{"id":13736878,"url":"https://github.com/marcopacini/ts_prometheus","last_synced_at":"2025-09-08T19:42:37.418Z","repository":{"id":54381497,"uuid":"273336076","full_name":"marcopacini/ts_prometheus","owner":"marcopacini","description":"A prometheus client in Typescript for Deno","archived":false,"fork":false,"pushed_at":"2023-11-14T15:20:00.000Z","size":40,"stargazers_count":32,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-24T21:40:03.154Z","etag":null,"topics":["deno","metrics","prometheus","prometheus-client"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcopacini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-06-18T20:42:16.000Z","updated_at":"2024-05-21T21:40:52.000Z","dependencies_parsed_at":"2023-11-14T16:37:12.022Z","dependency_job_id":"d29d6cd8-4f6c-4d37-8055-3c9fa237e8b5","html_url":"https://github.com/marcopacini/ts_prometheus","commit_stats":{"total_commits":50,"total_committers":6,"mean_commits":8.333333333333334,"dds":0.24,"last_synced_commit":"48d51fff2690d4f377c8a23ff1e1c2d7ddcf20f0"},"previous_names":["marcopacini/ts-prometheus"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/marcopacini/ts_prometheus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcopacini%2Fts_prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcopacini%2Fts_prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcopacini%2Fts_prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcopacini%2Fts_prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcopacini","download_url":"https://codeload.github.com/marcopacini/ts_prometheus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcopacini%2Fts_prometheus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273948959,"owners_count":25196401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","metrics","prometheus","prometheus-client"],"created_at":"2024-08-03T03:01:30.347Z","updated_at":"2025-09-08T19:42:37.399Z","avatar_url":"https://github.com/marcopacini.png","language":"TypeScript","readme":"# ts_prometheus\n\nA prometheus client for Deno that supports counter, gauge, histrogram and\nsummary metric types.\n\n## Usage\n\nBy default all metrics are registered in the global `Registry` accessible via\n`Registry.default`. The `Registry` class has the method `metrics()` that returns\nthe text-based exposition for all metrics collected. But it is possible\nspecified one or more custom registry:\n\n```ts\nconst myRegistry = new Registry();\nconst myCounter = Counter.with({\n  name: \"my_counter\",\n  help: \"a counter with custom registry\",\n  registry: [myRegistry],\n});\n```\n\n## Examples\n\n- [ts-prometheus](https://github.com/marcopacini/ts-prometheus/blob/master/example/example.ts)\n- [oak](https://github.com/marcopacini/ts-prometheus/blob/master/example/oak/example.ts)\n- [Hono](https://github.com/marcopacini/ts-prometheus/blob/master/example/hono/example.ts)\n\n## Metric Types\n\n### Counter\n\n```ts\nconst counter = Counter.with({\n  name: \"http_requests_total\",\n  help: \"The total number of HTTP requests.\",\n  labels: [\"method\", \"status\"],\n});\n\nconst totalGetCreate = counter.labels({\n  method: \"GET\",\n  status: \"201\",\n});\n\ntotalGetCreate.inc();\ntotalGetCreate.inc(42);\n```\n\n```text\n# HELP http_requests_total The total number of HTTP requests.\n# TYPE http_requests_total counter\nhttp_requests_total{method=\"GET\",status=\"201\"} 43\n```\n\n### Gauge\n\n```ts\nconst gauge = Gauge.with({\n  name: \"cpu_time_usage\",\n  help: \"The CPU time usage.\",\n  labels: [\"mode\"],\n});\n\nconst cpuIdle = gauge.labels({\n  mode: \"idle\",\n});\n\ncpuIdle.set(0);\ncpuIdle.inc();\ncpuIdle.inc(42);\ncpuIdle.dec();\ncpuIdle.dec(3.14);\n```\n\n```\n# HELP cpu_time_usage The CPU time usage.\n# TYPE cpu_time_usage gauge\ncpu_time_usage{mode=\"idle\"} 38.86\n```\n\n### Histogram\n\n```ts\nconst histogram = Histogram.with({\n  name: \"http_requests_duration\",\n  help: \"A histogram of the requests duration.\",\n  buckets: [.05, .1, .2, .5, 1, 3],\n});\n\nhistogram.observe(.42);\nhistogram.observe(.58);\n```\n\n```\n# HELP http_requests_duration A histogram of the requests duration.\n# TYPE http_requests_duration histogram\nhttp_requests_duration_bucket{le=\"0.05\"} 0\nhttp_requests_duration_bucket{le=\"0.1\"} 0\nhttp_requests_duration_bucket{le=\"0.2\"} 0\nhttp_requests_duration_bucket{le=\"0.5\"} 1\nhttp_requests_duration_bucket{le=\"1\"} 2\nhttp_requests_duration_bucket{le=\"3\"} 2\nhttp_requests_duration_bucket{le=\"+Inf\"} 2\nhttp_requests_duration_sum 1\nhttp_requests_duration_count 2\n```\n\n### Summary\n\nBy default quantiles when not set are `[ .01, .05, .5, .95, .99 ]`.\n\n```ts\nlet summary = Summary.with({\n  name: \"http_response_size\",\n  help: \"A summary of the response size.\",\n  quantiles: [.25, .5, .75, 1],\n});\n\nlet values = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55];\nvalues.forEach((v) =\u003e summary.observe(v));\n```\n\n```\n# HELP http_response_size A summary of the response size.\n# TYPE http_response_size summary\nhttp_response_size{quantile=\"0.25\"} 2\nhttp_response_size{quantile=\"0.5\"} 5\nhttp_response_size{quantile=\"0.75\"} 21\nhttp_response_size{quantile=\"1\"} 55\nhttp_response_size_sum 143\nhttp_response_size_count 10\n```\n\nA sliding time window can be set using `maxAge` for defining the age of\nobservation in milliseconds, or `ageBuckets` for limiting the max number of\nobservations.\n\n```ts\nSummary.with({\n  name: \"http_response_size\",\n  help: \"A summary of the response size.\",\n  quantiles: [.25, .5, .75, 1],\n  maxAge: 1000, // milliseconds\n  ageBuckets: 5, // number of observations\n});\n```\n","funding_links":[],"categories":["基础设施"],"sub_categories":["JAM Stack/静态站点"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcopacini%2Fts_prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcopacini%2Fts_prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcopacini%2Fts_prometheus/lists"}