{"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.2.0","deps":[],"features":{},"cksum":"sha256:56f3b4383cbc570dcb2a210f0daf702428bc6a14a8bdf0412ef550440f445702","sig":"ed25519:f3223793e21fbbc631f03efd87ae2b0d6872c71b147a5ba928daf792c657bab8bb65d8e53ca9746a77f1cf9234405f5e0e6a8e1141b5338675bc6023e97c9102","key_fp":"SHA256:UspGxFtb7yFbHAcyG72z6OYMpTR5mLh+BO2Rht625yY","yanked":false,"edition":"2026","hew":">=0.6.0-rc1, <0.7.0","registry_sig":"ed25519:6497a027ac605be7fd9c2d2d3381b49cddbff21b81ed9a4e29c1773154faf0d032af8576c912f90a47cdbb5f126445769046adb5eb9ea02d15c6e84b3d841901","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-08-15T20:03:57.038Z","dl":"https://cdn.hewpkg.com/tarballs/hew/metrics/0.2.0.tar.zst"}}