{"id":13747552,"url":"https://github.com/jnunemaker/nunes","last_synced_at":"2025-05-15T15:09:28.526Z","repository":{"id":54677729,"uuid":"9507737","full_name":"jnunemaker/nunes","owner":"jnunemaker","description":":chart_with_upwards_trend: The friendly gem that instruments everything for you, like I would if I could.","archived":false,"fork":false,"pushed_at":"2024-01-28T22:33:41.000Z","size":331,"stargazers_count":496,"open_issues_count":5,"forks_count":22,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-03-31T19:11:20.992Z","etag":null,"topics":[],"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/jnunemaker.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":"2013-04-17T21:14:21.000Z","updated_at":"2025-01-25T02:30:07.000Z","dependencies_parsed_at":"2024-06-18T21:27:11.273Z","dependency_job_id":"71a10ba1-e779-43b1-aa13-e536126d4b91","html_url":"https://github.com/jnunemaker/nunes","commit_stats":{"total_commits":150,"total_committers":8,"mean_commits":18.75,"dds":0.09333333333333338,"last_synced_commit":"efa2481defd1ef9ad59e6bbbc781df34b95c47f0"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnunemaker%2Fnunes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnunemaker%2Fnunes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnunemaker%2Fnunes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jnunemaker%2Fnunes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jnunemaker","download_url":"https://codeload.github.com/jnunemaker/nunes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247721898,"owners_count":20985084,"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-08-03T06:01:33.299Z","updated_at":"2025-04-07T20:11:46.690Z","avatar_url":"https://github.com/jnunemaker.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# nunes\n\nThe friendly gem that instruments everything for you, like I would if I could.\n\n## Why \"nunes\"?\n\nBecause I don't work for you, but even that could not stop me from trying to make it as easy as possible for you to instrument ALL THE THINGS.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem \"nunes\"\n\nOr install it yourself as:\n\n    $ gem install nunes\n\n## Compatibility\n\n* \u003e= Ruby 2.0\n* Rails 4.2.x, 5.0.x\n\nNote: you can use v0.3.1 is for rails 3.2.x support.\n\n## Usage\n\nnunes works out of the box with [instrumental app](http://instrumentalapp.com) (my personal favorite) and [statsd](https://github.com/reinh/statsd). All you need to do is subscribe using an instance of statsd or instrumental's agent and you are good to go.\n\n### With Instrumental\n\n```ruby\nrequire \"nunes\"\nI = Instrument::Agent.new(...)\nNunes.subscribe(I)\n```\n\n### With Statsd\n\n```ruby\nrequire \"nunes\"\nstatsd = Statsd.new(...)\nNunes.subscribe(statsd)\n```\n\n### With Some Other Service\n\nIf you would like for nunes to work with some other service, you can easily make an adapter. Check out the [existing adapters](https://github.com/jnunemaker/nunes/tree/master/lib/nunes/adapters) for examples. The key is to inherit from `Nunes::Adapter` and then convert the `increment` and `timing` methods to whatever the service requires.\n\n## What Can I Do For You?\n\nIf you are using nunes with Rails, I will subscribe to the following events:\n\n* `process_action.action_controller`\n* `render_template.action_view`\n* `render_partial.action_view`\n* `deliver.action_mailer`\n* `receive.action_mailer`\n* `sql.active_record`\n* `cache_read.active_support`\n* `cache_generate.active_support`\n* `cache_fetch_hit.active_support`\n* `cache_write.active_support`\n* `cache_delete.active_support`\n* `cache_exist?.active_support`\n\nWhoa! You would do all that for me? Yep, I would. Because I care. Deeply.\n\nBased on those events, you'll get metrics like this in instrumental and statsd:\n\n#### Counters\n\n* `action_controller.status.200`\n* `action_controller.format.html`\n* `action_controller.controller.Admin.PostsController.new.status.403`\n* `action_controller.controller.Admin.PostsController.index.format.json`\n* `active_support.cache.hit`\n* `active_support.cache.miss`\n\n#### Timers\n\n* `action_controller.runtime.total`\n* `action_controller.runtime.view`\n* `action_controller.runtime.db`\n* `action_controller.controller.PostsController.index.runtime.total`\n* `action_controller.controller.PostsController.index.runtime.view`\n* `action_controller.controller.PostsController.index.runtime.db`\n* `action_controller.controller.PostsController.index.status.200`\n* `action_controller.controller.PostsController.index.format.html`\n* `action_view.template.app.views.posts.index.html.erb` - where `app.views.posts.index.html.erb` is the path of the view file\n* `action_view.partial.app.views.posts._post.html.erb` - I can even do partials! woot woot!\n* `action_mailer.deliver.PostMailer`\n* `action_mailer.receive.PostMailer`\n* `active_record.sql`\n* `active_record.sql.select`\n* `active_record.sql.insert`\n* `active_record.sql.update`\n* `active_record.sql.delete`\n* `active_support.cache.read`\n* `active_support.cache.fetch`\n* `active_support.cache.fetch_hit`\n* `active_support.cache.fetch_generate`\n* `active_support.cache.write`\n* `active_support.cache.delete`\n* `active_support.cache.exist`\n\n### But wait, there's more!!!\n\nIn addition to doing all that automagical work for you, I also allow you to wrap your own code with instrumentation. I know, I know, sounds too good to be true.\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  extend Nunes::Instrumentable\n\n  # wrap save and instrument the timing of it\n  instrument_method_time :save\nend\n```\n\nThis will instrument the timing of the User instance method save. What that means is when you do this:\n\n```ruby\nuser = User.new(name: 'NUNES!')\nuser.save\n```\n\nAn event named `instrument_method_time.nunes` will be generated, which in turn is subscribed to and sent to whatever you used to send instrumentation to (statsd, instrumental, etc.). The metric name will default to class.method. For the example above, the metric name would be `User.save`. No fear, you can customize this.\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  extend Nunes::Instrumentable\n\n  # wrap save and instrument the timing of it\n  instrument_method_time :save, 'crazy_town.save'\nend\n```\n\nPassing a string as the second argument sets the name of the metric. You can also customize the name using a Hash as the second argument.\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  extend Nunes::Instrumentable\n\n  # wrap save and instrument the timing of it\n  instrument_method_time :save, name: 'crazy_town.save'\nend\n```\n\nIn addition to name, you can also pass a payload that will get sent along with the generated event.\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  extend Nunes::Instrumentable\n\n  # wrap save and instrument the timing of it\n  instrument_method_time :save, payload: {pay: \"loading\"}\nend\n```\n\nIf you subscribe to the event on your own, say to log some things, you'll get a key named `:pay` with a value of `\"loading\"` in the event's payload. Pretty neat, eh?\n\n## `script/bootstrap`\n\nThis script will get all the dependencies ready so you can start hacking on nunes.\n\n```\n# to learn more about script/bootstrap\nscript/bootstrap help\n```\n\n## `script/test`\n\nFor your convenience, there is a script to run the tests. It will also perform `script/bootstrap`, which bundles and all that jazz.\n\n```\n# to learn more about script test\nscript/test help\n```\n\n## `script/watch`\n\nIf you are like me, you are too lazy to continually run `script/test`. For this scenario, I have included `script/watch`, which will run `script/test` automatically anytime a relevant file changes.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnunemaker%2Fnunes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjnunemaker%2Fnunes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnunemaker%2Fnunes/lists"}