Skip to content

Commit

Permalink
Include X-Request-Id header is worker proctitle
Browse files Browse the repository at this point in the history
Useful to map a process with application logs.
  • Loading branch information
byroot committed Apr 9, 2024
1 parent e3116a6 commit 3dac0a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Add `X-Request-Id` header in the workers proctitle if present.

# 0.13.0

- Fix compatibility with `--enable-frozen-string-literal` in preparation for Ruby 3.4.
Expand Down
6 changes: 5 additions & 1 deletion lib/pitchfork/http_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,11 @@ def process_client(client, worker, timeout_handler)
@request = Pitchfork::HttpParser.new
env = @request.read(client)

proc_name status: "requests: #{worker.requests_count}, processing: #{env["PATH_INFO"]}"
status = "requests: #{worker.requests_count}, processing: #{env["PATH_INFO"]}"
if request_id = env["HTTP_X_REQUEST_ID"]
status += ", request_id: #{request_id}"
end
proc_name status: status

env["pitchfork.worker"] = worker
timeout_handler.rack_env = env
Expand Down

0 comments on commit 3dac0a4

Please sign in to comment.