Skip to content

Commit

Permalink
Merge pull request #687 from bugsnag/tms/store-event-id
Browse files Browse the repository at this point in the history
Hackathon - Store Bugsnag event id
  • Loading branch information
twometresteve authored Oct 17, 2024
2 parents 0db4ce8 + aad9120 commit ace9787
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/features/support/internal_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def output_received_requests(request_type)
request_queue.all.each.with_index(1) do |request, number|
$stdout.puts "--- #{request_type} #{number} of #{count}"

$logger.info "Bugsnag Event Id: #{request[:event_id]}" if request[:event_id]

$logger.info 'Request body:'
Maze::Loggers::LogUtil.log_hash(Logger::Severity::INFO, request[:body])

Expand Down
7 changes: 7 additions & 0 deletions lib/maze/maze_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,23 @@ def write_requests
uri = request[:request][:request_uri]
headers = request[:request][:header]
body = request[:request][:body]
event_id = nil
else
invalid_request = false
uri = request[:request].request_uri
headers = request[:request].header
body = request[:body]
event_id = request[:event_id]
end

file.puts "URI: #{uri}"
file.puts

if event_id
file.puts "Event Id: #{event_id}"
file.puts
end

# Request
file.puts "Request:"
headers.each do |key, values|
Expand Down
2 changes: 2 additions & 0 deletions lib/maze/repeaters/request_repeater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def repeat(request)

response = https.request(onward_request)
log_response response

next response
end
end

Expand Down
3 changes: 2 additions & 1 deletion lib/maze/servlets/servlet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def do_GET(request, _response)
def do_POST(request, response)

@aspecto_repeater.repeat request
@bugsnag_repeater.repeat request
bugsnag_response = @bugsnag_repeater.repeat request

# Turn the WEBrick HttpRequest into our internal HttpRequest delegate
request = Maze::HttpRequest.new(request)
Expand Down Expand Up @@ -90,6 +90,7 @@ def do_POST(request, response)
schema_errors = @schema.validate(hash[:body])
hash[:schema_errors] = schema_errors.to_a
end
hash[:event_id] = bugsnag_response['bugsnag-event-id'] if bugsnag_response
add_request(hash)

# For the response, delaying if configured to do so
Expand Down

0 comments on commit ace9787

Please sign in to comment.