{"id":16511158,"url":"https://github.com/danog/better-prometheus","last_synced_at":"2026-03-06T12:31:38.539Z","repository":{"id":237946577,"uuid":"795565334","full_name":"danog/better-prometheus","owner":"danog","description":"A better Prometheus library for PHP applications.","archived":false,"fork":false,"pushed_at":"2024-05-09T19:11:46.000Z","size":27,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-09T13:17:50.694Z","etag":null,"topics":["prometheus","prometheus-exporter","prometheus-metrics"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"danog"}},"created_at":"2024-05-03T14:55:59.000Z","updated_at":"2025-08-28T16:50:39.000Z","dependencies_parsed_at":"2024-10-28T10:14:09.586Z","dependency_job_id":"35c1fb87-8378-444c-ae6e-447fb2f5c455","html_url":"https://github.com/danog/better-prometheus","commit_stats":null,"previous_names":["danog/better-prometheus"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/danog/better-prometheus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Fbetter-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Fbetter-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Fbetter-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Fbetter-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danog","download_url":"https://codeload.github.com/danog/better-prometheus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danog%2Fbetter-prometheus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30176166,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T11:48:51.886Z","status":"ssl_error","status_checked_at":"2026-03-06T11:48:51.460Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["prometheus","prometheus-exporter","prometheus-metrics"],"created_at":"2024-10-11T15:59:10.984Z","updated_at":"2026-03-06T12:31:38.517Z","avatar_url":"https://github.com/danog.png","language":"PHP","funding_links":["https://github.com/sponsors/danog"],"categories":[],"sub_categories":[],"readme":"# better-prometheus\n\n[![Psalm coverage](https://shepherd.dev/github/danog/better-prometheus/coverage.svg)](https://shepherd.dev/github/danog/better-prometheus)\n[![Psalm level 1](https://shepherd.dev/github/danog/better-prometheus/level.svg)](https://shepherd.dev/github/danog/better-prometheus)\n![License](https://img.shields.io/github/license/danog/better-prometheus?v)\n\nA better Prometheus library for PHP applications.  \n\nOffers a modern, clean PHP 8.1 API, with support for **default label values**, based on and compatible with the original `promphp/prometheus_client_php` library.   \n\n## Installation\n\n```bash\ncomposer require danog/better-prometheus\n```\n\n## Usage\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n\nuse danog\\BetterPrometheus\\BetterCollectorRegistry;\nuse Prometheus\\Storage\\InMemory;\nuse Prometheus\\Storage\\Redis;\n\n$adapter = new InMemory;\n// Any other promphp adapter may also be used...\n// $adapter = new Redis();\n\n$registry = new BetterCollectorRegistry($adapter);\n\n// Note the difference with promphp: the labels are keys =\u003e values, not just keys.  \n$counter = $registry-\u003egetOrRegisterCounter(\n    'test',\n    'some_counter',\n    'it increases',\n    // Note: these are default label key+values, they will be sent verbatim, no changes\n    ['someLabel' =\u003e 'defaultValue']\n);\n\n// Specify some additional labels post-construction like this (both keys and values)...\n$counter-\u003eincBy(3, ['type' =\u003e 'blue']);\n\n// ...or add some more default labels to the counter, creating a new counter:\n$newCounter = $counter-\u003eaddLabels(['someOtherLabel' =\u003e 'someOtherDefaultValue']);\nassert($newCounter !== $counter); // true\n$newCounter-\u003eincBy(3, ['type' =\u003e 'blue']);\n\n\n// Gauges can also be used\n$gauge = $registry-\u003egetOrRegisterGauge(\n    'test',\n    'some_gauge',\n    'it sets',\n    ['someLabel' =\u003e 'defaultValue']\n);\n$gauge-\u003eset(2.5, ['type' =\u003e 'blue']);\n\n\n\n// As well as histograms\n$histogram = $registry-\u003egetOrRegisterHistogram(\n    'test',\n    'some_histogram',\n    'it observes',\n    ['someLabel' =\u003e 'defaultValue'],\n    // [0.1, 1, 2, 3.5, 4, 5, 6, 7, 8, 9]\n);\n$histogram-\u003eobserve(3.5, ['type' =\u003e 'blue']);\n\n\n// And suummaries\n$summary = $registry-\u003egetOrRegisterSummary(\n    'test',\n    'some_summary',\n    'it observes a sliding window',\n    ['someLabel' =\u003e 'defaultValue'],\n    // 84600,\n    // [0.01, 0.05, 0.5, 0.95, 0.99]\n);\n\n$summary-\u003eobserve(5, ['type' =\u003e 'blue']);\n```\n\n## API documentation\n\nSee [here \u0026raquo;](https://daniil.it/better-prometheus/docs/) for the full API documentation.  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanog%2Fbetter-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanog%2Fbetter-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanog%2Fbetter-prometheus/lists"}