{"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-rc1","deps":[],"features":{},"cksum":"sha256:6101a4459bd19c04e22c42ff1c64ffdfa6d67001bd4eaaad991a40150501e0d0","sig":"ed25519:f0028979113d4f96e0c14800b07278d44f63e9076354a3057dedbee6952287c9a39b01d5a5063a25f665aac84a6830eba1cf5c0da15623ccd8d7f0fc9c51820a","key_fp":"SHA256:eJ/AxFqPuRnxO+ddzX7ZfpfHcRs/3Dh4c81uBJi9tfM","yanked":false,"edition":"2026","hew":">=0.10.0, <0.11.0","registry_sig":"ed25519:5e702d82df7e77bc73b627284397233743b6bed63cbb27f80c9cdfec18cbbb43fda1609cc12e1ba40aaddfcf925385c7f12199989da4f18571823eee4136a409","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-26T17:16:59.085Z","dl":"https://cdn.hewpkg.com/tarballs/hew/metrics/0.7.0-rc1.tar.zst"}}