{"id":29460743,"url":"https://github.com/carwow/honeykiq","last_synced_at":"2025-07-14T02:32:49.540Z","repository":{"id":47465872,"uuid":"161204077","full_name":"carwow/honeykiq","owner":"carwow","description":"Sidekiq → Honeycomb 🐝","archived":false,"fork":false,"pushed_at":"2023-01-11T19:00:50.000Z","size":81,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-07-02T18:16:54.064Z","etag":null,"topics":["honeycomb","sidekiq","sidekiq-honeycomb"],"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/carwow.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}},"created_at":"2018-12-10T16:29:46.000Z","updated_at":"2024-10-11T14:56:05.000Z","dependencies_parsed_at":"2023-02-09T04:31:09.860Z","dependency_job_id":null,"html_url":"https://github.com/carwow/honeykiq","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/carwow/honeykiq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Fhoneykiq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Fhoneykiq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Fhoneykiq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Fhoneykiq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carwow","download_url":"https://codeload.github.com/carwow/honeykiq/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Fhoneykiq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265233753,"owners_count":23731825,"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":["honeycomb","sidekiq","sidekiq-honeycomb"],"created_at":"2025-07-14T02:31:15.532Z","updated_at":"2025-07-14T02:32:49.514Z","avatar_url":"https://github.com/carwow.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Honeykiq\n\nSidekiq → Honeycomb 🐝\n\nSend [Sidekiq](https://sidekiq.org)-related events to\n[Honeycomb](https://www.honeycomb.io).\n\n## Installation\n\nAdd this line to your application's `Gemfile`:\n\n```ruby\ngem 'honeykiq'\n```\n\n## Usage\n\nThe library provides three use cases:\n\n- [`Honeykiq::ClientMiddleware`]\n- [`Honeykiq::ServerMiddleware`]\n- [`Honeykiq::PeriodicReporter`]\n\n[`Honeykiq::ClientMiddleware`]: #HoneykiqClientMiddleware\n[`Honeykiq::ServerMiddleware`]: #HoneykiqServerMiddleware\n[`Honeykiq::PeriodicReporter`]: #HoneykiqPeriodicReporter\n\n### Honeykiq::ClientMiddleware\n\nAdd Honeykiq to your Sidekiq client middleware chain. It will propagate tracing\nfields when used in combination with `Honeykiq::ServerMiddleware`.\n\nThis middleware is **only** configured to work with the `Honeycomb` beeline gem,\nnot with a custom `Libhoney` client.\n\n```ruby\n# Configure Honeycomb beeline\nHoneycomb.configure do |config|\n  config.write_key = ENV.fetch('HONEYCOMB_WRITE_KEY')\n  config.dataset = ENV.fetch('HONEYCOMB_DATASET')\nend\n\n# Add the middleware to Sidekiq chain\nSidekiq.configure_client do |config|\n  config.client_middleware do |chain|\n    chain.add Honeykiq::ClientMiddleware\n  end\nend\n\n# Also add it to the server client chain\nSidekiq.configure_server do |config|\n  # Configure the server client, used when a worker enqueues a job itself.\n  config.client_middleware do |chain|\n    chain.add Honeykiq::ClientMiddleware\n  end\n\n  # Configure ServerMiddleware with a tracing mode\n  config.server_middleware do |chain|\n    # tracing_mode: options are nil (default), :child, :child_trace, :link\n    #\n    # - nil (default) starts a span and trace when the job executes.\n    #\n    # - :child starts a span as a child of the enqueuing trace,\n    #   requires ClientMiddleware to be configured when enqueuing the job.\n    #\n    # - :child_trace (experimental) starts a span and a trace\n    #   with trace.parent_id set to the enqueuing trace id,\n    #   requires ClientMiddleware to be configured when enqueuing the job.\n    #\n    # - :link (experimental) starts a span and trace\n    #   with a link event that points to the enqueuing trace,\n    #   requires ClientMiddleware to be configured when enqueuing the job.\n    #   https://docs.honeycomb.io/getting-data-in/tracing/send-trace-data/#links\n    chain.add Honeykiq::ServerMiddleware, tracing_mode: :child\n  end\nend\n```\n\n### Honeykiq::ServerMiddleware\n\nAdd Honeykiq to your Sidekiq server middleware chain. It will send an event to\nHoneycomb once a job finishes or fails. Have a look at [server_middleware.rb]\nto see what kind of information it sends.\n\n[server_middleware.rb]: https://github.com/carwow/honeykiq/blob/master/lib/honeykiq/server_middleware.rb\n\n```ruby\n# Configure Honeycomb beeline\nHoneycomb.configure do |config|\n  config.write_key = ENV.fetch('HONEYCOMB_WRITE_KEY')\n  config.dataset = ENV.fetch('HONEYCOMB_DATASET')\nend\n\n# Add the middleware to Sidekiq chain\nSidekiq.configure_server do |config|\n  config.server_middleware do |chain|\n    chain.add Honeykiq::ServerMiddleware\n  end\nend\n\n# Or pass the libhoney client to the middleware\nSidekiq.configure_server do |config|\n  config.server_middleware do |chain|\n    chain.add Honeykiq::ServerMiddleware,\n      libhoney: Libhoney::Client.new(\n        write_key: ENV.fetch('HONEYCOMB_WRITE_KEY'),\n        dataset: ENV.fetch('HONEYCOMB_DATASET')\n      )\n  end\nend\n```\n\nYou can add your own data or functions to the Honeycomb event by subclassing\n`Honeykiq::ServerMiddleware`, and overriding the `extra_fields` method with\nyour own hash. The contents will be serialized into individual items in the\nevent:\n\n```ruby\nclass MyServerMiddleware \u003c Honeykiq::ServerMiddleware\n  def extra_fields(job) # Sidekiq::Job instance\n    {\n      my_data: 'evaluated and added to the event after the job has finished/errored',\n      my_function: -\u003e { Time.now }\n    }\n  end\nend\n\nSidekiq.configure_server do |config|\n  config.server_middleware do |chain|\n    chain.add MyServerMiddleware\n  end\nend\n```\n\n**Note:** If you have long running jobs, an event is only sent to Honeycomb\nwhen the job finishes. Therefore, it may appear as though no jobs are currently\nrunning.  Additionally, if the process receives a `SIGKILL` then no event is\nsent about that job, and the job may keep retrying without appearing in\nHoneycomb. The `PeriodicReporter` provides visibility for these cases.\n\n### Honeykiq::PeriodicReporter\n\nThe periodic reporter should be scheduled to report every few seconds,\ndepending on your use case. Every time the `#report` method is called it will\nsend a total of `1 + P + Q` events to Honeycomb where `P` and `Q` are the\nnumber of processes and queues respectively.\n\nIt sends three types of events: `instance`, `process`, and `queue`. Have a look\nat [periodic_reporter.rb] to see what kind of information we send for each\ntype.\n\n[periodic_reporter.rb]: https://github.com/carwow/honeykiq/blob/master/lib/honeykiq/periodic_reporter.rb\n\nA setup using [clockwork] to report every 30 seconds would look like this:\n\n```ruby\nrequire 'honeycomb-beeline'\nrequire 'clockwork'\nrequire 'honeykiq'\n\nHoneycomb.configure do |config|\n  config.write_key = ENV.fetch('HONEYCOMB_WRITE_KEY')\n  config.dataset = ENV.fetch('HONEYCOMB_DATASET')\nend\n\nmodule Clockwork\n  every(30, 'Honeykiq::PeriodicReporter') do\n    Honeykiq::PeriodicReporter.new.report\n  end\nend\n```\n\n[clockwork]: https://github.com/Rykian/clockwork\n\n## Contributing\n\n[Pull requests] are very welcome!\n\nPlease report bugs in a [new issue].\n\nEveryone is expected to follow the [code of conduct].\n\n[Pull requests]: https://github.com/carwow/honeykiq/pulls\n[new issue]: https://github.com/carwow/honeykiq/issues/new\n[code of conduct]: https://github.com/carwow/honeykiq/tree/master/CODE_OF_CONDUCT.md\n\n## License\n\nThe gem is available as open source under the terms of the\n[MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarwow%2Fhoneykiq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarwow%2Fhoneykiq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarwow%2Fhoneykiq/lists"}