{"id":21496508,"url":"https://github.com/mlibrary/yabeda-hanami","last_synced_at":"2025-03-17T12:16:03.402Z","repository":{"id":230961296,"uuid":"780559877","full_name":"mlibrary/yabeda-hanami","owner":"mlibrary","description":"Yabeda plugin to collect basic metrics for Hanami applications","archived":false,"fork":false,"pushed_at":"2024-04-10T19:33:51.000Z","size":55,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-25T01:48:45.165Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mlibrary.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-04-01T18:20:37.000Z","updated_at":"2024-04-24T09:37:09.000Z","dependencies_parsed_at":"2024-04-10T20:32:20.973Z","dependency_job_id":"22ca0e1d-3d00-4307-bda2-9dc1b7ce3843","html_url":"https://github.com/mlibrary/yabeda-hanami","commit_stats":null,"previous_names":["mlibrary/yabeda-hanami"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlibrary%2Fyabeda-hanami","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlibrary%2Fyabeda-hanami/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlibrary%2Fyabeda-hanami/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlibrary%2Fyabeda-hanami/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlibrary","download_url":"https://codeload.github.com/mlibrary/yabeda-hanami/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244031154,"owners_count":20386534,"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-23T16:16:51.271Z","updated_at":"2025-03-17T12:16:03.382Z","avatar_url":"https://github.com/mlibrary.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yabeda::Hanami\n\nBuilt-in metrics for out of the box [Hanami](https://hanamirb.org/) applications monitoring.\n\n[![Gem Version](https://badge.fury.io/rb/yabeda-hanami.svg)](https://badge.fury.io/rb/yabeda-hanami)\n\n## Metrics\n\n### Rack\n| type      | name                        | subscription[^1]      | comment                        |\n|-----------|-----------------------------|-----------------------|--------------------------------|\n| counter   | :hanami_requests_total      | :\"rack.request.start\" | Total web requests received    |\n| counter   | :hanami_responses_total     | :\"rack.request.stop\"  | Total web responses given      |\n| histogram | :hanami_processing_duration | :\"rack.request.stop\"  | Processing duration in seconds |\n| counter   | :hanami_errors_total        | :\"rack.request.error\" | Total rack errors[^2]          |\n[^1]: `id` of [Dry::Monitor::Notifications](https://www.rubydoc.info/gems/dry-monitor/Dry/Monitor/Notifications) declared in [Dry::Monitor::Rack::Middleware](https://www.rubydoc.info/gems/dry-monitor/Dry/Monitor/Rack/Middleware)\n[^2]: I don't think this event is ever used! [dry-monitor (1.0.1)](https://www.rubydoc.info/gems/dry-monitor)\n\n## Installation\n\n### Gemfile\nAdd these lines to your application's Gemfile:\n\n```ruby\ngem \"yabeda-hanami\", \"~\u003e 0.1\"\n# Then add monitoring system adapter, e.g.:\ngem 'yabeda-prometheus'\n```\n\nAlternatively, install from git:\n```ruby\ngem \"yabeda-hanami\", \"~\u003e 0.1\", git: \"https://github.com/mlibrary/yabeda-hanami.git\", tag: \"v0.1.1\"\n# Then add monitoring system adapter, e.g.:\ngem 'yabeda-prometheus'\n```\n\n### config.ru\nAdd these lines to your application's config.ru:\n\n```ruby\nrequire \"yabeda/prometheus\"\n\n# Use the monitoring system adapter, e.g.:\nuse Yabeda::Prometheus::Exporter #, path: \"/metrics\"\n```\n\n### config/providers/instrument.rb\nCreate an instrument provider for the application\n\n```ruby\n# frozen_string_literal: true\n\nrequire \"yabeda/hanami\"\n\nHanami.app.register_provider :instrument, namespace: true do\n  prepare do\n    Yabeda::Hanami.install!\n\n    config = Yabeda::Hanami.config\n\n    config.notifications = target[\"notifications\"]\n\n    Yabeda.configure!\n  end\n\n  start do\n    _config = Yabeda::Hanami.config\n\n    Yabeda::Hanami.subscribe!\n  end\nend\n```\n\n## Verification\n\nIn the above example the route `http://127.0.0.1:2300/metrics` returns the application's metrics.\n\n```shell\n# TYPE hanami_requests_total counter\n# HELP hanami_requests_total A counter of the total number of HTTP requests hanami processed.\nhanami_requests_total{method=\"GET\",path=\"/\",status=\"\",remote_ip=\"172.24.0.1\"} 2.0\n# TYPE hanami_responses_total counter\n# HELP hanami_responses_total A counter of the total number of HTTP requests hanami processed.\nhanami_responses_total{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\"} 2.0\n# TYPE hanami_processing_duration_seconds histogram\n# HELP hanami_processing_duration_seconds A histogram of the processing duration.\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"0.005\"} 0.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"0.01\"} 0.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"0.025\"} 0.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"0.05\"} 0.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"0.1\"} 1.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"0.25\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"0.5\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"1\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"2.5\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"5\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"10\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"30\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"60\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"120\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"300\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"600\"} 2.0\nhanami_processing_duration_seconds_bucket{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\",le=\"+Inf\"} 2.0\nhanami_processing_duration_seconds_sum{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\"} 0.246\nhanami_processing_duration_seconds_count{method=\"GET\",path=\"/\",status=\"200\",remote_ip=\"172.24.0.1\"} 2.0\n# TYPE hanami_rack_errors_total counter\n# HELP hanami_rack_errors_total A counter of the total number of rack errors.\n```\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\n\n\nTo install this gem onto your local machine, run `bundle exec rake install`. \n\n## Docker Compose Development Environment (dcde)\n\nAfter checking out the repo, run `docker-compose build` to build the **dcde** image. Once the image is built, run `docker-compose up -d` which will create the **dcde** container. Now run `docker-compose exec -- dcde bash` to get a bash shell inside the container.\n\nFrom here on it is the same as above a.k.a. run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. etc...\n\n**NOTE:** If you are using `docker-compose` on a non-linux machine you will need to run `bundle lock --add-platform x86_64-linux` otherwise the action workflows will fail when pushing your branch to GitHub.  \n\n## Releasing\n\nTo 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n1. Bump version number in `lib/yabeda/hanami/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::Hanami::VERSION).to_s`\n\n\n2. Fill `CHANGELOG.md` with missing changes, add header with version and date.\n\n\n3. Make a commit:\n```shell\ngit add lib/yabeda/hanami/version.rb CHANGELOG.md\nversion=$(ruby -r ./lib/yabeda/hanami/version.rb -e \"puts Gem::Version.new(Yabeda::Hanami::VERSION)\")\ngit commit --message=\"${version}: \" --edit\n```\n\n4. Create annotated tag:\n```shell\ngit tag v${version} --annotate --message=\"${version}: \" --edit --sign\n```\n\n\n5. Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)\n\n\n6. Push it:\n```shell\ngit push --follow-tags\n```\n\n7. You're done!\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/mlibrary/yabeda-hanami. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mlibrary/yabeda-hanami/blob/main/CODE_OF_CONDUCT.md).\n\n## Code of Conduct\n\nEveryone interacting in the Yabeda::Hanami project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mlibrary/yabeda-hanami/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [Apache 2.0 License](https://opensource.org/license/apache-2-0).\n\n## Copyright Notice\nCopyright 2024, Regents of the University of Michigan.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlibrary%2Fyabeda-hanami","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlibrary%2Fyabeda-hanami","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlibrary%2Fyabeda-hanami/lists"}