{"id":20795665,"url":"https://github.com/graze/dog-statsd","last_synced_at":"2025-05-01T09:55:16.043Z","repository":{"id":44568526,"uuid":"45537113","full_name":"graze/dog-statsd","owner":"graze","description":":dog: DataDog StatsD Client","archived":false,"fork":false,"pushed_at":"2022-02-07T22:05:11.000Z","size":119,"stargazers_count":41,"open_issues_count":6,"forks_count":12,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-01T09:54:35.306Z","etag":null,"topics":["datadog","php","statsd","statsd-client"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graze.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-04T12:19:39.000Z","updated_at":"2024-09-10T23:40:20.000Z","dependencies_parsed_at":"2022-09-11T19:12:32.814Z","dependency_job_id":null,"html_url":"https://github.com/graze/dog-statsd","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graze%2Fdog-statsd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graze%2Fdog-statsd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graze%2Fdog-statsd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graze%2Fdog-statsd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graze","download_url":"https://codeload.github.com/graze/dog-statsd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251856993,"owners_count":21655119,"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":["datadog","php","statsd","statsd-client"],"created_at":"2024-11-17T16:23:11.949Z","updated_at":"2025-05-01T09:55:16.009Z","avatar_url":"https://github.com/graze.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graze/dog-statsd\n\n![Giphy](http://media1.giphy.com/media/ALCI3eTii7qOk/giphy.gif)\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/graze/dog-statsd.svg?style=flat-square)](https://packagist.org/packages/graze/dog-statsd)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/graze/dog-statsd/master.svg?style=flat-square)](https://travis-ci.org/graze/dog-statsd)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/graze/dog-statsd.svg?style=flat-square)](https://scrutinizer-ci.com/g/graze/dog-statsd/code-structure)\n[![Quality Score](https://img.shields.io/scrutinizer/g/graze/dog-statsd.svg?style=flat-square)](https://scrutinizer-ci.com/g/graze/dog-statsd)\n[![Total Downloads](https://img.shields.io/packagist/dt/graze/dog-statsd.svg?style=flat-square)](https://packagist.org/packages/graze/dog-statsd)\n\nClient to talk to [DataDogs StatsD Agent](http://docs.datadoghq.com/guides/dogstatsd) Forked from:\n[League/StatsD](https://github.com/thephpleague/statsd)\n\nFor more information on the metric, see: [Datadogs metrics guide](http://docs.datadoghq.com/guides/metrics/).\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require graze/dog-statsd\n```\n\n## Usage\n\n### Configuring\n\n```php\n$statsd = new Graze\\DogStatsD\\Client();\n$statsd-\u003econfigure([\n    'host' =\u003e '127.0.0.1',\n    'port' =\u003e 8125,\n    'namespace' =\u003e 'example',\n]);\n```\n\nOR\n\n```php\n$statsd1 = DogStatsD\\Client::instance('server1')-\u003econfigure([...]);\n$statsd2 = DogStatsD\\Client::instance('server2')-\u003econfigure([...]);\n```\n\nThe StatsD client waits for `ini_get('default_socket_timeout')` seconds when opening the socket by default. To reduce\nthis timeout, add `'timeout' =\u003e \u003cint\u003e` to your config.\n\nThe StatsD client will either throw a `ConnectionException`, throw a warning or ignore all errors if it is unable to\nsend data to the StatsD server. This can be configured using the `onError` property\n\n```\n    'onError' =\u003e 'error' // 'error', 'exception' or 'ignore'\n```\n\nBy default this is set to `'error'`\n\n#### Core StatsD implementation\n\nTo use this with a core statsd implementation (without the extra features DataDog have added) include the following in\nyour configuration:\n```\n'dataDog' =\u003e false\n```\n\n### Methods\n\n#### Counters\n\n```php\n$statsd-\u003eincrement('web.pageview');\n$statsd-\u003edecrement('storage.remaining');\n$statsd-\u003eincrement([\n    'first.metric',\n    'second.metric'\n], 2);\n$statsd-\u003eincrement('web.clicks', 1, 0.5);\n```\n\n#### Gauges\n\n```php\n$statsd-\u003egauge('api.logged_in_users', 123456);\n```\n\n#### Sets\n\n```php\n$userID = 23;\n$statsd-\u003eset('api.unique_logins', $userID);\n```\n\n#### Histogram\n\n```php\n$result = $db-\u003efetch();\n$statsd-\u003ehistogram('db.results', count($result), 0.5);\n```\n\n#### Timers\n\n```php\n$statsd-\u003etiming('api.response_time', 256);\n```\n\n#### Timing Blocks\n\n```php\n$statsd-\u003etime('api.dbcall', function () {\n    // this code execution will be timed and recorded in ms\n});\n```\n\n#### Tags\n\n```php\n$statsd-\u003eincrement('web.pageview', 1, ['page' =\u003e 'some/page']);\n$statsd-\u003eguage('api.logged_in_users', 123456, ['environement' =\u003e 'live']);\n$statsd-\u003eset('api.unique_logins', $userID, ['tag']);\n$statsd-\u003etiming('api.response_time', 245, ['end-point' =\u003e 'page', 'env' =\u003e 'test']);\n```\n\n##### Tags Processors\n\nYou can add tag processors to inject tags at runtime for each metric.\n\n```php\n$statsd-\u003eaddTagProcessor(function (array $tags) {\n    $tags['new-key'] = 'new-value';\n    return $tags;\n});\n```\n\n#### Events\n\n```php\n$statsd-\u003eevent(\n    'build.success',\n    'The build super_awesome_application_build_1 has completed',\n    [\n        'time'  =\u003e time(),\n        'alert' =\u003e Client::ALERT_SUCCESS,\n    ],\n    [\n        'environment' =\u003e 'live',\n    ]\n);\n```\n\n#### Service Check\n\n```php\n$statsd-\u003eserviceCheck(\n    'service.api.account',\n    Client::STATUS_OK,\n    [\n        'host' =\u003e 'this.hostname.com',\n        'time' =\u003e time(),\n    ],\n    [\n        'environment' =\u003e 'staging',\n    ]\n);\n```\n\n#### Default Tags\n\nSend the same base tags with every request\n\n```php\n$client = new Client();\n$client-\u003econfigure([\n    'tags' =\u003e [\n        'env'     =\u003e 'live',\n        'release' =\u003e 'app-2.3.1',\n    ],\n]);\n```\n\n## Testing\n\n``` bash\n$ make test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email security@graze.com instead of using the issue tracker.\n\n## Credits\n\n- [Harry Bragg](https://github.com/h-bragg)\n- [All Contributors](../../contributors)\n\n### Forked from [thephpleague/statsd](https://github.com/thephpleague/statsd):\n\n- [Marc Qualie](https://github.com/marcqualie)\n- [League/StatsD Contributors](https://github.com/thephpleague/statsd/contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraze%2Fdog-statsd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraze%2Fdog-statsd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraze%2Fdog-statsd/lists"}