Skip to content

Commit

Permalink
Add request_id to notices
Browse files Browse the repository at this point in the history
Foe #616
  • Loading branch information
stympy committed Oct 22, 2024
1 parent 1f401c9 commit dfe8792
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/honeybadger/agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def notify(exception_or_opts = nil, opts = {}, **kwargs)
opts[:rack_env] ||= context_manager.get_rack_env
opts[:global_context] ||= context_manager.get_context
opts[:breadcrumbs] ||= breadcrumbs.dup
opts[:request_id] ||= context_manager.get_request_id

notice = Notice.new(config, opts)

Expand Down
14 changes: 7 additions & 7 deletions lib/honeybadger/notice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def tags=(tags)
# Custom details data
attr_accessor :details

# The ID of the request which caused this notice.
attr_accessor :request_id

# The parsed exception backtrace. Lines in this backtrace that are from installed gems
# have the base path for gem installs replaced by "[GEM_ROOT]", while those in the project
# have "[PROJECT_ROOT]".
Expand Down Expand Up @@ -213,13 +216,7 @@ def initialize(config, opts = {})
self.api_key = opts[:api_key] || config[:api_key]
self.tags = construct_tags(opts[:tags]) | construct_tags(context[:tags])

self.url = opts[:url] || request_hash[:url] || nil
self.action = opts[:action] || request_hash[:action] || nil
self.component = opts[:controller] || opts[:component] || request_hash[:component] || nil
self.params = opts[:parameters] || opts[:params] || request_hash[:params] || {}
self.session = opts[:session] || request_hash[:session] || {}
self.cgi_data = opts[:cgi_data] || request_hash[:cgi_data] || {}
self.details = opts[:details] || {}
self.request_id = opts[:request_id] || nil

self.session = opts[:session][:data] if opts[:session] && opts[:session][:data]

Expand Down Expand Up @@ -261,6 +258,9 @@ def as_json(*args)
stats: stats,
time: now,
pid: pid
},
correlation_context: {
request_id: s(request_id)
}
}
end
Expand Down

0 comments on commit dfe8792

Please sign in to comment.