{"id":14984061,"url":"https://github.com/lamoda/php-metrics","last_synced_at":"2025-04-06T04:11:18.283Z","repository":{"id":30834221,"uuid":"126138069","full_name":"lamoda/php-metrics","owner":"lamoda","description":"PHP metric responder and storage abstraction library","archived":false,"fork":false,"pushed_at":"2024-11-13T10:59:01.000Z","size":150,"stargazers_count":36,"open_issues_count":3,"forks_count":10,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-03-30T03:05:41.499Z","etag":null,"topics":["metrics","monitoring","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lamoda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2018-03-21T07:12:43.000Z","updated_at":"2024-11-13T10:56:46.000Z","dependencies_parsed_at":"2024-06-12T16:56:32.820Z","dependency_job_id":"79744f77-0d56-47e9-82b0-2e72cc2ca1f7","html_url":"https://github.com/lamoda/php-metrics","commit_stats":{"total_commits":44,"total_committers":13,"mean_commits":"3.3846153846153846","dds":0.6363636363636364,"last_synced_commit":"23a7077e1c81e09855369813ec6646072f543041"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamoda%2Fphp-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamoda%2Fphp-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamoda%2Fphp-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamoda%2Fphp-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamoda","download_url":"https://codeload.github.com/lamoda/php-metrics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430870,"owners_count":20937874,"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":["metrics","monitoring","php"],"created_at":"2024-09-24T14:08:23.433Z","updated_at":"2025-04-06T04:11:18.258Z","avatar_url":"https://github.com/lamoda.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lamoda metric responder\n\n[![Build Status](https://github.com/lamoda/php-metrics/workflows/Tests/badge.svg?branch=master)](https://github.com/lamoda/php-metrics/workflows/Tests/badge.svg?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/lamoda/php-metrics/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/lamoda/php-metrics/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/lamoda/php-metrics/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/lamoda/php-metrics/?branch=master)\n[![Build Status](https://scrutinizer-ci.com/g/lamoda/php-metrics/badges/build.png?b=master)](https://scrutinizer-ci.com/g/lamoda/php-metrics/build-status/master)\n[![Latest Stable Version](https://poser.pugx.org/lamoda/metrics/v/stable)](https://packagist.org/packages/lamoda/metrics)\n\n## Features\n\n* Metric responder with lazy sourcing\n* Multiple metric response formats\n  * [Telegraf `JSON`](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/httpjson)\n  * [Prometheus exporter](https://prometheus.io/docs/instrumenting/writing_exporters/)\n* Symfony bundle [optional]\n* Doctrine and redis/predis integration out of the box\n\n## Installation\n\n* install with composer\n\n```sh\ncomposer require lamoda/metrics:^2.0\n```\n\n## Usage examples\n\n* [Collecting metrics](doc/examples/01_collect.md)\n* [Storing metrics](doc/examples/02_store.md)\n* [Responding metrics](doc/examples/03_respond.md)\n* [Symfony integration](src/MetricBundle/Resources/docs/integration.md)\n\n## Main terms\n\n* **Metric** is a named value, representing system running state, health check or cumulative measurement, optionally tagged\n\n* **Metric response** is a set of metrics collected for the fixed moment of time, formatted for single input format\n* **Metric responder** is a http endpoint used to render collected metrics into suitable web response format\n\n* **Metrics** can be **sourced** in the terms of dynamic spawning for collection generation\n  * The general advice is to have metrics as lazy as possible, resolving to the fixed at the time of generation response\n  * Usually **Source** is implemented as an instance of `\\Traversable` object to embed into collection\n\nMetric are generally of two types:\n* **Precomputed** metrics are usually generated outside of responding process, like counters\n* **Runtime** metrics are generated on call, representing the current state of the system\n\nFrom the point of metric responding the difference between types is nominal since PHP has share nothing architecture and most stored values should\nbe obtained from storage in any case (and thus waste some caller time), so\nin general **Precomputed** metrics are just very fast **Runtime** metrics\n\nBut from the point of metric storing **Precomputed** metrics have more significant difference - some of them\ncan be retrieved from metric storage for update\n\n* **Mutable** metric is the **Metric**, which can be updated with either with some delta or with absolute value according to\n  business rules:\n  * Counters\n  * Accumulated total\n  * Balance\n\n* **Precomputed** metrics MAY NOT be **Mutable** since precomputing can be part of\n  the responder performance optimization process and there is no sense in adjusting such value as it is overwritten\n  during metric computation\n\n* **Mutable Metric Storage** is the general storage interface which allows end user to mutate some metric by name and tags.\n  It's depends on internal storage implementation, what happens if the metric is not found. If the storage allows\n  dynamic metric generation - new metric would be stored silently with given value\n\n## Supplementary terms\n\n* **Collector** is the generic class serving the metric **Source** to other parts of the library\n    * **Responder** to render\n    * **Storage** receiver to cache them\n    * Debug utilities for metric profiling and inspection\n\n  In general **Collector** could just keep preconfigured **Source** or retrieve data from other sources (API, DB, Cache)\n\n* **Materializing** is the process of resolving single metric **Collector** into precomputed metric **Source**\nand storing it in a resolved form for fast access to some **Storage** (Cache, DB, etc)\n\n* **Storage** is the metric storing driver. It is responsible for the following actions\n    * Create new metric instance by its primary parts - name, value and tags\n    * Find metric by name and tags\n    * Work as a **Source** of metrics\n    * Work as a receiver accepting **Source** to be materialized in it\n\n## Extending\n\nSee [extending chapter](doc/extending.md)\n\n## Development\n\n### Running tests\n```yaml\ncomposer install\nvendor/bin/phpunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamoda%2Fphp-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamoda%2Fphp-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamoda%2Fphp-metrics/lists"}