{"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.7.0","deps":[],"features":{},"cksum":"sha256:291d42d39474b94c93d666c179c0e485f2e5fac961f5cb8d5d1d3c043857e6a4","sig":"ed25519:c847e2b12c5bfa2c6bb4a59f4b34d50b4765c9fff4ec747f4fcb620b081084283c2f82170ac749a65dd1089af31294d552193e3d2f6a0ddb438efd5045f64905","key_fp":"SHA256:QDgYk38yt+UbTDqWpi+aVd+Vkirhyd7m4y+5bVuNIpg","yanked":false,"edition":"2026","hew":">=0.10.0, <0.12.0","registry_sig":"ed25519:de149b7b52dbbdea134dc02e590a988420339febd5c7b28753d7ac7a4167a5d5344d916dc29a4d3e9b9f34f644223ac43240aa46ac98399590bce27014a8bb0d","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-11-13T06:01:21.034Z","dl":"https://cdn.hewpkg.com/tarballs/hew/metrics/0.7.0.tar.zst"}}