Skip to content

Commit

Permalink
Merge pull request #685 from bugsnag/hackathon/configurable-endpoints
Browse files Browse the repository at this point in the history
Hackathon - allow repeating of errors to Bugsnag development
  • Loading branch information
twometresteve authored Oct 17, 2024
2 parents 730f5e8 + a417ec2 commit 0db4ce8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/maze/repeaters/bugsnag_repeater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ def enabled?
end

def url_for_request_type
traces_endpoint = URI.parse(ENV['MAZE_REPEATER_TRACES_ENDPOINT'] || 'https://otlp.bugsnag.com/v1/traces').tap do |u|
u.host = "#{Maze.config.bugsnag_repeater_api_key}.#{u.host}" unless u.host == 'localhost'
end
url = case @request_type
when :errors then 'https://notify.bugsnag.com/'
when :sessions then 'https://sessions.bugsnag.com/'
when :traces then "https://#{Maze.config.bugsnag_repeater_api_key}.otlp.bugsnag.com/v1/traces"
when :errors then ENV['MAZE_REPEATER_NOTIFY_ENDPOINT'] || 'https://notify.bugsnag.com/'
when :sessions then ENV['MAZE_REPEATER_SESSIONS_ENDPOINT'] || 'https://sessions.bugsnag.com/'
when :traces then traces_endpoint.to_s
else return nil
end
URI.parse(url)
Expand Down
5 changes: 4 additions & 1 deletion lib/maze/repeaters/request_repeater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def repeat(request)

uri = url_for_request_type

Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |https|
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.to_s.start_with?('https')) do |https|

uri.path = '/' if uri.path.nil? || uri.path.empty?

onward_request = Net::HTTP::Post.new(uri.path)
onward_request.body = decompress(request)

Expand Down

0 comments on commit 0db4ce8

Please sign in to comment.