{"id":23421154,"url":"https://github.com/nhsdigital/ndr_stats","last_synced_at":"2026-05-19T19:02:46.497Z","repository":{"id":41950042,"uuid":"259381654","full_name":"NHSDigital/ndr_stats","owner":"NHSDigital","description":"Lightweight wrapper around statsd client for easy instrumentation of Rails","archived":false,"fork":false,"pushed_at":"2025-02-05T19:40:58.000Z","size":61,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-09T09:41:48.289Z","etag":null,"topics":["instrumentation","rails","statsd"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/NHSDigital.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-27T15:59:51.000Z","updated_at":"2025-02-05T19:41:01.000Z","dependencies_parsed_at":"2025-04-09T09:46:54.026Z","dependency_job_id":null,"html_url":"https://github.com/NHSDigital/ndr_stats","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/NHSDigital/ndr_stats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fndr_stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fndr_stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fndr_stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fndr_stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NHSDigital","download_url":"https://codeload.github.com/NHSDigital/ndr_stats/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fndr_stats/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267349511,"owners_count":24073101,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["instrumentation","rails","statsd"],"created_at":"2024-12-23T02:14:12.402Z","updated_at":"2026-05-19T19:02:46.399Z","avatar_url":"https://github.com/NHSDigital.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NdrStats [![Build Status](https://github.com/NHSDigital/ndr_stats/workflows/Test/badge.svg)](https://github.com/NHSDigital/ndr_stats/actions?query=workflow%3Atest) [![Gem Version](https://badge.fury.io/rb/ndr_stats.svg)](https://badge.fury.io/rb/ndr_stats)\n\nProvides pain-free setup of stats collecting to Ruby/Rails projects.\n\n## Assumed Architecture\n\nThis library currently sends UDP packets to the configured receiver using the statsd format (with tagging addition).\n\nThe conventional way we set this up is as follows:\n\n```\n+-------------+   UDP   +----------------------------+\n| Ruby client |  ----\u003e  | Prometheus Statsd Exporter |\n+-------------+         +----------------------------+\n                                     |\n                                     | scraped by\n                                     V\n  +---------+            +-----------------------+\n  | Grafana |    \u003c----   | Central Prometheus DB |\n  +---------+            +-----------------------+\n```\n\n## Setup\n\n### Ruby\n\nFirst, set up the library to point at a Statsd receiver:\n\n```ruby\nNdrStats.configure(host: 'localhost', port: 9125)\n```\n\n### Rails\n\nWhen used in a Rails application, you have the option to auto-configure `NdrStats`.\n\n#### File-based\n\nAdd configuration in `config/stats.yml`:\n\n```yaml\n---\nhost: localhost\nport: 9125\n```\n\n#### Environment config\n\nAlternatively, you can use environment variables `NDR_STATS_{HOST,PORT,SYSTEM,STACK}` to provide config parameters.\nEnvironment variables override any file-based configuration that's also found.\n\n#### System / Stack\n\nIt's additionally possible to specify `system` and `stack`, which will be automatically added as tags on all stats.\nIf the host application's enclosing module responds to the `flavour` or `stack` methods, these will be used if not otherwise specified.\n\n\n## Usage\n\nBasic usage is as follows:\n\n```ruby\n# increment counts of things:\nNdrStats.count(:issues)\nNdrStats.count(:issues, 3)\n\n# time things:\nNdrStats.time(:paint_drying) { paint.dry! }\nNdrStats.timing(:web_request, 100) # milliseconds\n\n# set counts of things:\nNdrStats.gauge(:population, 8_000_000_000)\n```\n\nAll methods additionally accept tags, sent using the DataDog format extension:\n\n```ruby\nNdrStats.count(:issues, +1, type: :closed)\nNdrStats.count(:issues, -1, type: :open)\n```\n\n### Pings\n\nYou can register background pings (for process status checks) using `NdrStats.ping`,\nby supplying tags. These will also use any default tags you have configured.\n\nMetrics:\n* `ndr_stats_initial_ping` is incremented once, initially\n* `ndr_stats_ping` is then incremented periodically, according to the frequency\n* `ndr_stats_final_ping` is incremented once on exit, if it's possible to do so.\n\n```ruby\n# basic tagged ping:\nNdrStats.ping(type: 'webapp')\n\n# supply additional tags:\nNdrStats.ping(type: 'daemon', name: 'batch importer')\n\n# set a custom frequency (defaults to every minute):\nNdrStats.ping(type: 'sloth', every: 3.hours)\n```\n\nSee `NdrStats::Ping` for more details.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git co\n\n\n## Code of Conduct\n\nEveryone interacting in the NdrStats project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the `CODE_OF_CONDUCT.md`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fndr_stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhsdigital%2Fndr_stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fndr_stats/lists"}