{"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.1.0","deps":[],"features":{},"cksum":"sha256:fa0c0546e80ff88a88477915164c568831a158041c93624a9454ba1de1e31b9b","sig":"ed25519:00b47957ba29e3784b21db4e1c737fd29958c40185d0eece54f778829748b24b712019cdee7bf92fad9cd473c8b80bc414de6233035c68dc01fe414fccc67100","key_fp":"SHA256:3njv78NJD/NTkV83eJ86yfrXqpu+l652GAjPzB/Grp0","yanked":false,"registry_sig":"ed25519:5782831705238cb2072aadf7861eb07bf771422a2bb779a9dfbc09e92abadbd6defdc70185a75eedb68b0a90fe9d11f5e452aaaa030eb625a7bf00137e7a690e","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-03-12T21:11:03.341Z","dl":"https://cdn.hewpkg.com/tarballs/hew/metrics/0.1.0.tar.zst"}}