bugsnag-maze-runner 7.28.0 → 7.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/maze-runner +3 -1
- data/lib/maze/client/appium/bb_client.rb +4 -4
- data/lib/maze/client/appium/bb_devices.rb +18 -12
- data/lib/maze/client/bb_api_client.rb +22 -14
- data/lib/maze/client/selenium/bb_client.rb +4 -3
- data/lib/maze/client/selenium/bs_browsers.yml +6 -0
- data/lib/maze/configuration.rb +5 -2
- data/lib/maze/option/parser.rb +7 -2
- data/lib/maze/option/processor.rb +3 -1
- data/lib/maze/option/validator.rb +2 -2
- data/lib/maze/option.rb +2 -1
- data/lib/maze/repeaters/aspecto_repeater.rb +30 -0
- data/lib/maze/repeaters/bugsnag_repeater.rb +30 -0
- data/lib/maze/repeaters/request_repeater.rb +61 -0
- data/lib/maze/servlets/servlet.rb +6 -1
- data/lib/maze.rb +1 -1
- metadata +5 -3
- data/lib/maze/request_repeater.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c132077721ff7826d0a4e3735f61ddfeaacc94c85adc0da7f638e0b8469c867
|
4
|
+
data.tar.gz: b62473d6c7a69a7d7f2be846e142f4860d1485ddd24b7e70647828971d7b0909
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d8e5613c8a6f989f21cb1bf51b86248ae9f70acbaf10521e7ef41621ea2e5e21e320da23d5d2c736f3b269de1e0a23d0623bcfd3b7c1df54992c5d26c883dd6
|
7
|
+
data.tar.gz: 95143189aa779a5b8c8ac5bec5214bc9705ccba94165d2158fca2e4a6cd55100a1dc45369b307cd99a73642198334729732d94215f7c905074f13743a55c5dcb
|
data/bin/maze-runner
CHANGED
@@ -42,7 +42,9 @@ require_relative '../lib/maze/metrics_processor'
|
|
42
42
|
require_relative '../lib/maze/network'
|
43
43
|
require_relative '../lib/maze/proxy'
|
44
44
|
require_relative '../lib/maze/retry_handler'
|
45
|
-
require_relative '../lib/maze/request_repeater'
|
45
|
+
require_relative '../lib/maze/repeaters/request_repeater'
|
46
|
+
require_relative '../lib/maze/repeaters/aspecto_repeater'
|
47
|
+
require_relative '../lib/maze/repeaters/bugsnag_repeater'
|
46
48
|
require_relative '../lib/maze/runner'
|
47
49
|
require_relative '../lib/maze/terminating_server'
|
48
50
|
|
@@ -26,19 +26,19 @@ module Maze
|
|
26
26
|
|
27
27
|
def device_capabilities
|
28
28
|
config = Maze.config
|
29
|
+
prefix = BitBarDevices.caps_prefix(config.appium_version)
|
29
30
|
capabilities = {
|
30
|
-
|
31
|
+
"#{prefix}noReset" => true,
|
32
|
+
"#{prefix}newCommandTimeout" => 0,
|
31
33
|
'bitbar:options' => {
|
32
34
|
# Some capabilities probably belong in the top level
|
33
35
|
# of the hash, but BitBar picks them up from here.
|
34
36
|
'apiKey' => config.access_key,
|
35
37
|
'app' => config.app,
|
36
38
|
'findDevice' => false,
|
37
|
-
'testTimeout' => 7200
|
38
|
-
'newCommandTimeout' => 0
|
39
|
+
'testTimeout' => 7200
|
39
40
|
}
|
40
41
|
}
|
41
|
-
capabilities['appiumVersion'] = config.appium_version unless config.appium_version.nil?
|
42
42
|
capabilities.deep_merge! dashboard_capabilities
|
43
43
|
capabilities.deep_merge! BitBarDevices.get_available_device(config.device)
|
44
44
|
capabilities.deep_merge! JSON.parse(config.capabilities_option)
|
@@ -9,24 +9,25 @@ module Maze
|
|
9
9
|
class BitBarDevices
|
10
10
|
class << self
|
11
11
|
# Uses the BitBar API to find an available device from the group name given, or a device of that name
|
12
|
-
# @param
|
12
|
+
# @param device_or_group_names [String] Name of the device, or device group(s) for which to find an available
|
13
|
+
# device. Multiple device group names can be separated by a pipe.
|
13
14
|
# @return Capabilities hash for the available device
|
14
|
-
def get_available_device(
|
15
|
+
def get_available_device(device_or_group_names)
|
15
16
|
api_client = BitBarApiClient.new(Maze.config.access_key)
|
16
|
-
|
17
|
-
if
|
17
|
+
device_group_ids = api_client.get_device_group_ids(device_or_group_names)
|
18
|
+
if device_group_ids
|
18
19
|
# Device group found - find a free device in it
|
19
|
-
$logger.debug "Got group
|
20
|
-
group_count, device = api_client.
|
20
|
+
$logger.debug "Got group ids #{device_group_ids} for #{device_or_group_names}"
|
21
|
+
group_count, device = api_client.find_device_in_groups(device_group_ids)
|
21
22
|
if device.nil?
|
22
23
|
# TODO: Retry rather than fail, see PLAT-7377
|
23
24
|
Maze::Helper.error_exit 'There are no devices available'
|
24
25
|
else
|
25
|
-
$logger.info "#{group_count} device(s) currently available in group '#{
|
26
|
+
$logger.info "#{group_count} device(s) currently available in group(s) '#{device_or_group_names}'"
|
26
27
|
end
|
27
28
|
else
|
28
29
|
# See if there is a device with the given name
|
29
|
-
device = api_client.find_device
|
30
|
+
device = api_client.find_device device_or_group_names
|
30
31
|
end
|
31
32
|
|
32
33
|
device_name = device['displayName']
|
@@ -40,6 +41,8 @@ module Maze
|
|
40
41
|
Maze.config.os = platform
|
41
42
|
Maze.config.os_version = platform_version.to_f.floor
|
42
43
|
|
44
|
+
prefix = caps_prefix(Maze.config.appium_version)
|
45
|
+
|
43
46
|
case platform
|
44
47
|
when 'android'
|
45
48
|
automation_name = if platform_version.start_with?('5')
|
@@ -49,7 +52,7 @@ module Maze
|
|
49
52
|
end
|
50
53
|
make_android_hash(device_name, automation_name)
|
51
54
|
when 'ios'
|
52
|
-
make_ios_hash(device_name)
|
55
|
+
make_ios_hash(device_name, prefix)
|
53
56
|
else
|
54
57
|
throw "Invalid device platform specified #{platform}"
|
55
58
|
end
|
@@ -108,18 +111,21 @@ module Maze
|
|
108
111
|
hash.freeze
|
109
112
|
end
|
110
113
|
|
111
|
-
def make_ios_hash(device)
|
114
|
+
def make_ios_hash(device, prefix='')
|
112
115
|
{
|
113
116
|
'automationName' => 'XCUITest',
|
114
117
|
'deviceName' => 'iPhone device',
|
115
118
|
'platformName' => 'iOS',
|
119
|
+
"#{prefix}shouldTerminateApp" => 'true',
|
116
120
|
'bitbar:options' => {
|
117
|
-
'noReset' => 'true',
|
118
|
-
'shouldTerminateApp' => 'true',
|
119
121
|
'device' => device
|
120
122
|
}
|
121
123
|
}.freeze
|
122
124
|
end
|
125
|
+
|
126
|
+
def caps_prefix(appium_version)
|
127
|
+
appium_version.nil? || (appium_version.to_i < 2) ? '' : 'appium:'
|
128
|
+
end
|
123
129
|
end
|
124
130
|
end
|
125
131
|
end
|
@@ -20,30 +20,38 @@ module Maze
|
|
20
20
|
query_api(path)
|
21
21
|
end
|
22
22
|
|
23
|
-
# Get the id of a device
|
24
|
-
|
23
|
+
# Get the id(s) of a one or more device groups given their names. Multiple device group names should be separated
|
24
|
+
# by a pipe (which is directly supported by the BitBar API)
|
25
|
+
def get_device_group_ids(device_group_names)
|
25
26
|
query = {
|
26
|
-
'filter': "
|
27
|
+
'filter': "displayName_in_#{device_group_names}"
|
27
28
|
}
|
28
29
|
device_groups = query_api('device-groups', query)
|
29
30
|
if device_groups['data'].nil? || device_groups['data'].size == 0
|
30
31
|
nil
|
31
32
|
else
|
32
|
-
device_groups['data'][
|
33
|
+
device_groups['data'].map { |group| group['id'] }
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
def find_device_in_groups(device_group_ids)
|
38
|
+
all_devices = []
|
39
|
+
device_group_ids.each do |group_id|
|
40
|
+
path = "device-groups/#{group_id}/devices"
|
41
|
+
query = {
|
42
|
+
'filter': "online_eq_true"
|
43
|
+
}
|
44
|
+
all_devices += query_api(path, query)['data']
|
45
|
+
end
|
46
|
+
|
47
|
+
$logger.debug "All available devices in group(s) #{device_group_ids}: #{JSON.pretty_generate(all_devices)}"
|
48
|
+
filtered_devices = all_devices.reject { |device| device['locked'] }
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
50
|
+
# Only send gauges to DataDog for single device groups
|
51
|
+
if device_group_ids.size == 1
|
52
|
+
Maze::Plugins::DatadogMetricsPlugin.send_gauge('bitbar.device.available', all_devices.size, [Maze.config.device])
|
53
|
+
Maze::Plugins::DatadogMetricsPlugin.send_gauge('bitbar.device.unlocked', filtered_devices.size, [Maze.config.device])
|
54
|
+
end
|
47
55
|
return filtered_devices.size, filtered_devices.sample
|
48
56
|
end
|
49
57
|
|
@@ -12,9 +12,10 @@ module Maze
|
|
12
12
|
config.capabilities = capabilities
|
13
13
|
|
14
14
|
if Maze::Client::BitBarClientUtils.use_local_tunnel?
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
if ENV['BUILDKITE']
|
16
|
+
credentials = Maze::Client::BitBarClientUtils.account_credentials config.tms_uri
|
17
|
+
capabilities['bitbar_apiKey'] = credentials[:access_key]
|
18
|
+
end
|
18
19
|
|
19
20
|
Maze::Client::BitBarClientUtils.start_local_tunnel config.sb_local,
|
20
21
|
config.username,
|
data/lib/maze/configuration.rb
CHANGED
@@ -61,8 +61,11 @@ module Maze
|
|
61
61
|
# The server endpoints for which invalid requests should be captured and cause tests to fail
|
62
62
|
attr_accessor :captured_invalid_requests
|
63
63
|
|
64
|
-
# API key to use when repeating requests
|
65
|
-
attr_accessor :
|
64
|
+
# API key to use when repeating requests to Bugsnag
|
65
|
+
attr_accessor :aspecto_repeater_api_key
|
66
|
+
|
67
|
+
# API key to use when repeating requests to Bugsnag
|
68
|
+
attr_accessor :bugsnag_repeater_api_key
|
66
69
|
|
67
70
|
# Enables awareness of a public IP address on Buildkite with the Elastic CI Stack for AWS.
|
68
71
|
attr_accessor :aws_public_ip
|
data/lib/maze/option/parser.rb
CHANGED
@@ -41,7 +41,11 @@ module Maze
|
|
41
41
|
type: :boolean,
|
42
42
|
default: true
|
43
43
|
|
44
|
-
opt Option::
|
44
|
+
opt Option::ASPECTO_REPEATER_API_KEY,
|
45
|
+
'Enables forwarding of all received POST requests to Aspecto, using the API key provided. MAZE_ASPECTO_REPEATER_API_KEY may also be set.',
|
46
|
+
type: :string
|
47
|
+
|
48
|
+
opt Option::BUGSNAG_REPEATER_API_KEY,
|
45
49
|
'Enables forwarding of all received POST requests to Bugsnag, using the API key provided. MAZE_REPEATER_API_KEY may also be set.',
|
46
50
|
type: :string
|
47
51
|
|
@@ -232,7 +236,8 @@ module Maze
|
|
232
236
|
options[Option::SELENIUM_SERVER] ||= ENV['MAZE_SELENIUM_SERVER'] || 'https://us-west-desktop-hub.bitbar.com/wd/hub'
|
233
237
|
end
|
234
238
|
|
235
|
-
options[Option::
|
239
|
+
options[Option::ASPECTO_REPEATER_API_KEY] ||= ENV['MAZE_ASPECTO_REPEATER_API_KEY']
|
240
|
+
options[Option::BUGSNAG_REPEATER_API_KEY] ||= ENV['MAZE_REPEATER_API_KEY']
|
236
241
|
options[Option::SB_LOCAL] ||= ENV['MAZE_SB_LOCAL'] || '/SBSecureTunnel'
|
237
242
|
options[Option::TMS_URI] ||= ENV['MAZE_TMS_URI']
|
238
243
|
options[Option::TMS_TOKEN] ||= ENV['MAZE_TMS_TOKEN']
|
@@ -23,7 +23,8 @@ module Maze
|
|
23
23
|
config.enable_bugsnag = options[Maze::Option::ENABLE_BUGSNAG]
|
24
24
|
config.tms_uri = options[Maze::Option::TMS_URI]
|
25
25
|
config.tms_token = options[Maze::Option::TMS_TOKEN]
|
26
|
-
config.
|
26
|
+
config.aspecto_repeater_api_key = options[Maze::Option::ASPECTO_REPEATER_API_KEY]
|
27
|
+
config.bugsnag_repeater_api_key = options[Maze::Option::BUGSNAG_REPEATER_API_KEY]
|
27
28
|
|
28
29
|
# Document server options
|
29
30
|
config.document_server_root = options[Maze::Option::DS_ROOT]
|
@@ -80,6 +81,7 @@ module Maze
|
|
80
81
|
config.username = options[Maze::Option::USERNAME]
|
81
82
|
config.access_key = options[Maze::Option::ACCESS_KEY]
|
82
83
|
config.tms_uri = options[Maze::Option::TMS_URI]
|
84
|
+
config.appium_version = options[Maze::Option::APPIUM_VERSION]
|
83
85
|
device_option = options[Maze::Option::DEVICE]
|
84
86
|
if device_option.nil? || device_option.empty?
|
85
87
|
# BitBar Web
|
@@ -30,10 +30,10 @@ module Maze
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# --repeater-api-key
|
33
|
-
key = options[Option::
|
33
|
+
key = options[Option::BUGSNAG_REPEATER_API_KEY]
|
34
34
|
key_regex = /^[0-9a-fA-F]{32}$/
|
35
35
|
if key && !key_regex.match?(key)
|
36
|
-
errors << "--#{Option::
|
36
|
+
errors << "--#{Option::BUGSNAG_REPEATER_API_KEY} must be set to a 32-character hex value"
|
37
37
|
end
|
38
38
|
|
39
39
|
# Farm specific options
|
data/lib/maze/option.rb
CHANGED
@@ -56,7 +56,8 @@ module Maze
|
|
56
56
|
|
57
57
|
# General options
|
58
58
|
AWS_PUBLIC_IP = 'aws-public-ip'
|
59
|
-
|
59
|
+
ASPECTO_REPEATER_API_KEY = 'aspecto-repeater-api-key'
|
60
|
+
BUGSNAG_REPEATER_API_KEY = 'repeater-api-key'
|
60
61
|
ENABLE_BUGSNAG = 'enable-bugsnag'
|
61
62
|
ENABLE_RETRIES = 'enable-retries'
|
62
63
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Maze
|
2
|
+
module Repeaters
|
3
|
+
# Repeats Bugsnag requests
|
4
|
+
class AspectoRepeater < RequestRepeater
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def set_headers(request)
|
9
|
+
request['Authorization'] = Maze.config.aspecto_repeater_api_key
|
10
|
+
end
|
11
|
+
|
12
|
+
def enabled?
|
13
|
+
# enabled if the config option is on and this request type should be repeated
|
14
|
+
Maze.config.aspecto_repeater_api_key && url_for_request_type
|
15
|
+
end
|
16
|
+
|
17
|
+
def gzip_supported
|
18
|
+
false
|
19
|
+
end
|
20
|
+
|
21
|
+
def url_for_request_type
|
22
|
+
url = case @request_type
|
23
|
+
when :traces then 'https://otelcol.aspecto.io:4318/v1/traces'
|
24
|
+
else return nil
|
25
|
+
end
|
26
|
+
URI.parse(url)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Maze
|
2
|
+
module Repeaters
|
3
|
+
# Repeats Bugsnag requests
|
4
|
+
class BugsnagRepeater < RequestRepeater
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def set_headers(request)
|
9
|
+
# TODO Also overwrite apiKey in the payload, if present, recalculate the integrity header (handling
|
10
|
+
# compressed payloads if the content-encoding header is set accordingly)
|
11
|
+
request['bugsnag-api-key'] = Maze.config.bugsnag_repeater_api_key
|
12
|
+
end
|
13
|
+
|
14
|
+
def enabled?
|
15
|
+
# enabled if the config option is on and this request type should be repeated
|
16
|
+
Maze.config.bugsnag_repeater_api_key && url_for_request_type
|
17
|
+
end
|
18
|
+
|
19
|
+
def url_for_request_type
|
20
|
+
url = case @request_type
|
21
|
+
when :errors then 'https://notify.bugsnag.com/'
|
22
|
+
when :sessions then 'https://sessions.bugsnag.com/'
|
23
|
+
when :traces then 'https://otlp.bugsnag.com/v1/traces'
|
24
|
+
else return nil
|
25
|
+
end
|
26
|
+
URI.parse(url)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Maze
|
2
|
+
module Repeaters
|
3
|
+
# Repeats POST requests
|
4
|
+
class RequestRepeater
|
5
|
+
|
6
|
+
def initialize(request_type)
|
7
|
+
@request_type = request_type
|
8
|
+
end
|
9
|
+
|
10
|
+
# @param request [HTTPRequest] The request to be repeated
|
11
|
+
def repeat(request)
|
12
|
+
|
13
|
+
return unless enabled?
|
14
|
+
|
15
|
+
# TODO Forwarding of internal errors to be considered later
|
16
|
+
return if request.header.keys.any? { |key| key.downcase == 'bugsnag-internal-error' }
|
17
|
+
|
18
|
+
uri = url_for_request_type
|
19
|
+
|
20
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |https|
|
21
|
+
onward_request = Net::HTTP::Post.new(uri)
|
22
|
+
onward_request.body = decompress(request)
|
23
|
+
|
24
|
+
# Set all headers that are present, unless Gzip is not supported
|
25
|
+
request.header.each do |key,value|
|
26
|
+
next if !gzip_supported && key.downcase == 'content-encoding'
|
27
|
+
next if key.downcase.start_with? 'bugsnag'
|
28
|
+
|
29
|
+
onward_request[key] = value
|
30
|
+
end
|
31
|
+
set_headers onward_request
|
32
|
+
|
33
|
+
https.request(onward_request)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def gzip_supported
|
40
|
+
true
|
41
|
+
end
|
42
|
+
|
43
|
+
def decompress(request)
|
44
|
+
if !gzip_supported && %r{^gzip$}.match(request['Content-Encoding'])
|
45
|
+
reader = Zlib::GzipReader.new(StringIO.new(request.body))
|
46
|
+
reader.read
|
47
|
+
else
|
48
|
+
request.body
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def enabled?
|
53
|
+
raise 'Method not implemented by this class'
|
54
|
+
end
|
55
|
+
|
56
|
+
def url_for_request_type
|
57
|
+
raise 'Method not implemented by this class'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -28,7 +28,6 @@ module Maze
|
|
28
28
|
|
29
29
|
# Receives and parses the requests and payloads sent from the test fixture
|
30
30
|
class Servlet < BaseServlet
|
31
|
-
prepend RequestRepeater
|
32
31
|
|
33
32
|
# Constructor
|
34
33
|
#
|
@@ -40,6 +39,8 @@ module Maze
|
|
40
39
|
@request_type = request_type
|
41
40
|
@requests = Server.list_for request_type
|
42
41
|
@schema = JSONSchemer.schema(schema) unless schema.nil?
|
42
|
+
@aspecto_repeater = Maze::Repeaters::AspectoRepeater.new(@request_type)
|
43
|
+
@bugsnag_repeater = Maze::Repeaters::BugsnagRepeater.new(@request_type)
|
43
44
|
end
|
44
45
|
|
45
46
|
# Logs an incoming GET WEBrick request.
|
@@ -57,6 +58,10 @@ module Maze
|
|
57
58
|
# @param request [HTTPRequest] The incoming GET request
|
58
59
|
# @param response [HTTPResponse] The response to return
|
59
60
|
def do_POST(request, response)
|
61
|
+
|
62
|
+
@aspecto_repeater.repeat request
|
63
|
+
@bugsnag_repeater.repeat request
|
64
|
+
|
60
65
|
# Turn the WEBrick HttpRequest into our internal HttpRequest delegate
|
61
66
|
request = HttpRequest.new(request)
|
62
67
|
|
data/lib/maze.rb
CHANGED
@@ -7,7 +7,7 @@ require_relative 'maze/timers'
|
|
7
7
|
# Glues the various parts of MazeRunner together that need to be accessed globally,
|
8
8
|
# providing an alternative to the proliferation of global variables or singletons.
|
9
9
|
module Maze
|
10
|
-
VERSION = '7.
|
10
|
+
VERSION = '7.30.0'
|
11
11
|
|
12
12
|
class << self
|
13
13
|
attr_accessor :check, :driver, :internal_hooks, :mode, :start_time, :dynamic_retry, :public_address,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugsnag-maze-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.30.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Kirkland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -420,8 +420,10 @@ files:
|
|
420
420
|
- lib/maze/plugins/error_code_plugin.rb
|
421
421
|
- lib/maze/plugins/global_retry_plugin.rb
|
422
422
|
- lib/maze/proxy.rb
|
423
|
+
- lib/maze/repeaters/aspecto_repeater.rb
|
424
|
+
- lib/maze/repeaters/bugsnag_repeater.rb
|
425
|
+
- lib/maze/repeaters/request_repeater.rb
|
423
426
|
- lib/maze/request_list.rb
|
424
|
-
- lib/maze/request_repeater.rb
|
425
427
|
- lib/maze/retry_handler.rb
|
426
428
|
- lib/maze/runner.rb
|
427
429
|
- lib/maze/schemas/OtelTraceSchema.json
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Maze
|
2
|
-
# Repeats POST requests
|
3
|
-
module RequestRepeater
|
4
|
-
|
5
|
-
def do_POST(request, response)
|
6
|
-
repeat(request) if enabled?
|
7
|
-
|
8
|
-
super(request, response)
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def enabled?
|
14
|
-
# enabled if the config option is on and this request type should be repeated
|
15
|
-
Maze.config.repeater_api_key && url_for_request_type
|
16
|
-
end
|
17
|
-
|
18
|
-
# @param request [HTTPRequest] The request to be repeated
|
19
|
-
def repeat(request)
|
20
|
-
|
21
|
-
# TODO Forwarding of internal errors to be considered later
|
22
|
-
return if request.header.keys.any? { |key| key.downcase == 'bugsnag-internal-error' }
|
23
|
-
|
24
|
-
url = url_for_request_type
|
25
|
-
http = Net::HTTP.new(url.host)
|
26
|
-
bugsnag_request = Net::HTTP::Post.new(url.path)
|
27
|
-
|
28
|
-
# Set all headers that are present
|
29
|
-
bugsnag_request.body = request.body
|
30
|
-
request.header.each {|key,value| bugsnag_request[key] = value }
|
31
|
-
bugsnag_request['bugsnag-api-key'] = Maze.config.repeater_api_key
|
32
|
-
|
33
|
-
# TODO Also overwrite apiKey in the payload, if present, recalculate the integrity header (handling
|
34
|
-
# compressed payloads if the content-encoding header is set accordingly)
|
35
|
-
|
36
|
-
http.request(bugsnag_request)
|
37
|
-
end
|
38
|
-
|
39
|
-
def url_for_request_type
|
40
|
-
url = case @request_type
|
41
|
-
when :errors then 'https://notify.bugsnag.com/'
|
42
|
-
when :sessions then 'https://sessions.bugsnag.com/'
|
43
|
-
when :traces then 'https://otlp.bugsnag.com/v1/traces'
|
44
|
-
else return nil
|
45
|
-
end
|
46
|
-
URI.parse(url)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|