bugsnag-maze-runner 7.23.0 → 7.25.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 -0
- data/bin/upload-app +49 -23
- data/lib/features/steps/network_steps.rb +29 -20
- data/lib/features/steps/trace_steps.rb +6 -0
- data/lib/features/support/internal_hooks.rb +9 -0
- data/lib/maze/client/appium/bb_client.rb +19 -7
- data/lib/maze/client/bb_api_client.rb +2 -0
- data/lib/maze/client/bb_client_utils.rb +8 -1
- data/lib/maze/client/selenium/base_client.rb +4 -0
- data/lib/maze/client/selenium/bb_client.rb +9 -0
- data/lib/maze/client/selenium/bs_client.rb +4 -0
- data/lib/maze/driver/browser.rb +7 -0
- data/lib/maze/hooks/appium_hooks.rb +6 -0
- data/lib/maze/hooks/browser_hooks.rb +5 -1
- data/lib/maze/metrics_processor.rb +71 -0
- data/lib/maze/plugins/datadog_metrics_plugin.rb +71 -0
- data/lib/maze/request_list.rb +1 -1
- data/lib/maze/server.rb +10 -0
- data/lib/maze.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02e955bef1519e412688dc3c061336307d211c724dedd39fce301e9e89113f6e
|
4
|
+
data.tar.gz: c4643eab515e98e1acc179d9b5ddaf90c9d3bf937ace170860c52d7a9b1235f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ce234fcc1913ba4b2b87cbe13e30ce02c3e726e3ff38f0b466282c8bb7f6236202186a224f92b6e9582715fb2eba3b3db19723e19227ae8249b72abbcd35a49
|
7
|
+
data.tar.gz: 25fdf555f609bc45b19c09e53ffe23f2929ad0cddf7fc3c7d32891ebaf72a71c4426e932c7fe22151169dd60a1e177b86dafccf3b1f1e6aa218945b5354f0d30
|
data/bin/maze-runner
CHANGED
@@ -26,6 +26,7 @@ require_relative '../lib/maze/client/selenium/base_client'
|
|
26
26
|
require_relative '../lib/maze/client/selenium/bb_client'
|
27
27
|
require_relative '../lib/maze/client/selenium/bs_client'
|
28
28
|
require_relative '../lib/maze/client/selenium/local_client'
|
29
|
+
|
29
30
|
require_relative '../lib/maze/aws_public_ip'
|
30
31
|
require_relative '../lib/maze/compare'
|
31
32
|
require_relative '../lib/maze/docker'
|
@@ -37,6 +38,7 @@ require_relative '../lib/maze/http_request'
|
|
37
38
|
require_relative '../lib/maze/logger'
|
38
39
|
require_relative '../lib/maze/macos_utils'
|
39
40
|
require_relative '../lib/maze/maze_output'
|
41
|
+
require_relative '../lib/maze/metrics_processor'
|
40
42
|
require_relative '../lib/maze/network'
|
41
43
|
require_relative '../lib/maze/proxy'
|
42
44
|
require_relative '../lib/maze/retry_handler'
|
@@ -82,6 +84,7 @@ require_relative '../lib/maze/plugins/bugsnag_reporting_plugin'
|
|
82
84
|
require_relative '../lib/maze/plugins/cucumber_report_plugin'
|
83
85
|
require_relative '../lib/maze/plugins/error_code_plugin'
|
84
86
|
require_relative '../lib/maze/plugins/global_retry_plugin'
|
87
|
+
require_relative '../lib/maze/plugins/datadog_metrics_plugin'
|
85
88
|
|
86
89
|
# Require monkey-patches after everything else
|
87
90
|
require_relative '../lib/utils/selenium_money_patch'
|
data/bin/upload-app
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require_relative '../lib/maze'
|
5
5
|
require_relative '../lib/maze/client/bs_client_utils'
|
6
|
+
require_relative '../lib/maze/client/bb_client_utils'
|
6
7
|
require_relative '../lib/maze/logger'
|
7
8
|
require_relative '../lib/maze/helper'
|
8
9
|
require 'optimist'
|
@@ -11,45 +12,70 @@ require 'net/http'
|
|
11
12
|
|
12
13
|
class UploadAppEntry
|
13
14
|
def start(args)
|
14
|
-
|
15
|
-
text 'Upload app files to
|
16
|
-
text ''
|
17
|
-
text 'Requires BROWSER_STACK_USERNAME and BROWSER_STACK_ACCESS_KEY'
|
15
|
+
parser = Optimist::Parser.new do
|
16
|
+
text 'Upload app files to a device farm'
|
18
17
|
text ''
|
19
18
|
text 'Usage [OPTIONS]'
|
20
19
|
text ''
|
21
20
|
opt :help,
|
22
|
-
|
21
|
+
'Print this help.'
|
23
22
|
opt :app,
|
24
|
-
|
25
|
-
|
23
|
+
'The app to upload.',
|
24
|
+
type: :string,
|
25
|
+
required: true
|
26
26
|
opt :app_id_file,
|
27
|
-
|
28
|
-
|
27
|
+
'The file to write the uploaded app ID back to',
|
28
|
+
type: :string
|
29
|
+
opt :farm,
|
30
|
+
'The device farm to upload the app to, one of bb (BitBar) or bs (BrowserStack) (default)',
|
31
|
+
type: :string,
|
32
|
+
default: 'bs'
|
33
|
+
opt :username,
|
34
|
+
'Device farm username. Defaults to BROWSER_STACK_DEVICES_USERNAME variable (required for BrowserStack)',
|
35
|
+
type: :string
|
36
|
+
opt :access_key,
|
37
|
+
'Device farm access key. Defaults to BROWSER_STACK_DEVICES_ACCESS_KEY or BITBAR_ACCESS_KEY environment variables (required)',
|
38
|
+
type: :string
|
29
39
|
end
|
30
40
|
|
31
|
-
|
41
|
+
options = Optimist::with_standard_exception_handling parser do
|
32
42
|
raise Optimist::HelpNeeded if ARGV.empty? # show help screen
|
33
|
-
|
43
|
+
parser.parse ARGV
|
34
44
|
end
|
35
45
|
|
36
|
-
# Get
|
37
|
-
|
38
|
-
|
46
|
+
# Get username and access key from the environment
|
47
|
+
case options[:farm]
|
48
|
+
when 'bs'
|
49
|
+
options[:username] ||= ENV['BROWSER_STACK_DEVICES_USERNAME'] || ENV['BROWSER_STACK_USERNAME']
|
50
|
+
options[:access_key] ||= ENV['BROWSER_STACK_DEVICES_ACCESS_KEY'] ||ENV['BROWSER_STACK_ACCESS_KEY']
|
51
|
+
if options[:username].nil?
|
52
|
+
$logger.warn 'Browserstack requires username option to be set'
|
53
|
+
Optimist::with_standard_exception_handling parser do
|
54
|
+
raise Optimist::HelpNeeded
|
55
|
+
end
|
56
|
+
end
|
57
|
+
when 'bb'
|
58
|
+
options[:access_key] ||= ENV['BITBAR_ACCESS_KEY']
|
59
|
+
end
|
39
60
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
Optimist::with_standard_exception_handling p do
|
61
|
+
if options[:access_key].nil?
|
62
|
+
$logger.warn 'An access_key is required to upload the app'
|
63
|
+
Optimist::with_standard_exception_handling parser do
|
44
64
|
raise Optimist::HelpNeeded
|
45
65
|
end
|
46
66
|
end
|
47
67
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
68
|
+
case options[:farm]
|
69
|
+
when 'bs'
|
70
|
+
Maze::Client::BrowserStackClientUtils.upload_app options[:username],
|
71
|
+
options[:access_key],
|
72
|
+
options[:app],
|
73
|
+
options[:app_id_file]
|
74
|
+
when 'bb'
|
75
|
+
Maze::Client::BitBarClientUtils.upload_app options[:access_key],
|
76
|
+
options[:app],
|
77
|
+
options[:app_id_file]
|
78
|
+
end
|
53
79
|
end
|
54
80
|
end
|
55
81
|
|
@@ -8,29 +8,17 @@ When('I wait for the host {string} to open port {string}') do |host, port|
|
|
8
8
|
Maze::Network.wait_for_port(host, port)
|
9
9
|
end
|
10
10
|
|
11
|
-
# Sets the HTTP status code to be used for
|
12
|
-
#
|
13
|
-
# @step_input status_code [Integer] The status code to return
|
14
|
-
When('I set the HTTP status code to {int}') do |status_code|
|
15
|
-
Maze::Server.set_status_code_generator(Maze::Generator.new [status_code].cycle)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Sets the HTTP status code to be used for the next request
|
19
|
-
#
|
20
|
-
# @step_input status_code [Integer] The status code to return
|
21
|
-
When('I set the HTTP status code for the next request to {int}') do |status_code|
|
22
|
-
Maze::Server.set_status_code_generator(create_defaulting_generator([status_code], Maze::Server::DEFAULT_STATUS_CODE))
|
23
|
-
end
|
24
|
-
|
25
|
-
# Sets the HTTP status code to be used for the next set of requests
|
11
|
+
# Sets the HTTP status code to be used for the next set of requests for a given connection type
|
26
12
|
#
|
13
|
+
# @step_input http_verb [String] The type of request this code will be used for
|
27
14
|
# @step_input status_codes [String] A comma separated list of status codes to return
|
28
|
-
When('I set the HTTP status code for the next requests to {string}') do |status_codes|
|
15
|
+
When('I set the HTTP status code for the next {string} requests to {string}') do |http_verb, status_codes|
|
16
|
+
raise("Invalid HTTP verb: #{http_verb}") unless Maze::Server::ALLOWED_HTTP_VERBS.include?(http_verb)
|
29
17
|
codes = status_codes.split(',').map(&:strip)
|
30
|
-
Maze::Server.set_status_code_generator(create_defaulting_generator(codes, Maze::Server::DEFAULT_STATUS_CODE))
|
18
|
+
Maze::Server.set_status_code_generator(create_defaulting_generator(codes, Maze::Server::DEFAULT_STATUS_CODE), http_verb)
|
31
19
|
end
|
32
20
|
|
33
|
-
#
|
21
|
+
# Sets the HTTP status code to be used for all subsequent requests for a given connection type
|
34
22
|
#
|
35
23
|
# @step_input http_verb [String] The type of request this code will be used for
|
36
24
|
# @step_input status_code [Integer] The status code to return
|
@@ -39,7 +27,7 @@ When('I set the HTTP status code for {string} requests to {int}') do |http_verb,
|
|
39
27
|
Maze::Server.set_status_code_generator(Maze::Generator.new([status_code].cycle), http_verb)
|
40
28
|
end
|
41
29
|
|
42
|
-
#
|
30
|
+
# Sets the HTTP status code to be used for the next request for a given connection type
|
43
31
|
#
|
44
32
|
# @step_input http_verb [String] The type of request this code will be used for
|
45
33
|
# @step_input status_code [Integer] The status code to return
|
@@ -48,6 +36,27 @@ When('I set the HTTP status code for the next {string} request to {int}') do |ht
|
|
48
36
|
Maze::Server.set_status_code_generator(create_defaulting_generator([status_code], Maze::Server::DEFAULT_STATUS_CODE), http_verb)
|
49
37
|
end
|
50
38
|
|
39
|
+
# Sets the HTTP status code to be used for all subsequent POST requests
|
40
|
+
#
|
41
|
+
# @step_input status_code [Integer] The status code to return
|
42
|
+
When('I set the HTTP status code to {int}') do |status_code|
|
43
|
+
step %{I set the HTTP status code for "POST" requests to #{status_code}}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Sets the HTTP status code to be used for the next POST request
|
47
|
+
#
|
48
|
+
# @step_input status_code [Integer] The status code to return
|
49
|
+
When('I set the HTTP status code for the next request to {int}') do |status_code|
|
50
|
+
step %{I set the HTTP status code for the next "POST" request to #{status_code}}
|
51
|
+
end
|
52
|
+
|
53
|
+
# Sets the HTTP status code to be used for the next set of POST requests
|
54
|
+
#
|
55
|
+
# @step_input status_codes [String] A comma separated list of status codes to return
|
56
|
+
When('I set the HTTP status code for the next requests to {string}') do |status_codes|
|
57
|
+
step %{I set the HTTP status code for the next "POST" requests to "#{status_codes}"}
|
58
|
+
end
|
59
|
+
|
51
60
|
# Sets the sampling probability to be used for all subsequent trace responses
|
52
61
|
#
|
53
62
|
# @step_input sampling_probability [String] The sampling probability to return
|
@@ -103,7 +112,7 @@ end
|
|
103
112
|
# @step_input url [String] The URL to open.
|
104
113
|
When('I open the URL {string}') do |url|
|
105
114
|
begin
|
106
|
-
open(url, &:read)
|
115
|
+
URI.open(url, &:read)
|
107
116
|
rescue OpenURI::HTTPError
|
108
117
|
$logger.debug $!.inspect
|
109
118
|
end
|
@@ -148,6 +148,12 @@ Then('a span field {string} equals {string}') do |key, expected|
|
|
148
148
|
Maze.check.includes selected_keys, expected
|
149
149
|
end
|
150
150
|
|
151
|
+
Then('a span field {string} equals {int}') do |key, expected|
|
152
|
+
spans = spans_from_request_list(Maze::Server.list_for('traces'))
|
153
|
+
selected_keys = spans.map { |span| span[key] }
|
154
|
+
Maze.check.includes selected_keys, expected
|
155
|
+
end
|
156
|
+
|
151
157
|
Then('a span field {string} matches the regex {string}') do |attribute, pattern|
|
152
158
|
regex = Regexp.new pattern
|
153
159
|
spans = spans_from_request_list(Maze::Server.list_for('traces'))
|
@@ -65,6 +65,9 @@ BeforeAll do
|
|
65
65
|
# Start document server, if asked for
|
66
66
|
# This must happen after any client hooks have run, so that they can set the server root
|
67
67
|
Maze::DocumentServer.start unless Maze.config.document_server_root.nil?
|
68
|
+
|
69
|
+
# An initial setup for total success status
|
70
|
+
$success = true
|
68
71
|
end
|
69
72
|
|
70
73
|
# @param config The Cucumber config
|
@@ -141,6 +144,9 @@ After do |scenario|
|
|
141
144
|
output_received_requests('invalid requests')
|
142
145
|
end
|
143
146
|
|
147
|
+
# Keep a global record of the total test status for reporting purposes
|
148
|
+
$success = !scenario.failed?
|
149
|
+
|
144
150
|
# Log all received requests to file
|
145
151
|
Maze::MazeOutput.new(scenario).write_requests if Maze.config.file_log
|
146
152
|
|
@@ -183,6 +189,9 @@ end
|
|
183
189
|
# After all tests
|
184
190
|
AfterAll do
|
185
191
|
|
192
|
+
metrics = Maze::MetricsProcessor.new(Maze::Server.metrics)
|
193
|
+
metrics.process
|
194
|
+
|
186
195
|
if Maze.timers.size.positive?
|
187
196
|
$stdout.puts '--- Timer summary'
|
188
197
|
Maze.timers.report
|
@@ -70,25 +70,37 @@ module Maze
|
|
70
70
|
#
|
71
71
|
# @return [Hash] A hash containing the capabilities.
|
72
72
|
def dashboard_capabilities
|
73
|
-
|
74
|
-
|
75
|
-
if
|
76
|
-
project
|
73
|
+
|
74
|
+
# Determine project name
|
75
|
+
if ENV['BUILDKITE']
|
76
|
+
$logger.info 'Using BUILDKITE_PIPELINE_SLUG for BitBar project name'
|
77
|
+
project = ENV['BUILDKITE_PIPELINE_SLUG']
|
77
78
|
else
|
78
|
-
|
79
|
-
|
79
|
+
# Attempt to use the current git repo
|
80
|
+
output, status = Maze::Runner.run_command('git rev-parse --show-toplevel')
|
81
|
+
if status == 0
|
82
|
+
project = File.basename(output[0].strip)
|
80
83
|
else
|
81
84
|
$logger.warn 'Unable to determine project name, consider running Maze Runner from within a Git repository'
|
82
85
|
project = 'Unknown'
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
89
|
+
# Test run
|
86
90
|
if ENV['BUILDKITE']
|
87
|
-
|
91
|
+
bk_retry = ENV['BUILDKITE_RETRY_COUNT']
|
92
|
+
retry_string = if !bk_retry.nil? && bk_retry.to_i > 1
|
93
|
+
" (#{bk_retry})"
|
94
|
+
else
|
95
|
+
''
|
96
|
+
end
|
97
|
+
test_run = "#{ENV['BUILDKITE_BUILD_NUMBER']} - #{ENV['BUILDKITE_LABEL']}#{retry_string}"
|
88
98
|
else
|
89
99
|
test_run = Maze.run_uuid
|
90
100
|
end
|
91
101
|
|
102
|
+
$logger.info "BitBar project name: #{project}"
|
103
|
+
$logger.info "BitBar test run: #{test_run}"
|
92
104
|
{
|
93
105
|
'bitbar:options' => {
|
94
106
|
bitbar_project: project,
|
@@ -41,7 +41,9 @@ module Maze
|
|
41
41
|
all_devices = query_api(path, query)
|
42
42
|
|
43
43
|
$logger.debug "All available devices in group #{device_group_id}: #{JSON.pretty_generate(all_devices)}"
|
44
|
+
Maze::Plugins::DatadogMetricsPlugin.send_gauge('bitbar.device.available', all_devices['data'].size, [Maze.config.device])
|
44
45
|
filtered_devices = all_devices['data'].reject { |device| device['locked'] }
|
46
|
+
Maze::Plugins::DatadogMetricsPlugin.send_gauge('bitbar.device.unlocked', filtered_devices.size, [Maze.config.device])
|
45
47
|
return filtered_devices.size, filtered_devices.sample
|
46
48
|
end
|
47
49
|
|
@@ -17,7 +17,8 @@ module Maze
|
|
17
17
|
# Uploads an app to BitBar for later consumption
|
18
18
|
# @param api_key [String] The BitBar API key
|
19
19
|
# @param app [String] A path to the application file
|
20
|
-
|
20
|
+
# @param app_id_file [String] the file to write the uploaded app url to BitBar
|
21
|
+
def upload_app(api_key, app, app_id_file=nil)
|
21
22
|
uuid_regex = /\A[0-9]+\z/
|
22
23
|
|
23
24
|
if uuid_regex.match? app
|
@@ -53,6 +54,12 @@ module Maze
|
|
53
54
|
raise
|
54
55
|
end
|
55
56
|
end
|
57
|
+
|
58
|
+
unless app_id_file.nil?
|
59
|
+
$logger.info "Writing uploaded app id to #{app_id_file}"
|
60
|
+
File.write(Maze::Helper.expand_path(app_id_file), app_uuid)
|
61
|
+
end
|
62
|
+
|
56
63
|
app_uuid
|
57
64
|
end
|
58
65
|
|
@@ -27,6 +27,15 @@ module Maze
|
|
27
27
|
Maze.driver.start_driver
|
28
28
|
end
|
29
29
|
|
30
|
+
def log_run_outro
|
31
|
+
api_client = BitBarApiClient.new(Maze.config.access_key)
|
32
|
+
|
33
|
+
$logger.info 'Selenium session created:'
|
34
|
+
id = Maze.driver.session_id
|
35
|
+
link = api_client.get_device_session_ui_link(id)
|
36
|
+
$logger.info Maze::LogUtil.linkify link, 'BitBar session(s)' if link
|
37
|
+
end
|
38
|
+
|
30
39
|
def stop_session
|
31
40
|
super
|
32
41
|
Maze::Client::BitBarClientUtils.stop_local_tunnel
|
data/lib/maze/driver/browser.rb
CHANGED
@@ -6,6 +6,7 @@ module Maze
|
|
6
6
|
@client
|
7
7
|
|
8
8
|
def before_all
|
9
|
+
Maze::Plugins::DatadogMetricsPlugin.send_increment('appium.test_started')
|
9
10
|
@client = Maze::Client::Appium.start
|
10
11
|
end
|
11
12
|
|
@@ -30,6 +31,11 @@ module Maze
|
|
30
31
|
|
31
32
|
def after_all
|
32
33
|
@client&.log_run_outro
|
34
|
+
if $success
|
35
|
+
Maze::Plugins::DatadogMetricsPlugin.send_increment('appium.test_succeeded')
|
36
|
+
else
|
37
|
+
Maze::Plugins::DatadogMetricsPlugin.send_increment('appium.test_failed')
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
41
|
def at_exit
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative './request_list'
|
2
|
+
|
3
|
+
module Maze
|
4
|
+
class MetricsProcessor
|
5
|
+
# @param metrics [RequestList] The metrics to be processed
|
6
|
+
def initialize(metrics)
|
7
|
+
@metrics = metrics
|
8
|
+
@columns = Set.new
|
9
|
+
@rows = []
|
10
|
+
end
|
11
|
+
|
12
|
+
# Collates the metrics given into a CSV-friendly structure and writes the CSV to disk
|
13
|
+
def process
|
14
|
+
return if @metrics.size_all == 0
|
15
|
+
|
16
|
+
collate
|
17
|
+
write_to_disk
|
18
|
+
end
|
19
|
+
|
20
|
+
# Organises the raw metrics into an Array of hashes representing each row of the CSV,
|
21
|
+
# whilst also capturing an overall set of column headings
|
22
|
+
def collate
|
23
|
+
@metrics.all.each do |request|
|
24
|
+
row = {}
|
25
|
+
metric = request[:body]
|
26
|
+
metric.each do |key, value|
|
27
|
+
@columns.add key
|
28
|
+
row[key] = value
|
29
|
+
end
|
30
|
+
@rows << row
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def write_to_disk
|
35
|
+
filepath = File.join(Dir.pwd, 'maze_output', 'metrics.csv')
|
36
|
+
|
37
|
+
puts "Call with #{filepath}"
|
38
|
+
|
39
|
+
File.open(filepath, 'w') do |file|
|
40
|
+
# Write the header, with columns ordered alphabetically
|
41
|
+
sorted_columns = @columns.to_a.sort!
|
42
|
+
header = sorted_columns.join ','
|
43
|
+
file.puts header
|
44
|
+
|
45
|
+
# Write the rows
|
46
|
+
@rows.each do |row|
|
47
|
+
row_values = sorted_columns.map do |column|
|
48
|
+
if row.has_key? column
|
49
|
+
to_csv_friendly(row[column])
|
50
|
+
else
|
51
|
+
''
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
file.puts row_values.join ','
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_csv_friendly(value)
|
61
|
+
return value unless value.class == String
|
62
|
+
|
63
|
+
if value.include?(' ') || value.include?(',')
|
64
|
+
"\"#{value}\""
|
65
|
+
else
|
66
|
+
value
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'datadog/statsd'
|
4
|
+
|
5
|
+
module Maze
|
6
|
+
module Plugins
|
7
|
+
# Enables metrics to be reported to Datadog via a StatsD proxy
|
8
|
+
class DatadogMetricsPlugin
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# Sends a gauge metric to Datadog
|
12
|
+
#
|
13
|
+
# @param metric [String] The identifier of the metric
|
14
|
+
# @param value [Integer] The value of the metric
|
15
|
+
# @param tags [Array] An array of strings with which to tag the metric
|
16
|
+
def send_gauge(metric, value, tags=[])
|
17
|
+
return unless logging?
|
18
|
+
stats_dog.gauge(metric, value, tags: tags)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Sends an increment metric to Datadog
|
22
|
+
#
|
23
|
+
# @param metric [String] The identifier of the metric
|
24
|
+
# @param tags [Array] An array of strings with which to tag the metric
|
25
|
+
def send_increment(metric, tags=[])
|
26
|
+
return unless logging?
|
27
|
+
stats_dog.increment(metric, tags: tags)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Whether metrics should be delivered to Datadog
|
33
|
+
#
|
34
|
+
# @returns [Boolean] Whether metrics should be sent
|
35
|
+
def logging?
|
36
|
+
ENV['BUILDKITE']
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns or initialises the DogStatsD instance
|
40
|
+
#
|
41
|
+
# @returns [Datadog::Statsd] The DogStatsD instance
|
42
|
+
def stats_dog
|
43
|
+
@stats_dog ||= initialize_stats_dog
|
44
|
+
end
|
45
|
+
|
46
|
+
# Initializes the DogStatsD instance, connecting to the buildkite agent Datadog agent
|
47
|
+
#
|
48
|
+
# @returns [Datadog::Statsd] The newly created DogStatsD instance
|
49
|
+
def initialize_stats_dog
|
50
|
+
tags = []
|
51
|
+
tags << Maze.config.device.to_s if Maze.config.device
|
52
|
+
tags << Maze.config.farm.to_s if Maze.config.farm
|
53
|
+
@stats_dog = Datadog::Statsd.new(aws_instance_ip, 8125, tags: tags, namespace: 'maze-runner')
|
54
|
+
|
55
|
+
at_exit do
|
56
|
+
@stats_dog.close
|
57
|
+
end
|
58
|
+
|
59
|
+
@stats_dog
|
60
|
+
end
|
61
|
+
|
62
|
+
# Retrieves the internal ipv4 address of the AWS buildkite instance the maze-runner container is run upon
|
63
|
+
#
|
64
|
+
# @returns [String] The local ipv4 address the Datadog agent is running on
|
65
|
+
def aws_instance_ip
|
66
|
+
`curl --silent -XGET http://169.254.169.254/latest/meta-data/local-ipv4`
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/maze/request_list.rb
CHANGED
data/lib/maze/server.rb
CHANGED
@@ -83,6 +83,8 @@ module Maze
|
|
83
83
|
builds
|
84
84
|
when 'log', 'logs'
|
85
85
|
logs
|
86
|
+
when 'metric', 'metrics'
|
87
|
+
metrics
|
86
88
|
when 'trace', 'traces'
|
87
89
|
traces
|
88
90
|
when 'upload', 'uploads'
|
@@ -145,6 +147,13 @@ module Maze
|
|
145
147
|
@logs ||= RequestList.new
|
146
148
|
end
|
147
149
|
|
150
|
+
# A list of metric requests received
|
151
|
+
#
|
152
|
+
# @return [RequestList] Received metric requests
|
153
|
+
def metrics
|
154
|
+
@metrics ||= RequestList.new
|
155
|
+
end
|
156
|
+
|
148
157
|
# A list of commands for a test fixture to perform. Strictly speaking these are responses to HTTP
|
149
158
|
# requests, but the list behavior is all we need.
|
150
159
|
#
|
@@ -202,6 +211,7 @@ module Maze
|
|
202
211
|
server.mount '/react-native-source-map', Servlets::Servlet, :sourcemaps
|
203
212
|
server.mount '/command', Servlets::CommandServlet
|
204
213
|
server.mount '/logs', Servlets::LogServlet
|
214
|
+
server.mount '/metrics', Servlets::Servlet, :metrics
|
205
215
|
server.mount '/reflect', Servlets::ReflectiveServlet
|
206
216
|
server.start
|
207
217
|
rescue StandardError => e
|
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.25.0'
|
11
11
|
|
12
12
|
class << self
|
13
13
|
attr_accessor :check, :driver, :internal_hooks, :mode, :start_time, :dynamic_retry, :public_address, :run_uuid
|
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.25.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-
|
11
|
+
date: 2023-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 0.9.6
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: dogstatsd-ruby
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 5.5.0
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 5.5.0
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: optimist
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -394,6 +408,7 @@ files:
|
|
394
408
|
- lib/maze/logger.rb
|
395
409
|
- lib/maze/macos_utils.rb
|
396
410
|
- lib/maze/maze_output.rb
|
411
|
+
- lib/maze/metrics_processor.rb
|
397
412
|
- lib/maze/network.rb
|
398
413
|
- lib/maze/option.rb
|
399
414
|
- lib/maze/option/parser.rb
|
@@ -401,6 +416,7 @@ files:
|
|
401
416
|
- lib/maze/option/validator.rb
|
402
417
|
- lib/maze/plugins/bugsnag_reporting_plugin.rb
|
403
418
|
- lib/maze/plugins/cucumber_report_plugin.rb
|
419
|
+
- lib/maze/plugins/datadog_metrics_plugin.rb
|
404
420
|
- lib/maze/plugins/error_code_plugin.rb
|
405
421
|
- lib/maze/plugins/global_retry_plugin.rb
|
406
422
|
- lib/maze/proxy.rb
|