{"metadata":{"name":"hew/metrics","vers":"0.7.1","description":"Actor-owned Prometheus metrics for Hew — typed counters, gauges, histograms, labels, and export","license":"MIT OR Apache-2.0","authors":["Hew Contributors"],"deps":[],"features":{},"keywords":["metrics","prometheus","monitoring","observability"],"repository":"https://github.com/hew-lang/ecosystem","edition":"2026","hew":">=0.10.0, <0.12.0","readme":"# hew.metrics\n\nActor-owned Prometheus counters, gauges, histograms, labels, and text export.\nEvery registration, mutation and export handler declares `fails\nMetricsError`, so a call replies `Result<T, ActorError<MetricsError>>`: match\n`.Ok(value)`, `.Err(.Failed(error))` for a metrics error, and `.Err(_)` for a\nregistry that could not answer. Registration replies the metric handle,\n`export` the text, and every mutation `()`. Stopping the actor releases its\nnative registry.\n\nEach labeled metric retains at most 1024 distinct label-value tuples. Once the\nlimit is reached, existing tuples remain mutable and operations with a new\ntuple return `MetricsError.SeriesLimit`.\n\n```hew\nimport hew.metrics;\n\nfn export_requests() -> string {\n    let registry = spawn metrics.Registry;\n    let text = match registry.counter(\"requests_total\", \"Handled requests\") {\n        .Ok(counter) => {\n            let _ = registry.counter_inc(counter);\n            let _ = registry.counter_add(counter, 2.0);\n            match registry.export() {\n                .Ok(text) => text,\n                .Err(.Failed(error)) => metrics.error_message(error),\n                .Err(_) => \"metrics actor stopped before replying\",\n            }\n        }\n        .Err(.Failed(error)) => metrics.error_message(error),\n        .Err(_) => \"metrics actor stopped before replying\",\n    };\n    stop(registry);\n    stopped(registry);\n    text\n}\n\nfn main() {\n    println(export_requests());\n}\n\n#[test]\n#[real_time]\nfn exports_the_incremented_counter() {\n    assert(export_requests().contains(\"\\nrequests_total 3\\n\"));\n}\n```\n\nThis is [`examples/basic.hew`](examples/basic.hew) without its header comment. Run it\nfrom the ecosystem checkout:\n\n```sh\nhew run --pkg-path . metrics/examples/basic.hew\n```\n\nIt prints the Prometheus text exposition of everything the registry holds:\n\n```text\n# HELP requests_total Handled requests\n# TYPE requests_total counter\nrequests_total 3\n```\n\n`export()` is what makes a registry observable, so the example calls it rather\nthan incrementing a counter and exiting silently, and its test checks the\n`requests_total 3` line.\n"},"version":{"name":"hew/metrics","vers":"0.4.0","deps":[],"features":{},"cksum":"sha256:877edc148bc805b5cb0f4a60764f5c0e355685b973e53dac43109f2ded1e7e43","sig":"ed25519:2eb4a9203b1c5b66a83ee4191fc9c45e1e9a605a30870018039825758bb8e6b5246e002aaa72ff5f7cbfddc25d6690aa057dd50483fcb668f089539bdb178208","key_fp":"SHA256:xl0hCTnhRoxLob4M6UdsT7Jtjn0a2wyYJf9ObIANTao","yanked":false,"edition":"2026","hew":">=0.6.2, <0.7.0","registry_sig":"ed25519:4a15ac8178ee1e6682264ef028d209ea4d0b5ae67066d0b4adbc316a778438c9003b21ae6b5c57a4058632cc6b3ff769aa2918f35eb49b77bd62dfa1c24a4a06","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-21T03:47:49.740Z","dl":"https://cdn.hewpkg.com/tarballs/hew/metrics/0.4.0.tar.zst"}}