{"id":13879615,"url":"https://github.com/yabeda-rb/yabeda","last_synced_at":"2025-05-14T16:12:29.918Z","repository":{"id":39636726,"uuid":"151409356","full_name":"yabeda-rb/yabeda","owner":"yabeda-rb","description":"Extendable framework for collecting and exporting metrics from your Ruby application","archived":false,"fork":false,"pushed_at":"2024-10-11T12:01:10.000Z","size":194,"stargazers_count":804,"open_issues_count":6,"forks_count":25,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T00:05:44.517Z","etag":null,"topics":["metrics","monitoring","ruby","yabeda"],"latest_commit_sha":null,"homepage":null,"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/yabeda-rb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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-10-03T12:30:53.000Z","updated_at":"2025-04-09T14:30:15.000Z","dependencies_parsed_at":"2024-06-18T15:14:09.586Z","dependency_job_id":"1496ddc4-d448-4d1a-9105-e7f5fac6b50c","html_url":"https://github.com/yabeda-rb/yabeda","commit_stats":{"total_commits":57,"total_committers":10,"mean_commits":5.7,"dds":"0.21052631578947367","last_synced_commit":"3089b8fb0cb974aae4d2abd0f8a09c4e23fec168"},"previous_names":["evil-metrics/evil-metrics"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yabeda-rb%2Fyabeda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yabeda-rb%2Fyabeda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yabeda-rb%2Fyabeda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yabeda-rb%2Fyabeda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yabeda-rb","download_url":"https://codeload.github.com/yabeda-rb/yabeda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131319,"owners_count":21052819,"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","ruby","yabeda"],"created_at":"2024-08-06T08:02:26.842Z","updated_at":"2025-04-10T00:06:04.602Z","avatar_url":"https://github.com/yabeda-rb.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# ![Yabeda](./yabeda-logo.png)\n\n[![Gem Version](https://badge.fury.io/rb/yabeda.svg)](https://rubygems.org/gems/yabeda)\n[![Tests status](https://github.com/yabeda-rb/yabeda/actions/workflows/test.yml/badge.svg)](https://github.com/yabeda-rb/yabeda/actions/workflows/test.yml)\n\nExtendable solution for easy setup of monitoring in your Ruby apps.\n\n\u003ca href=\"https://evilmartians.com/?utm_source=yabeda\u0026utm_campaign=project_page\"\u003e\n\u003cimg src=\"https://evilmartians.com/badges/sponsored-by-evil-martians.svg\" alt=\"Sponsored by Evil Martians\" width=\"236\" height=\"54\"\u003e\n\u003c/a\u003e\n\n\u003e Read more about Yabeda and the reasoning behind it in Martian Chronicles: [“Meet Yabeda: Modular framework for instrumenting Ruby applications”](https://evilmartians.com/chronicles/meet-yabeda-modular-framework-for-instrumenting-ruby-applications)\n\n## Installation\n\nMost of the time you don't need to add this gem to your Gemfile directly (unless you're only collecting your custom metrics):\n\n```ruby\ngem 'yabeda'\n\n# Add some plugins to quickly start collecting some essential metrics:\n# gem 'yabeda-rails'\n# gem 'yabeda-sidekiq'\n\n# Then add monitoring system adapter, e.g.:\n# gem 'yabeda-prometheus'\n```\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\n 1. Declare your metrics:\n\n    ```ruby\n    Yabeda.configure do\n      group :your_app do\n        counter   :bells_rang_count, comment: \"Total number of bells being rang\", tags: %i[bell_size]\n        gauge     :whistles_active,  comment: \"Number of whistles ready to whistle\"\n        histogram :whistle_runtime do\n          comment \"How long whistles are being active\"\n          unit :seconds\n        end\n        summary :bells_ringing_duration, unit: :seconds, comment: \"How long bells are ringing\"\n      end\n    end\n    ```\n\n 2. After your application was initialized and all metrics was declared, you need to apply Yabeda configuration:\n\n    ```ruby\n    Yabeda.configure!\n    ```\n\n    _If you're using Ruby on Rails then it will be configured automatically!_\n\n 3. Access metric in your app and use it!\n\n    ```ruby\n    def ring_the_bell(id)\n      bell = Bell.find(id)\n      bell.ring!\n      Yabeda.your_app.bells_rang_count.increment({bell_size: bell.size}, by: 1)\n    end\n\n    def whistle!\n      Yabeda.your_app.whistle_runtime.measure do\n        # Run your code\n      end\n    end\n    ```\n\n 4. Setup collecting of metrics that do not tied to specific events in you application. E.g.: reporting your app's current state\n    ```ruby\n    Yabeda.configure do\n      # This block will be executed periodically few times in a minute\n      # (by timer or external request depending on adapter you're using)\n      # Keep it fast and simple!\n      collect do\n        your_app.whistles_active.set({}, Whistle.where(state: :active).count)\n      end\n    end\n    ```\n\n  5. _Optionally_ setup default tags for all appropriate metrics\n     ```ruby\n     Yabeda.configure do\n       # matches all metrics in all groups\n       default_tag :rails_environment, 'production'\n\n       # matches all metrics in the :your_app group\n       default_tag :tag_name, 'override', group: :your_app\n     end\n\n     # You can redefine them for limited amount of time\n     Yabeda.with_tags(rails_environment: 'staging') do\n       Yabeda.your_app.bells_rang_count.increment({bell_size: bell.size}, by: 1)\n     end\n     ```\n\n     **Note**: any usage of `with_tags` **must** have all those tags defined on all metrics that are generated in the block.\n\n  6. _Optionally_ override default tags using precedence:\n\n     The tag precedence from high to low is:\n\n     * Manually specified tags\n     * Thread local tags (specified by `Yabeda.with_tags`)\n     * Group specific tags\n     * Global tags\n\n  7. See the docs for the adapter you're using\n  8. Enjoy!\n\n## Available monitoring system adapters\n\n### Maintained by Yabeda\n\n - Prometheus:\n   - [yabeda-prometheus](https://github.com/yabeda-rb/yabeda-prometheus) — wraps [official Ruby client for Prometheus](https://github.com/prometheus/client_ruby).\n   - [yabeda-prometheus-mmap](https://github.com/yabeda-rb/yabeda-prometheus-mmap) — wraps [GitLab's fork of Prometheus Ruby client](https://gitlab.com/gitlab-org/prometheus-client-mmap) which may work better for multi-process application servers.\n - [Datadog](https://github.com/yabeda-rb/yabeda-datadog)\n - [NewRelic](https://github.com/yabeda-rb/yabeda-newrelic)\n\n### Third-party adapters\n\nThese are developed and maintained by other awesome folks:\n\n - [Statsd](https://github.com/asusikov/yabeda-statsd)\n - [AWS CloudWatch](https://github.com/retsef/yabeda-cloudwatch)\n - [Honeybadger Insights](https://github.com/honeybadger-io/yabeda-honeybadger_insights)\n - _…and more! You can write your own adapter and open a pull request to add it into this list._\n\n## Available plugins to collect metrics\n\n### Maintained by Yabeda\n\n - [yabeda-rails] — basic request metrics for [Ruby on Rails](https://rubyonrails.org/) applications.\n - [yabeda-activerecord] — query performance and connection pool stats for apps using ActiveRecord to query databases.\n - [yabeda-sidekiq] — comprehensive set of metrics for monitoring [Sidekiq](https://sidekiq.org/) jobs execution and queues.\n - [yabeda-faktory] — metrics for monitoring jobs execution by Ruby workers of [Faktory](https://contribsys.com/faktory/).\n - [yabeda-graphql] — metrics to query and field-level monitoring for apps using [GraphQL-Ruby](https://graphql-ruby.org/).\n - [yabeda-puma-plugin] — metrics for internal state and performance of [Puma](https://puma.io/) application server.\n - [yabeda-http_requests] — monitor how many outgoing HTTP calls your application does (uses [Sniffer](https://github.com/aderyabin/sniffer)).\n - [yabeda-schked] — monitor number and duration of Cron jobs executed by [Schked](https://github.com/bibendi/schked).\n - [yabeda-anycable] — monitor number, duration, and status of [AnyCable](https://anycable.io/) RPC calls.\n\n### Third-party plugins\n\nThese are developed and maintained by other awesome folks:\n\n - [yabeda-grape](https://github.com/efigence/yabeda-grape) — metrics for [Grape](https://github.com/ruby-grape/grape) framework.\n - [yabeda-gruf](https://github.com/Placewise/yabeda-gruf) — metrics for [gRPC Ruby Framework](https://github.com/bigcommerce/gruf)\n - [yabeda-gc](https://github.com/ianks/yabeda-gc) — metrics for Ruby garbage collection.\n - [yabeda-activejob](https://github.com/Fullscript/yabeda-activejob) — backend-agnostic metrics for background jobs.\n - [yabeda-shoryuken](https://github.com/retsef/yabeda-shoryuken) — metrics for [Shoryuken](https://github.com/ruby-shoryuken/shoryuken) jobs execution message queues.\n - [yabeda-rack-ratelimit](https://github.com/basecamp/yabeda-rack-ratelimit) — metrics for [Rack::Ratelimit](https://github.com/jeremy/rack-ratelimit)\n - [yabeda-hanami](https://github.com/mlibrary/yabeda-hanami) — metrics for [Hanami](https://hanamirb.org/) The web, with simplicity.\n - _…and more! You can write your own adapter and open a pull request to add it into this list._\n\n## Configuration\n\nConfiguration is handled by [anyway_config] gem. With it you can load settings from environment variables (which names are constructed from config key upcased and prefixed with `YABEDA_`), YAML files, and other sources. See [anyway_config] docs for details.\n\nConfig key | Type     | Default | Description |\n---------- | -------- | ------- | ----------- |\n`debug`    | boolean  | `false` | Collects metrics measuring Yabeda performance |\n\n## Debugging metrics\n\n - Time of collector block run: `yabeda_collect_duration` (segmented by block source location). Collector blocks are used for collecting metrics of application state and usually makes some potentially slow queries to databases, network requests, etc.\n\nThese are only enabled in debug mode. To enable it either set `debug` config key to `true` (e.g. by specifying `YABEDA_DEBUG=true` in your environment variables or executing `Yabeda.debug!` in your code).\n\n## Testing\n\n### RSpec\n\nAdd the following to your `rails_helper.rb` (or `spec_helper.rb`):\n\n```ruby\nrequire \"yabeda/rspec\"\n```\n\nNow you can use `increment_yabeda_counter`, `update_yabeda_gauge`, `measure_yabeda_histogram`, and `observe_yabeda_summary` matchers:\n\n```ruby\nit \"increments counters\" do\n  expect { subject }.to increment_yabeda_counter(Yabeda.myapp.foo_count).by(3)\nend\n```\n\nYou can scope metrics by used tags with `with_tags`:\n\n```ruby\nit \"updates gauges\" do\n  expect { subject }.to \\\n    update_yabeda_gauge(\"some_gauge_name\").\n    with_tags(method: \"command\", command: \"subscribe\")\nend\n```\n\nNote that tags you specified doesn't need to be exact, but can be a subset of tags used on metric update. In this example updates with following sets of tags `{ method: \"command\", command: \"subscribe\", status: \"SUCCESS\" }` and `{ method: \"command\", command: \"subscribe\", status: \"FAILURE\" }` will make test example to pass.\n\nAnd check for values with `by` for counters, `to` for gauges, and `with` for histograms and summaries (and you [can use other matchers here](https://relishapp.com/rspec/rspec-expectations/v/3-10/docs/composing-matchers)):\n\n```ruby\nexpect { subject }.to \\\n  measure_yabeda_histogram(Yabeda.something.anything_runtime).\n  with(be_between(0.005, 0.05))\n```\n\nYou also can specify multiple tags and their expected values in `with`:\n\n```ruby\nexpect { whatever }.to increment_yabeda_counter(:my_counter).with(\n  { tag: \"foo\" } =\u003e 1,\n  { tag: \"bar\" } =\u003e (be \u003e= 42),\n)\n```\n\n## Advanced usage\n\n### Limiting metrics and groups to specific adapters\n\nYou can limit, which metrics and groups should be available for specific adapter:\n\n```ruby\nYabeda.configure do\n  group :internal do\n    adapter :prometheus\n\n    counter :foo\n    gauge :bar\n  end\n\n  group :cloud do\n    adapter :newrelic\n\n    counter :baz\n  end\n\n  counter :qux, adapter: :prometheus\nend\n```\n\n\n## Roadmap (aka TODO or Help wanted)\n\n - Ability to change metric settings for individual adapters\n\n   ```rb\n   histogram :foo, comment: \"say what?\" do\n     adapter :prometheus do\n       buckets [0.01, 0.5, …, 60, 300, 3600]\n     end\n   end\n   ```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` 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 commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n### Releasing\n\n 1. Bump version number in `lib/yabeda/version.rb`\n\n    In case of pre-releases keep in mind [rubygems/rubygems#3086](https://github.com/rubygems/rubygems/issues/3086) and check version with command like `Gem::Version.new(Yabeda::VERSION).to_s`\n\n 2. Fill `CHANGELOG.md` with missing changes, add header with version and date.\n\n 3. Make a commit:\n\n    ```sh\n    git add lib/yabeda/version.rb CHANGELOG.md\n    version=$(ruby -r ./lib/yabeda/version.rb -e \"puts Gem::Version.new(Yabeda::VERSION)\")\n    git commit --message=\"${version}: \" --edit\n    ```\n\n 3. Create annotated tag:\n\n    ```sh\n    git tag v${version} --annotate --message=\"${version}: \" --edit --sign\n    ```\n\n 4. Fill version name into subject line and (optionally) some description (changes will be taken from changelog and appended automatically)\n\n 5. Push it:\n\n    ```sh\n    git push --follow-tags\n    ```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/yabeda-rb/yabeda.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n[yabeda-rails]: https://github.com/yabeda-rb/yabeda-rails/ \"Yabeda plugin for collecting and exporting basic metrics for Rails applications\"\n[yabeda-activerecord]: https://github.com/yabeda-rb/yabeda-activerecord/ \"Yabeda plugin to collect query performance metrics and connection pool statistics\"\n[yabeda-sidekiq]: https://github.com/yabeda-rb/yabeda-sidekiq/ \"Yabeda plugin for complete monitoring of Sidekiq metrics\"\n[yabeda-faktory]: https://github.com/yabeda-rb/yabeda-faktory/ \"Yabeda plugin for complete monitoring of Faktory Ruby Workers\"\n[yabeda-graphql]: https://github.com/yabeda-rb/yabeda-graphql/ \"Measure and understand how good your GraphQL-Ruby application works\"\n[yabeda-puma-plugin]: https://github.com/yabeda-rb/yabeda-puma-plugin/ \"Collects Puma web-server metrics from puma control application\"\n[yabeda-http_requests]: https://github.com/yabeda-rb/yabeda-http_requests/ \"Builtin metrics to monitor external HTTP requests\"\n[yabeda-schked]: https://github.com/yabeda-rb/yabeda-schked/ \"Built-in metrics for monitoring Schked recurring jobs out of the box\"\n[yabeda-anycable]: https://github.com/yabeda-rb/yabeda-anycable \"Collect performance metrics for AnyCable RPC server\"\n[anyway_config]: https://github.com/palkan/anyway_config \"Configuration library for Ruby gems and applications\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyabeda-rb%2Fyabeda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyabeda-rb%2Fyabeda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyabeda-rb%2Fyabeda/lists"}