{"id":23024637,"url":"https://github.com/previousnext/php-prometheus","last_synced_at":"2025-08-14T11:32:21.312Z","repository":{"id":49244898,"uuid":"151487512","full_name":"previousnext/php-prometheus","owner":"previousnext","description":"PHP library for serializing to the Prometheus text format.","archived":false,"fork":false,"pushed_at":"2024-06-04T01:57:49.000Z","size":36,"stargazers_count":6,"open_issues_count":2,"forks_count":4,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-12-07T18:36:03.345Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/previousnext.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2018-10-03T22:16:40.000Z","updated_at":"2024-06-04T01:57:15.000Z","dependencies_parsed_at":"2024-06-21T19:08:51.994Z","dependency_job_id":"376f4879-babb-4842-902e-39779a2f5e33","html_url":"https://github.com/previousnext/php-prometheus","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":0.05882352941176472,"last_synced_commit":"139abd97fe24c821706af08d54c2410485864d7a"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/previousnext%2Fphp-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/previousnext%2Fphp-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/previousnext%2Fphp-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/previousnext%2Fphp-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/previousnext","download_url":"https://codeload.github.com/previousnext/php-prometheus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229822641,"owners_count":18129586,"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","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":[],"created_at":"2024-12-15T13:20:21.470Z","updated_at":"2024-12-15T13:20:22.092Z","avatar_url":"https://github.com/previousnext.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Prometheus Serializer\n\nA PHP library for serializing to the prometheus text format.\n\n[![CircleCI](https://circleci.com/gh/previousnext/php-prometheus.svg?style=svg)](https://circleci.com/gh/previousnext/php-prometheus)\n\n**NOTE** This library does not keep state. It is intended purely as a serialization library. Therefore, there are no\nmethods into increment or decrement values for metrics, only to set them in order to be serialized.\n\n## Installation\n\n```\ncomposer require previousnext/php-prometheus\n```\n\n## Usage\n\n### Gauge\n\n```php\n$gauge = new Gauge(\"foo\", \"bar\", \"A test gauge\");\n$gauge-\u003eset(100, ['baz' =\u003e 'wiz']);\n$gauge-\u003eset(90, ['wobble' =\u003e 'wibble', 'bing' =\u003e 'bong']);\n$gauge-\u003eset(0);\n\n$serializer = MetricSerializerFactory::create();\n$output = $serializer-\u003eserialize($gauge, 'prometheus');\n```\n\nExpected output:\n\n```text\n# HELP foo_bar A test gauge\n# TYPE foo_bar gauge\nfoo_bar{baz=\"wiz\"} 100\nfoo_bar{wobble=\"wibble\",bing=\"bong\"} 90\nfoo_bar 0\n```\n\n### Counter\n\n```php\n$counter = new Counter(\"foo\", \"bar\", \"A counter for testing\");\n$counter-\u003eset(100, ['baz' =\u003e 'wiz']);\n\n$serializer = MetricSerializerFactory::create();\n$output = $serializer-\u003eserialize($counter, 'prometheus');\n```\n\nExpected output:\n\n```text\n# HELP foo_bar A counter for testing\n# TYPE foo_bar counter\nfoo_bar{baz=\"wiz\"} 100\n```\n\n### Summary\n\n```php\n$summary = new Summary(\"foo\", \"bar\", \"Summary help text\", 'baz');\n$buckets = [0, 0.25, 0.5, 0.75, 1];\n$values = [2, 4, 6, 8, 10];\n$summary-\u003esetValues($buckets, $values);\n$summary-\u003esetSum(54321);\n$summary-\u003esetCount(212);\n\n$serializer = MetricSerializerFactory::create();\n$output = $serializer-\u003eserialize($summary, 'prometheus');\n```\n\nExpected output:\n\n```text\n# HELP foo_bar Summary help text\n# TYPE foo_bar summary\nfoo_bar{baz=\"0\"} 2\nfoo_bar{baz=\"0.25\"} 4\nfoo_bar{baz=\"0.5\"} 6\nfoo_bar{baz=\"0.75\"} 8\nfoo_bar{baz=\"1\"} 10\nfoo_bar_sum 54321\nfoo_bar_count 212\n```\n\n## Developing\n\nPHP CodeSniffer\n```\n./bin/phpcs\n```\n\nPHPUnit\n\n```\n./bin/phpunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreviousnext%2Fphp-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreviousnext%2Fphp-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreviousnext%2Fphp-prometheus/lists"}