{"id":19723495,"url":"https://github.com/remind101/request_id","last_synced_at":"2025-04-29T22:30:58.753Z","repository":{"id":10546490,"uuid":"12744034","full_name":"remind101/request_id","owner":"remind101","description":"Middleware for logging heroku request id's","archived":false,"fork":false,"pushed_at":"2022-12-23T21:09:04.000Z","size":52,"stargazers_count":17,"open_issues_count":0,"forks_count":13,"subscribers_count":90,"default_branch":"master","last_synced_at":"2025-04-22T19:47:36.499Z","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/remind101.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}},"created_at":"2013-09-11T00:38:11.000Z","updated_at":"2024-03-10T01:05:39.000Z","dependencies_parsed_at":"2023-01-13T16:00:21.292Z","dependency_job_id":null,"html_url":"https://github.com/remind101/request_id","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remind101%2Frequest_id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remind101%2Frequest_id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remind101%2Frequest_id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remind101%2Frequest_id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remind101","download_url":"https://codeload.github.com/remind101/request_id/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251592952,"owners_count":21614448,"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-11T23:22:23.942Z","updated_at":"2025-04-29T22:30:58.176Z","avatar_url":"https://github.com/remind101.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deprecated and looking for new maintainers!\n\n# RequestId\n\nThis is a gem with a collection of middleware for easily cascading [Heroku request id's](https://devcenter.heroku.com/articles/http-request-id)\nThroughout the system. It includes:\n\n* Rack middleware, which adds the request\\_id to `Thread.current[:request_id]`.\n* Sidekiq Client middleware, which adds the request\\_id to the message\n  payload.\n* Sidekiq Server middleware, which adds the request\\_id to\n  `Thread.current[:request_id]` from the request\\_id in the message payload.\n* Faraday middleware, which adds the request\\_id as a response header `X-Request-Id`.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'request_id'\n```\n\n## Usage\n\nAdd the rack middleware:\n\n```ruby\nuse Rack::RequestId\n```\n\n### If you're using Sidekiq\n\nAdd the client middleware.\n\n```ruby\nSidekiq.configure_client do |config|\n  config.client_middleware do |chain|\n    chain.add Sidekiq::Middleware::Client::RequestId\n  end\nend\n```\n\nAdd the server middleware.\n\n```ruby\nSidekiq.configure_server do |config|\n  config.client_middleware do |chain|\n    chain.add Sidekiq::Middleware::Client::RequestId\n  end\n\n  config.server_middleware do |chain|\n    chain.add Sidekiq::Middleware::Server::RequestId\n  end\nend\n```\n\nIf you're using other Sidekiq middleware that wraps job execution, consider\nusing Sidekiq's\n[`chain.prepend`](http://www.rubydoc.info/github/mperham/sidekiq/Sidekiq%2FMiddleware%2FChain%3Aprepend)\nin place of `chain.add` to push the `request_id` middleware to the top of the\nstack so it runs before other possibly dependent middleware. For example:\n\n```ruby\nSidekiq.configure_client do |config|\n  config.client_middleware do |chain|\n    chain.prepend Sidekiq::Middleware::Client::RequestId\n  end\nend\n```\n\n### If you're using Faraday\n\nAdd the middleware.\n\n```ruby\n  builder.use Faraday::RequestId\n\n```\n\n### Customization\n\nYou can customize each middleware to store the value of any headers you like in the same fashion. For instance,\nif you wanted to track a `X-Request-Id` header as well as a `X-Session-Id` header, you could do so like this:\n\n```ruby\n# Rack\nuse Rack::RequestId\nuse Rack::RequestId, headers: [ { key: :request_id, value: -\u003e (env) { env['HTTP_X_SESSION_ID'], response_header: 'X-Session-Id' } } ]\n\n# Sidekiq\nSidekiq.configure_client do |config|\n  config.client_middleware do |chain|\n    chain.add Sidekiq::Middleware::Client::RequestId\n    chain.add Sidekiq::Middleware::Client::RequestId, headers: [ { key: :session_id, value: -\u003e { ::RequestId.get(:session_id) } } ]\n  end\nend\n\nSidekiq.configure_server do |config|\n  config.client_middleware do |chain|\n    chain.add Sidekiq::Middleware::Client::RequestId\n    chain.add Sidekiq::Middleware::Client::RequestId, headers: [ { key: :session_id, value: -\u003e { ::RequestId.get(:session_id) } } ]\n  end\n\n  config.server_middleware do |chain|\n    chain.add Sidekiq::Middleware::Server::RequestId, headers: [ { key: :session_id, value: lambda { |item| item['session_id'] } } ]\n  end\nend\n\n# Faraday\nbuilder.use Faraday::RequestId, headers: [ { key: :session_id, header: 'X-Session-Id' } ]\n```\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%2Fremind101%2Frequest_id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremind101%2Frequest_id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremind101%2Frequest_id/lists"}