{"id":19312120,"url":"https://github.com/bigcommerce/gruf-prometheus","last_synced_at":"2026-03-10T07:03:07.287Z","repository":{"id":34936446,"uuid":"186699263","full_name":"bigcommerce/gruf-prometheus","owner":"bigcommerce","description":"Gruf plugin for Prometheus support","archived":false,"fork":false,"pushed_at":"2026-02-20T15:24:17.000Z","size":111,"stargazers_count":4,"open_issues_count":1,"forks_count":6,"subscribers_count":14,"default_branch":"main","last_synced_at":"2026-02-20T19:55:11.485Z","etag":null,"topics":["gruf","prometheus","ruby"],"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/bigcommerce.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-05-14T20:56:47.000Z","updated_at":"2026-02-20T15:24:21.000Z","dependencies_parsed_at":"2023-01-15T10:44:56.406Z","dependency_job_id":"601b9e5e-7bc9-46b1-9b14-74fa5616623e","html_url":"https://github.com/bigcommerce/gruf-prometheus","commit_stats":{"total_commits":48,"total_committers":2,"mean_commits":24.0,"dds":0.08333333333333337,"last_synced_commit":"8ec54652f2b9923da7bc72e23507750c2bceb42e"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/bigcommerce/gruf-prometheus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fgruf-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fgruf-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fgruf-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fgruf-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigcommerce","download_url":"https://codeload.github.com/bigcommerce/gruf-prometheus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigcommerce%2Fgruf-prometheus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30326893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["gruf","prometheus","ruby"],"created_at":"2024-11-10T00:32:56.146Z","updated_at":"2026-03-10T07:03:07.242Z","avatar_url":"https://github.com/bigcommerce.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gruf-prometheus - Prometheus support for gruf\n\n[![CircleCI](https://circleci.com/gh/bigcommerce/gruf-prometheus/tree/main.svg?style=svg)](https://circleci.com/gh/bigcommerce/gruf-prometheus/tree/main)  [![Gem Version](https://badge.fury.io/rb/gruf-prometheus.svg)](https://badge.fury.io/rb/gruf-prometheus) [![Documentation](https://inch-ci.org/github/bigcommerce/gruf-prometheus.svg?branch=main)](https://inch-ci.org/github/bigcommerce/gruf-prometheus?branch=main)\n\nAdds Prometheus support for [gruf](https://github.com/bigcommerce/gruf) 2.7.0+. Supports Ruby 3.x.\n\n## Installation\n\n```ruby\ngem 'gruf-prometheus'\n```\n\nIn your gruf initializer:\n\n```ruby\nrequire 'gruf/prometheus'\n\nGruf.configure do |c|\n  c.hooks.use(Gruf::Prometheus::Hook)\nend\n```\n\nThen `bundle exec gruf` and you'll automatically have prometheus metrics for your gruf server.\n\nThe gruf server will by default run on port 9394, and can be scraped at `/metrics`.\n\n## Integrations\n\n### System Metrics\n\nThe gem comes with general system metrics out of the box that illustrate server health/statistics:\n\n|Name|Type|Description|\n|---|---|---|\n|ruby_grpc_pool_jobs_waiting_total|gauge|Number of jobs in the gRPC thread pool that are actively waiting|\n|ruby_grpc_pool_ready_workers_total|gauge|The amount of non-busy workers in the thread pool|\n|ruby_grpc_pool_workers_total|gauge|Number of workers in the gRPC thread pool|\n|ruby_grpc_pool_initial_size|gauge|Initial size of the gRPC thread pool|\n|ruby_grpc_poll_period|gauge|Polling period for the gRPC thread pool|\n\n### Server Metrics\n\nFurthermore, the server interceptor measures general counts (and optionally, latencies), and can be setup via:\n\n```ruby\n::Gruf.interceptors.use(::Gruf::Prometheus::Server::Interceptor)\n```\n\nThis will output the following metrics:\n\n|Name|Type|Description|\n|---|---|---|\n|ruby_grpc_server_started_total|counter|Total number of RPCs started on the server|\n|ruby_grpc_server_failed_total|counter|Total number of RPCs that throw an unknown, internal, data loss, failed precondition, unavailable, deadline exceeded, or cancelled exception on the server|\n|ruby_grpc_server_handled_total|counter|Total number of RPCs completed on the server, regardless of success or failure|\n|ruby_grpc_server_handled_latency_seconds|histogram|Histogram of response latency of RPCs handled by the server, in seconds|\n\nNote that the histogram is disabled by default - you'll have to turn it on either through the `server_measure_latency`\nconfiguration yielded in `Gruf::Prometheus.configure`, or through the `PROMETHEUS_SERVER_MEASURE_LATENCY` environment\nvariable. Also, the `measure_latency: true` option can be passed as a second argument to `Gruf.interceptors.use` to\nconfigure this directly in the interceptor.\n\nThe precedence order for this is, from first to last, with last taking precedence:\n1) `measure_latency: true` passed into the interceptor\n2) `Gruf::Prometheus.configure` explicit setting globally\n3) `PROMETHEUS_SERVER_MEASURE_LATENCY` ENV var globally. This is the only value set by default - to `false` - and will\n   be the default unless other methods are invoked.\n\n### Client Metrics\n\ngruf-prometheus can also measure gruf client timings, via the interceptor:\n\n```ruby\nGruf::Client.new(\n  service: MyService,\n  client_options: {\n    interceptors: [Gruf::Prometheus::Client::Interceptor.new]\n  }\n)\n```\n\n|Name|Type|Description|\n|---|---|---|\n|ruby_grpc_client_started_total|counter|Total number of RPCs started by the client|\n|ruby_grpc_client_failed_total|counter|Total number of RPCs that throw an unknown, internal, data loss, failed precondition, unavailable, deadline exceeded, or cancelled exception by the client|\n|ruby_grpc_client_completed|counter|Total number of RPCs completed by the client, regardless of success or failure|\n|ruby_grpc_client_completed_latency_seconds|histogram|Histogram of response latency of RPCs completed by the client, in seconds|\n\nNote that the histogram is disabled by default - you'll have to turn it on either through the `client_measure_latency`\nconfiguration yielded in `Gruf::Prometheus.configure`, or through the `PROMETHEUS_CLIENT_MEASURE_LATENCY` environment\nvariable. Optionally, you can pass in `measure_latency: true` into the Interceptor directly as an option argument in the\ninitializer.\n\nThe precedence order for this is, from first to last, with last taking precedence:\n1) `measure_latency: true` passed into the interceptor\n2) `Gruf::Prometheus.configure` explicit setting globally\n3) `PROMETHEUS_CLIENT_MEASURE_LATENCY` ENV var globally. This is the only value set by default - to `false` - and will\n   be the default unless other methods are invoked.\n\n### Running the Client Interceptor in Non-gRPC Processes\n\nOne caveat is that you _must_ have the appropriate Type Collector setup in whatever process you are running in. If\nyou are already doing this in a gruf gRPC service that is using the hook provided by this gem above, no further\nconfiguration is needed. Otherwise, in whatever bc-prometheus-ruby configuration you have setup, you'll need to ensure\nthe type collector is loaded:\n\n```ruby\n# prometheus_server is whatever `::Bigcommerce::Prometheus::Server` instance you are using in the current process\n# Often hooks into these are exposed as configuration options, e.g. `web_collectors`, `resque_collectors`, etc\nprometheus_server.add_type_collector(::Gruf::Prometheus::Client::TypeCollector.new)\n```\n\nNote that you don't need to do this for the `Gruf::Prometheus::Client::Collector`, as it is an on-demand collector\nthat does not run in a threaded loop.\n\nSee [bc-prometheus-ruby](https://github.com/bigcommerce/bc-prometheus-ruby#custom-server-integrations)'s documentation\non custom server integrations for more information.\n\n## Configuration\n\nYou can further configure `Gruf::Prometheus` globally using the block syntax:\n\n```ruby\nGruf::Prometheus.configure do |config|\n  # config here\nend\n```\n\nwhere the options available are:\n\n| Option | Description | Default | ENV Name |\n| ------ | ----------- | ------- | -------- |\n| process_label | The label to use for metric prefixing | grpc | PROMETHEUS_PROCESS_LABEL |\n| process_name | Label to use for process name in logging | grpc | PROMETHEUS_PROCESS_NAME |\n| collection_frequency | The period in seconds in which to collect metrics | 30 | PROMETHEUS_COLLECTION_FREQUENCY |\n| collectors | Any collectors you would like to start with the server. Passed as a hash of collector class =\u003e options | {} | |\n| type_collectors | Any type collectors you would like to start with the server. Passed as an array of collector objects | [] | |\n| server_measure_latency| Whether or not to measure latency as a histogram for servers | 0 | PROMETHEUS_SERVER_MEASURE_LATENCY |\n| client_measure_latency| Whether or not to measure latency as a histogram for clients | 0 | PROMETHEUS_CLIENT_MEASURE_LATENCY |\n\n## License\n\nCopyright (c) 2019-present, BigCommerce Pty. Ltd. All rights reserved\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated\ndocumentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the\nrights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit\npersons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the\nSoftware.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE\nWARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\nOTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigcommerce%2Fgruf-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigcommerce%2Fgruf-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigcommerce%2Fgruf-prometheus/lists"}