{"id":18792997,"url":"https://github.com/autometrics-dev/autometrics-rb","last_synced_at":"2025-04-13T14:31:48.249Z","repository":{"id":145285163,"uuid":"604133663","full_name":"autometrics-dev/autometrics-rb","owner":"autometrics-dev","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-01T16:04:13.000Z","size":25,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-31T14:19:54.544Z","etag":null,"topics":[],"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/autometrics-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-02-20T12:05:19.000Z","updated_at":"2024-08-11T20:33:52.000Z","dependencies_parsed_at":"2023-07-15T14:11:35.231Z","dependency_job_id":"d5e23cf3-0b05-4df3-8b64-ccf4e4c4d7e1","html_url":"https://github.com/autometrics-dev/autometrics-rb","commit_stats":null,"previous_names":["autometrics-dev/autometrics-ruby"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autometrics-dev%2Fautometrics-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autometrics-dev%2Fautometrics-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autometrics-dev%2Fautometrics-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autometrics-dev%2Fautometrics-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/autometrics-dev","download_url":"https://codeload.github.com/autometrics-dev/autometrics-rb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223590195,"owners_count":17170095,"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-07T21:23:04.624Z","updated_at":"2024-11-07T21:23:05.151Z","avatar_url":"https://github.com/autometrics-dev.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# autometrics-ruby\n\n\u003e :warning: **Autometrics for Ruby needs community input.** We are seeking feedback from the community on the API and implementation. Please open an issue if you have any questions or feedback!\n\nA Ruby gem that makes it easy to understand the error rate, response time, and production usage of any function in your code.\n\nOnce we complete all our `TODOs`, you should only have to add a one or two lines of code, and then be able to jump straight from your IDE to live Prometheus charts for each of your HTTP/RPC handlers, database methods, or any other piece of application logic.\n\n## Features\n\n- ✨ `include Autometrics` exposes utilities that can instrument class methods, in order to track useful metrics for your application\n- ⚡ Minimal runtime overhead\n\n**Coming Soon**\n\n- 💡 Writes Prometheus queries so you can understand the data generated without knowing PromQL\n- 🔗 Create links to live Prometheus charts directly into each function's docstrings, via SolarGraph\n\n- 📊 Grafana dashboard showing the performance of all instrumented functions\n\n## Usage\n\nAutometrics makes use of `\"prometheus-client\"` under the hood, which is the aptly named Ruby client for Prometheus.\n\nFor now, you simply need to add the autometrics gem to your project (`gem install autometrics`), `include Autometrics` in any class you wish to observe, and then set up a `/metrics` endpoint in your app that exposes the metrics to Prometheus, if one does not already exist. There is an example Sinatra app in this repo to show how you might do this.\n\n### Usage inside a class\n\n```ruby\n# Include the `Autometrics` module, then call `autometrics` to enable autometrics on specific methods\n\nclass ClassWithSomeAutometrics\n  include Autometrics\n\n  # Option 1: Specify an allow-list of the methods to observe\n  autometrics only: :foo\n\n  # Option 2: Provide an exclusion-list of the methods we should not observe\n  autometrics skip: :bar\n\n  def foo\n    p \"I'm getting observed!\"\n  end\n\n  def bar\n    p \"I am not getting observed. :(\"\n  end\nend\n\n# Include `Autometrics::On` to enable autometrics on all methods (`initialize` is excluded by default)\nclass ClassWithAllAutometrics\n  include Autometrics::On\n\n  def foo\n    p \"This will be observed in prometheus!\"\n  end\n\n  def bar\n    p \"Sooøøøoo will this!\"\n  end\nend\n```\n\n### Usage with plain-old Ruby methods\n\n```ruby\nrequire \"autometrics\"\n\nautometrics def top_level_foo\n  p \"I'm getting observed!\"\nend\n```\n\n## TODOs\n\n- [ ] Provide an example of how to use Autometrics with a Rails app\n- [ ] Look for other methods to exclude by default, like `initialize`. (E.g., should we exclude private methods?)\n- [ ] Add tests\n- [ ] Investigate ability to swap out the prometheus client, e.g., using the [`prometheus_exporter` gem](https://github.com/discourse/prometheus_exporter)\n\n## Developing Locally\n\nTo build the Gem:\n\n```sh\ngem build autometrics.gemspec\n```\n\nFor a simple smoke test, run `bundle` and `bundle exec ruby autometrics_test_quick.rb`.\n\nTo use debug logs:\n\n```sh\nLOG_LEVEL=debug bundle exec ruby autometrics_test_quick.rb\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautometrics-dev%2Fautometrics-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautometrics-dev%2Fautometrics-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautometrics-dev%2Fautometrics-rb/lists"}