{"id":16701644,"url":"https://github.com/coryodaniel/yodeler","last_synced_at":"2025-05-16T14:31:31.100Z","repository":{"id":56899143,"uuid":"49455001","full_name":"coryodaniel/yodeler","owner":"coryodaniel","description":"A generic instrumentation library with a multiple pluggable backend adapters.","archived":false,"fork":false,"pushed_at":"2016-01-27T20:53:50.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T08:53:34.582Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coryodaniel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-11T21:17:31.000Z","updated_at":"2016-01-20T11:16:32.000Z","dependencies_parsed_at":"2022-08-21T01:50:24.798Z","dependency_job_id":null,"html_url":"https://github.com/coryodaniel/yodeler","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryodaniel%2Fyodeler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryodaniel%2Fyodeler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryodaniel%2Fyodeler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coryodaniel%2Fyodeler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coryodaniel","download_url":"https://codeload.github.com/coryodaniel/yodeler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254546803,"owners_count":22089211,"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-10-12T18:45:00.855Z","updated_at":"2025-05-16T14:31:30.799Z","avatar_url":"https://github.com/coryodaniel.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yodeler\n\nA generic instrumentation library thats supports reporting to multiple endpoints via pluggable backend adapters.\n\nSpoutin' off noise to whoever is listening.\n\n![Build Status](https://travis-ci.org/coryodaniel/yodeler.svg \"Build Status\")\n[![Test Coverage](https://codeclimate.com/github/coryodaniel/yodeler/badges/coverage.svg)](https://codeclimate.com/github/coryodaniel/yodeler/coverage)\n[![Code Climate](https://codeclimate.com/github/coryodaniel/yodeler/badges/gpa.svg)](https://codeclimate.com/github/coryodaniel/yodeler)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'yodeler', '~\u003e0.1.2'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install yodeler\n\n## Usage\n\n### Configuration\n\n#### Single endpoint\nIn ```config/initializers/yodeler.rb```\n```ruby\nYodeler.configure do |client|\n  # if no endpoint name is given, it defaults to :default\n  client.adapter(:http) do |http|\n    http.path = '/events'\n    http.host = 'example.com'\n    # http.port = 80\n    # http.use_ssl = false\n    # http.default_params = {}\n  end\n\n  # if no timestamp_format is set, defaults to UTC ISO8601\n  client.timestamp_format = :iso8601\n  #client.timestamp_format = :epoch\n  #client.timestamp_format = -\u003e { Time.now.whatever.you_feel_like! }\nend\n```\n\n#### Multiple Endpoints\nIn ```config/initializers/yodeler.rb```\n```ruby\n\nYodeler.configure do |client|\n  client.endpoint(:sales_reporting).adapter(:http) do |http|\n    http.path = '/events'\n    http.host = 'sales.example.com'\n  end\n\n  client.endpoint(:devops_reporting).adapter(:http) do |http|\n    http.path = '/events'\n    http.host = 'devops.example.com'\n  end\n\n  # by default, the client dispatches to the first registered endpoint\n  # you can change it to a different one\n  # Alternatively you can dispatch to a set of endpoints when dispatching a metric\n  #   Yodeler.gauge('users.count', 35, to: [:sales_reporting, :devops_reporting])\n  client.default_endpoint_name = :devops_reporting\nend\n```\n\n#### Full Configuration Example\nIn ```config/yodeler.yml```\n```yaml\ndevelopment:\n  auth_token: SOSECUREZ\n  sales_reporting:\n    host: localhost\n    port: 3030\n  devops_reporting:\n    host: localhost\n    port: 3031    \n```\n\nIn ```config/initializers/yodeler.rb```\n```ruby\nconfig = YAML.load(File.read(\"./config/yodeler.yml\"))[Rails.env]\n\nYodeler.configure do |client|\n  client.endpoint(:sales_reporting).adapter(:http) do |http|\n    http.path = '/events'\n    http.host = config[:sales_reporting][:host]\n    http.port = config[:sales_reporting][:port]\n    http.default_params = {\n      auth_token: config[:auth_token]\n    }\n  end\n\n  client.endpoint(:devops_reporting).adapter(:http) do |http|\n    http.path = '/events'\n    http.host = config[:devops_reporting][:host]\n    http.port = config[:devops_reporting][:port]\n    http.default_params = {\n      auth_token: config[:auth_token]\n    }\n\n    # Overwrite the default http dispatcher or overwrite an individual metric dispatcher\n    #   http.handle(:gauge){ |url, metric, default_params| ... something cool ... }\n    http.handle(:default) do |url, metric, default_params|\n      # This is the default handler definition, but you could change it\n      HTTP.post(url, json: default_params.merge(metric.to_hash))\n    end\n  end\n\n  client.default_endpoint_name = :devops_reporting\nend\n\n```\n\n#### [Dashing Example](https://github.com/shopify/dashing)\n```ruby\nYodeler.configure do |client|\n  client.endpoint(:karma_widget).adapter(:http) do |http|\n    http.path = '/widgets/karma'\n    http.host = 'localhost'\n    http.default_params = {\n      auth_token: config[:auth_token]\n    }\n  end\n\n  client.endpoint(:user_count_widget).adapter(:http) do |http|\n    http.path = '/widgets/user_count'\n    http.host = 'localhost'\n    http.default_params = {\n      auth_token: config[:auth_token]\n    }\n  end\nend\n```\n\n### Publishing Metrics and Events\n\n#### All instrumentation methods support an options hash\n\n* :prefix - [~String] :prefix your metric/event names\n* :tags   - [Array\u003cString,Symbol\u003e, String, Symbol] :tags ([]) array of tags to apply to metric/event\n* :sample_rate - [Float] :sample_rate (1.0) The sample rate to use\n* :to - [Array\u003cSymbol\u003e, Symbol] :to array of endpoint names to send the metric/event to. If not set will send to Yodeler::Client#default_endpoint_name\n* :meta - [Hash] :meta additional meta data to send with metric/event. Meta data like :tags, :hostname and :timestamp are merged into this hash\n\n#### Gauge\n```ruby\nYodeler.gauge 'user.count', 35\nYodeler.gauge 'user.count', 35, prefix: 'test'\nYodeler.gauge 'user.count', 35, sample_rate: 0.5\nYodeler.gauge 'user.count', 35, prefix: 'test', tags: ['cool']\nYodeler.gauge 'user.count', 35, to: [:devops_reporting, :sales_reporting]\n```\n\n#### Increment\n```ruby\nYodeler.increment 'users.count'\nYodeler.increment 'users.count', to: [:devops_reporting, :sales_reporting]\nYodeler.increment 'revenue', 10_000\nYodeler.increment 'revenue', 10_000, to: [:devops_reporting, :sales_reporting]\nYodeler.increment 'revenue', 10_000, to: [:devops_reporting, :sales_reporting], meta: {ip: request.remote_ip}\n```\n\n#### Timing\n```ruby\nYodeler.timing('eat.sandwich', {prefix: :test}) do\n  user.eat(sandwich)\nend #=\u003e returns result of block\n\nYodeler.timing 'eat.sandwich', 250 #in ms\nYodeler.timing 'eat.sandwich', 250, to: [:devops_reporting, :sales_reporting]\n```\n\n#### Event\n```ruby\nwizz_bang = {name: 'Wizz Bang 3000', image_url: 'http://example.com/wizzbang.jpg'}\nYodeler.publish 'product.sold', wizz_bang\nYodeler.publish 'product.sold', wizz_bang, prefix: 'ecommerce'\nYodeler.publish 'product.sold', wizz_bang, sample_rate: 0.25\nYodeler.publish 'product.sold', wizz_bang, to: [:devops_reporting, :sales_reporting]\nYodeler.publish 'product.sold', wizz_bang, to: [:devops_reporting, :sales_reporting], meta: {ip: request.remote_ip}\n\nYodeler.publish 'product.sold' do |msg|\n  msg[:name] = \"Wizz Bang 3000\"\n  msg[:image_url] = \"http://example.com/wizzbang.jpg\"\nend\n\nYodeler.publish 'product.sold', tags: [:wizzbang] do |msg|\n  msg[:name] = \"Wizz Bang 3000\"\n  msg[:image_url] = \"http://example.com/wizzbang.jpg\"\nend\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\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## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/coryodaniel/yodeler.\n\n## TODOs\n  * [ ] Yodeler#publish receive block\n  * [ ] Add a configuration proxy to use instead of initializing adapters and endpoints on #config\n  * [ ] Custom adapter documentation\n  * [ ] Client#format_options -\u003e Metric.format_options\n  * [ ] Client#default_endpoint_name accept array of names\n  * [ ] Dispatch to any object or proc, if adapter not registered\n    * client.endpoint(:dashboard).use(:something_that_responds_to_dispatch)\n    * client.endpoint(:dashboard).use{ |metric| MyWorker.perform_later(metric) }\n  * [ ] more yard docs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoryodaniel%2Fyodeler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoryodaniel%2Fyodeler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoryodaniel%2Fyodeler/lists"}