{"id":21893769,"url":"https://github.com/goodwaygroup/lib-hapi-dogstatsd","last_synced_at":"2025-04-15T15:32:55.084Z","repository":{"id":33117058,"uuid":"131146912","full_name":"GoodwayGroup/lib-hapi-dogstatsd","owner":"GoodwayGroup","description":"Hapi plugin for publishing route stats to Datadog","archived":false,"fork":false,"pushed_at":"2025-01-21T22:26:30.000Z","size":365,"stargazers_count":2,"open_issues_count":17,"forks_count":0,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-28T21:51:10.497Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/GoodwayGroup.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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-04-26T11:39:42.000Z","updated_at":"2021-06-02T18:22:57.000Z","dependencies_parsed_at":"2023-11-22T18:29:59.920Z","dependency_job_id":"deaf38a3-bc53-4b6c-b73a-4e78530c3c16","html_url":"https://github.com/GoodwayGroup/lib-hapi-dogstatsd","commit_stats":{"total_commits":107,"total_committers":6,"mean_commits":"17.833333333333332","dds":0.485981308411215,"last_synced_commit":"2e3de9e42a624566505057532bdf9a18b97f6f4b"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoodwayGroup%2Flib-hapi-dogstatsd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoodwayGroup%2Flib-hapi-dogstatsd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoodwayGroup%2Flib-hapi-dogstatsd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoodwayGroup%2Flib-hapi-dogstatsd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoodwayGroup","download_url":"https://codeload.github.com/GoodwayGroup/lib-hapi-dogstatsd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249098273,"owners_count":21212458,"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-11-28T13:16:38.850Z","updated_at":"2025-04-15T15:32:55.061Z","avatar_url":"https://github.com/GoodwayGroup.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lib-hapi-dogstatsd\n\n[![CircleCI](https://circleci.com/gh/GoodwayGroup/lib-hapi-dogstatsd.svg?style=svg)](https://circleci.com/gh/GoodwayGroup/lib-hapi-dogstatsd)\n[![Coverage Status](https://coveralls.io/repos/github/GoodwayGroup/lib-hapi-dogstatsd/badge.svg?branch=master)](https://coveralls.io/github/GoodwayGroup/lib-hapi-dogstatsd?branch=master)\n[![npm downloads](https://img.shields.io/npm/dm/@goodwaygroup/lib-hapi-dogstatsd.svg?style=flat-square)](http://npm-stat.com/charts.html?package=@goodwaygroup/lib-hapi-dogstatsd)\n[![install size](https://packagephobia.com/badge?p=@goodwaygroup/lib-hapi-dogstatsd)](https://packagephobia.com/result?p=@goodwaygroup/lib-hapi-dogstatsd)\n\n\u003e Please do not run this plugin within tests in your application\n\n## Usage\n\nThis plugin will send metrics regarding route performance on every request to the Hapi server.\n\nFor the `prefix`, please the name of the service that you are integrating with (neato-service, cool-api, etc)\n\n```\n$ npm install -S @goodwaygroup/lib-hapi-dogstatsd\n```\n\nIn your `index.js` for the Hapi server, register the plugin:\n\n```js\nconst HapiDogstatsd = require('@goodwaygroup/lib-hapi-dogstatsd')\n\n// Dogstatsd\nif (process.env.DOGSTATSD_HOST \u0026\u0026 process.env.NODE_ENV !== 'test') {\n    await server.register({\n        plugin: HapiDogstatsd,\n        options: {\n            host: process.env.DOGSTATSD_HOST,\n            port: process.env.DOGSTATSD_PORT || 8125,\n            tags: [`env:${process.env.NODE_ENV || 'development'}`],\n            prefix: 'neato-service'\n        }\n    });\n}\n```\n\n## Configuration Options\n\n\u003e When passing a configuration option, it will overwrite the defaults.\n\n- `host`: The host running the Datadog Daemon with dogstatsd configured\n- `port`: Port for dogstatsd\n    - default: `8125`\n- `prefix`: A prefix that will be prepended to all metrics sent to DataDog\n    - default: `hapi`\n- `tags`: An array of tags that will be applied to all metrics that are sent\n    - default: ```[`env:${process.env.NODE_ENV || 'development'}`]```\n- `excludedPaths`: An array of URL paths to ignore sending metrics for.\n    - default: `['/favicon.ico', '/health-check']`\n- `excludedTags`: An array of tag keys that will be excluded from the default list of tags added to each metric. The default list of tags is: `dns, url_path, route_path, status_code, http_method`\n    - default: `[]`\n\n### Route Based Tags\n\nTo add custom tags specific to a route, use the [response.plugin](https://github.com/hapijs/hapi/blob/master/API.md#response.plugins) state block to pass `tags` to the plugin. These tags will be merged with the default tags that are generated.\n\n```js\nresponse.plugins['dogstatsd'] = { tags: ['custom:tag', 'key:value'] }\n```\n\n### Route Based Metrics\n\nTo add custom metrics specific to a route, use the [response.plugin](https://github.com/hapijs/hapi/blob/master/API.md#response.plugins) state block to pass `metrics` to the plugin. These metrics will be merged with the default metrics that are generated.\n\nThe `metrics` will need to have the following structure.\n\n```js\nresponse.plugins.dogstatsd.metrics = [{\n    type: 'gauge',\n    name: 'cache.orphans',\n    value: 123,\n    tags: [`cache_db:${cache}`]\n}, {\n    type: 'incr',\n    name: 'cache.hit',\n    value: null,\n    tags: [`cache_db:${cache}`]\n}]\n```\n\n### Default Tags\n\nThese tags are set on every request:\n\n```js\nconst tags = [\n    `env:${process.env.NODE_ENV || 'development'}`,\n    `dns:${request.headers.host}`,\n    `url_path:${request.url.pathname}`,\n    `route_path:${request.route.path}`,\n    `status_code:${statusCode}`,\n    `http_method:${request.method.toUpperCase()}`\n];\n```\n\nExample:\n\n```\n[\n    'end:production',\n    'dns:github.com',\n    'url_path:/api/v1/user/34/edit',\n    'route_path:/api/v1/user/{id}/edit',\n    'status_code:200',\n    'http_method:POST'\n]\n```\n\n## Running Tests\n\nTo run tests, just run the following:\n\n```\nnpm test\n```\n\nAll commits are tested on [CircleCI](https://circleci.com/gh/GoodwayGroup/workflows/lib-hapi-dogstatsd)\n\n## Linting\n\nTo run `eslint`:\n\n```\nnpm run lint\n```\n\nTo auto-resolve:\n\n```\nnpm run lint:fix\n```\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Versioning\n\nWe use milestones and `npm` version to bump versions. We also employ [git-chglog](https://github.com/git-chglog/git-chglog) to manage the [CHANGELOG.md](CHANGELOG.md). For the versions available, see the [tags on this repository](https://github.com/GoodwayGroup/lib-hapi-dogstatsd/tags).\n\nTo initiate a version change:\n\n```\nnpm version major|minor|patch\n```\n\n## Authors\n\n* **Derek Smith** - *Initial work* - [@clok](https://github.com/clok)\n\nSee also the list of [contributors](https://github.com/GoodwayGroup/lib-hapi-dogstatsd/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n\n## Acknowledgments\n\n* Inspired by the great work done by [@mac-](https://github.com/mac-) in [hapi-statsd](https://github.com/mac-/hapi-statsd)\n* Uses the [dog-statsy](https://github.com/segmentio/dog-statsy) module.\n\n## Sponsors\n\n[![goodwaygroup][goodwaygroup]](https://goodwaygroup.com)\n\n[goodwaygroup]: https://s3.amazonaws.com/gw-crs-assets/goodwaygroup/logos/ggLogo_sm.png \"Goodway Group\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoodwaygroup%2Flib-hapi-dogstatsd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoodwaygroup%2Flib-hapi-dogstatsd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoodwaygroup%2Flib-hapi-dogstatsd/lists"}