datadog-ci 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -1
- data/README.md +36 -36
- data/lib/datadog/ci/configuration/components.rb +51 -25
- data/lib/datadog/ci/context/local.rb +50 -0
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +23 -29
- data/lib/datadog/ci/contrib/minitest/hooks.rb +16 -25
- data/lib/datadog/ci/contrib/rspec/example.rb +14 -18
- data/lib/datadog/ci/ext/environment/extractor.rb +5 -10
- data/lib/datadog/ci/ext/environment/providers/appveyor.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/aws_code_pipeline.rb +39 -0
- data/lib/datadog/ci/ext/environment/providers/azure.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/base.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/bitbucket.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/bitrise.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/buddy.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/buildkite.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/circleci.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/codefresh.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/github_actions.rb +17 -4
- data/lib/datadog/ci/ext/environment/providers/gitlab.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/jenkins.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/teamcity.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers/travis.rb +4 -0
- data/lib/datadog/ci/ext/environment/providers.rb +16 -14
- data/lib/datadog/ci/ext/transport.rb +5 -0
- data/lib/datadog/ci/recorder.rb +82 -46
- data/lib/datadog/ci/span.rb +107 -0
- data/lib/datadog/ci/test.rb +26 -0
- data/lib/datadog/ci/test_visibility/transport.rb +11 -29
- data/lib/datadog/ci/transport/api/base.rb +36 -0
- data/lib/datadog/ci/transport/api/builder.rb +46 -0
- data/lib/datadog/ci/transport/api/ci_test_cycle.rb +30 -0
- data/lib/datadog/ci/transport/api/evp_proxy.rb +44 -0
- data/lib/datadog/ci/transport/gzip.rb +4 -2
- data/lib/datadog/ci/transport/http.rb +25 -101
- data/lib/datadog/ci/utils/url.rb +15 -0
- data/lib/datadog/ci/version.rb +1 -1
- data/lib/datadog/ci.rb +193 -4
- data/sig/datadog/ci/configuration/components.rbs +7 -1
- data/sig/datadog/ci/context/local.rbs +21 -0
- data/sig/datadog/ci/ext/environment/extractor.rbs +0 -2
- data/sig/datadog/ci/ext/environment/providers/aws_code_pipeline.rbs +19 -0
- data/sig/datadog/ci/ext/environment/providers/base.rbs +2 -0
- data/sig/datadog/ci/ext/environment/providers/github_actions.rbs +5 -0
- data/sig/datadog/ci/ext/environment/providers.rbs +1 -1
- data/sig/datadog/ci/ext/transport.rbs +8 -0
- data/sig/datadog/ci/recorder.rbs +20 -8
- data/sig/datadog/ci/span.rbs +35 -0
- data/sig/datadog/ci/test.rbs +7 -0
- data/sig/datadog/ci/test_visibility/transport.rbs +7 -11
- data/sig/datadog/ci/transport/api/base.rbs +21 -0
- data/sig/datadog/ci/transport/api/builder.rbs +12 -0
- data/sig/datadog/ci/transport/api/ci_test_cycle.rbs +21 -0
- data/sig/datadog/ci/transport/api/evp_proxy.rbs +19 -0
- data/sig/datadog/ci/transport/http.rbs +12 -37
- data/sig/datadog/ci/utils/url.rbs +9 -0
- data/sig/datadog/ci.rbs +15 -3
- metadata +21 -3
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../ext/transport"
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module CI
|
7
|
+
module Transport
|
8
|
+
module Api
|
9
|
+
class Base
|
10
|
+
attr_reader :http
|
11
|
+
|
12
|
+
def initialize(http:)
|
13
|
+
@http = http
|
14
|
+
end
|
15
|
+
|
16
|
+
def request(path:, payload:, verb: "post")
|
17
|
+
http.request(
|
18
|
+
path: path,
|
19
|
+
payload: payload,
|
20
|
+
verb: verb,
|
21
|
+
headers: headers
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def headers
|
28
|
+
{
|
29
|
+
Ext::Transport::HEADER_CONTENT_TYPE => Ext::Transport::CONTENT_TYPE_MESSAGEPACK
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "ci_test_cycle"
|
4
|
+
require_relative "evp_proxy"
|
5
|
+
require_relative "../http"
|
6
|
+
require_relative "../../ext/transport"
|
7
|
+
|
8
|
+
module Datadog
|
9
|
+
module CI
|
10
|
+
module Transport
|
11
|
+
module Api
|
12
|
+
module Builder
|
13
|
+
def self.build_ci_test_cycle_api(settings)
|
14
|
+
dd_site = settings.site || Ext::Transport::DEFAULT_DD_SITE
|
15
|
+
url = settings.ci.agentless_url ||
|
16
|
+
"https://#{Ext::Transport::TEST_VISIBILITY_INTAKE_HOST_PREFIX}.#{dd_site}:443"
|
17
|
+
|
18
|
+
uri = URI.parse(url)
|
19
|
+
raise "Invalid agentless mode URL: #{url}" if uri.host.nil?
|
20
|
+
|
21
|
+
http = Datadog::CI::Transport::HTTP.new(
|
22
|
+
host: uri.host,
|
23
|
+
port: uri.port,
|
24
|
+
ssl: uri.scheme == "https" || uri.port == 443,
|
25
|
+
compress: true
|
26
|
+
)
|
27
|
+
|
28
|
+
CiTestCycle.new(api_key: settings.api_key, http: http)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.build_evp_proxy_api(agent_settings)
|
32
|
+
http = Datadog::CI::Transport::HTTP.new(
|
33
|
+
host: agent_settings.hostname,
|
34
|
+
port: agent_settings.port,
|
35
|
+
ssl: agent_settings.ssl,
|
36
|
+
timeout: agent_settings.timeout_seconds,
|
37
|
+
compress: false
|
38
|
+
)
|
39
|
+
|
40
|
+
EvpProxy.new(http: http)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
require_relative "../../ext/transport"
|
5
|
+
|
6
|
+
module Datadog
|
7
|
+
module CI
|
8
|
+
module Transport
|
9
|
+
module Api
|
10
|
+
class CiTestCycle < Base
|
11
|
+
attr_reader :api_key
|
12
|
+
|
13
|
+
def initialize(api_key:, http:)
|
14
|
+
@api_key = api_key
|
15
|
+
|
16
|
+
super(http: http)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def headers
|
22
|
+
headers = super
|
23
|
+
headers[Ext::Transport::HEADER_DD_API_KEY] = api_key
|
24
|
+
headers
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "datadog/core/environment/container"
|
4
|
+
|
5
|
+
require_relative "base"
|
6
|
+
require_relative "../../ext/transport"
|
7
|
+
|
8
|
+
module Datadog
|
9
|
+
module CI
|
10
|
+
module Transport
|
11
|
+
module Api
|
12
|
+
class EvpProxy < Base
|
13
|
+
def request(path:, payload:, verb: "post")
|
14
|
+
path = "#{Ext::Transport::EVP_PROXY_PATH_PREFIX}#{path.sub(/^\//, "")}"
|
15
|
+
|
16
|
+
super(
|
17
|
+
path: path,
|
18
|
+
payload: payload,
|
19
|
+
verb: verb
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def container_id
|
26
|
+
return @container_id if defined?(@container_id)
|
27
|
+
|
28
|
+
@container_id = Datadog::Core::Environment::Container.container_id
|
29
|
+
end
|
30
|
+
|
31
|
+
def headers
|
32
|
+
headers = super
|
33
|
+
headers[Ext::Transport::HEADER_EVP_SUBDOMAIN] = Ext::Transport::TEST_VISIBILITY_INTAKE_HOST_PREFIX
|
34
|
+
|
35
|
+
c_id = container_id
|
36
|
+
headers[Ext::Transport::HEADER_CONTAINER_ID] = c_id unless c_id.nil?
|
37
|
+
|
38
|
+
headers
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -10,9 +10,11 @@ module Datadog
|
|
10
10
|
module_function
|
11
11
|
|
12
12
|
def compress(input)
|
13
|
-
|
13
|
+
sio = StringIO.new
|
14
|
+
gzip_writer = Zlib::GzipWriter.new(sio, Zlib::DEFAULT_COMPRESSION, Zlib::DEFAULT_STRATEGY)
|
14
15
|
gzip_writer << input
|
15
|
-
gzip_writer.close
|
16
|
+
gzip_writer.close
|
17
|
+
sio.string
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "delegate"
|
4
|
+
require "datadog/core/transport/http/adapters/net"
|
5
|
+
require "datadog/core/transport/http/env"
|
6
|
+
require "datadog/core/transport/request"
|
4
7
|
|
5
8
|
require_relative "gzip"
|
6
9
|
require_relative "../ext/transport"
|
@@ -26,126 +29,47 @@ module Datadog
|
|
26
29
|
@compress = compress.nil? ? false : compress
|
27
30
|
end
|
28
31
|
|
29
|
-
def request(path:, payload:, headers:,
|
30
|
-
raise "Unknown method #{method}" unless respond_to?(method, true)
|
31
|
-
|
32
|
+
def request(path:, payload:, headers:, verb: "post")
|
32
33
|
if compress
|
33
34
|
headers[Ext::Transport::HEADER_CONTENT_ENCODING] = Ext::Transport::CONTENT_ENCODING_GZIP
|
34
35
|
payload = Gzip.compress(payload)
|
35
36
|
end
|
36
37
|
|
37
38
|
Datadog.logger.debug do
|
38
|
-
"Sending #{
|
39
|
+
"Sending #{verb} request: host=#{host}; port=#{port}; ssl_enabled=#{ssl}; " \
|
39
40
|
"compression_enabled=#{compress}; path=#{path}; payload_size=#{payload.size}"
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
+
ResponseDecorator.new(
|
44
|
+
adapter.call(
|
45
|
+
build_env(path: path, payload: payload, headers: headers, verb: verb)
|
46
|
+
)
|
47
|
+
)
|
43
48
|
end
|
44
49
|
|
45
50
|
private
|
46
51
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
def build_env(path:, payload:, headers:, verb:)
|
53
|
+
env = Datadog::Core::Transport::HTTP::Env.new(
|
54
|
+
Datadog::Core::Transport::Request.new
|
55
|
+
)
|
56
|
+
env.body = payload
|
57
|
+
env.path = path
|
58
|
+
env.headers = headers
|
59
|
+
env.verb = verb
|
60
|
+
env
|
54
61
|
end
|
55
62
|
|
56
|
-
def
|
57
|
-
|
58
|
-
post.body = payload
|
59
|
-
|
60
|
-
http_response = open do |http|
|
61
|
-
http.request(post)
|
62
|
-
end
|
63
|
-
|
64
|
-
Response.new(http_response)
|
65
|
-
rescue => e
|
66
|
-
Datadog.logger.debug("Unable to send events: #{e}")
|
67
|
-
|
68
|
-
InternalErrorResponse.new(e)
|
63
|
+
def adapter
|
64
|
+
@adapter ||= Datadog::Core::Transport::HTTP::Adapters::Net.new(host, port, timeout: timeout, ssl: ssl)
|
69
65
|
end
|
70
66
|
|
71
|
-
#
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
def initialize(http_response)
|
76
|
-
@http_response = http_response
|
77
|
-
end
|
78
|
-
|
79
|
-
def payload
|
80
|
-
http_response.body
|
81
|
-
end
|
82
|
-
|
83
|
-
def code
|
84
|
-
http_response.code.to_i
|
85
|
-
end
|
86
|
-
|
87
|
-
def ok?
|
88
|
-
code.between?(200, 299)
|
89
|
-
end
|
90
|
-
|
91
|
-
def unsupported?
|
92
|
-
code == 415
|
93
|
-
end
|
94
|
-
|
95
|
-
def not_found?
|
96
|
-
code == 404
|
97
|
-
end
|
98
|
-
|
99
|
-
def client_error?
|
100
|
-
code.between?(400, 499)
|
101
|
-
end
|
102
|
-
|
103
|
-
def server_error?
|
104
|
-
code.between?(500, 599)
|
105
|
-
end
|
106
|
-
|
107
|
-
def internal_error?
|
108
|
-
false
|
109
|
-
end
|
110
|
-
|
67
|
+
# this is needed because Datadog::Tracing::Writer is not fully compatiple with Datadog::Core::Transport
|
68
|
+
# TODO: remove before 1.0 when CI implements its own worker
|
69
|
+
class ResponseDecorator < ::SimpleDelegator
|
111
70
|
def trace_count
|
112
71
|
0
|
113
72
|
end
|
114
|
-
|
115
|
-
def inspect
|
116
|
-
"#{self.class} ok?:#{ok?} unsupported?:#{unsupported?}, " \
|
117
|
-
"not_found?:#{not_found?}, client_error?:#{client_error?}, " \
|
118
|
-
"server_error?:#{server_error?}, internal_error?:#{internal_error?}, " \
|
119
|
-
"payload:#{payload}"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
class InternalErrorResponse < Response
|
124
|
-
class DummyNetHTTPResponse
|
125
|
-
def body
|
126
|
-
""
|
127
|
-
end
|
128
|
-
|
129
|
-
def code
|
130
|
-
"-1"
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
attr_reader :error
|
135
|
-
|
136
|
-
def initialize(error)
|
137
|
-
super(DummyNetHTTPResponse.new)
|
138
|
-
|
139
|
-
@error = error
|
140
|
-
end
|
141
|
-
|
142
|
-
def internal_error?
|
143
|
-
true
|
144
|
-
end
|
145
|
-
|
146
|
-
def inspect
|
147
|
-
"#{super}, error_class:#{error.class}, error:#{error}"
|
148
|
-
end
|
149
73
|
end
|
150
74
|
end
|
151
75
|
end
|
data/lib/datadog/ci/version.rb
CHANGED
data/lib/datadog/ci.rb
CHANGED
@@ -5,11 +5,200 @@ require_relative "ci/version"
|
|
5
5
|
require "datadog/core"
|
6
6
|
|
7
7
|
module Datadog
|
8
|
-
#
|
9
|
-
#
|
8
|
+
# Datadog CI visibility public API.
|
9
|
+
#
|
10
|
+
# @public_api
|
10
11
|
module CI
|
11
|
-
class
|
12
|
-
|
12
|
+
class << self
|
13
|
+
# Return a {Datadog::CI::Test ci_test} that will trace a test called `test_name`.
|
14
|
+
# Raises an error if a test is already active.
|
15
|
+
#
|
16
|
+
# You could trace your test using a <tt>do-block</tt> like:
|
17
|
+
#
|
18
|
+
# ```
|
19
|
+
# Datadog::CI.trace_test(
|
20
|
+
# "test_add_two_numbers",
|
21
|
+
# service_name: "my-web-site-tests",
|
22
|
+
# operation_name: "test",
|
23
|
+
# tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
|
24
|
+
# ) do |ci_test|
|
25
|
+
# result = run_test
|
26
|
+
#
|
27
|
+
# if result.ok?
|
28
|
+
# ci_test.passed!
|
29
|
+
# else
|
30
|
+
# ci_test.failed!(exception: result.exception)
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
# ```
|
34
|
+
#
|
35
|
+
# The {#trace_test} method can also be used without a block in this way:
|
36
|
+
# ```
|
37
|
+
# ci_test = Datadog::CI.trace_test(
|
38
|
+
# "test_add_two_numbers',
|
39
|
+
# service: "my-web-site-tests",
|
40
|
+
# operation_name: "test",
|
41
|
+
# tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
|
42
|
+
# )
|
43
|
+
# run_test
|
44
|
+
# ci_test.finish
|
45
|
+
# ```
|
46
|
+
#
|
47
|
+
# Remember that in this case, calling {Datadog::CI::Test#finish} is mandatory.
|
48
|
+
#
|
49
|
+
# @param [String] test_name {Datadog::CI::Test} name (example: "test_add_two_numbers").
|
50
|
+
# @param [String] operation_name defines label for a test span in trace view ("test" if it's missing)
|
51
|
+
# @param [String] service_name the service name for this test
|
52
|
+
# @param [Hash<String,String>] tags extra tags which should be added to the test.
|
53
|
+
# @return [Object] If a block is provided, returns the result of the block execution.
|
54
|
+
# @return [Datadog::CI::Test] If no block is provided, returns the active,
|
55
|
+
# unfinished {Datadog::CI::Test}.
|
56
|
+
# @yield Optional block where new newly created {Datadog::CI::Test} captures the execution.
|
57
|
+
# @yieldparam [Datadog::CI::Test] ci_test the newly created and active [Datadog::CI::Test]
|
58
|
+
#
|
59
|
+
# @public_api
|
60
|
+
def trace_test(test_name, service_name: nil, operation_name: "test", tags: {}, &block)
|
61
|
+
recorder.trace_test(test_name, service_name: service_name, operation_name: operation_name, tags: tags, &block)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Same as {#trace_test} but it does not accept a block.
|
65
|
+
# Raises an error if a test is already active.
|
66
|
+
#
|
67
|
+
# Usage:
|
68
|
+
#
|
69
|
+
# ```
|
70
|
+
# ci_test = Datadog::CI.start_test(
|
71
|
+
# "test_add_two_numbers',
|
72
|
+
# service: "my-web-site-tests",
|
73
|
+
# operation_name: "test",
|
74
|
+
# tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
|
75
|
+
# )
|
76
|
+
# run_test
|
77
|
+
# ci_test.finish
|
78
|
+
# ```
|
79
|
+
#
|
80
|
+
# @param [String] test_name {Datadog::CI::Test} name (example: "test_add_two_numbers").
|
81
|
+
# @param [String] operation_name the resource this span refers, or `test` if it's missing
|
82
|
+
# @param [String] service_name the service name for this span.
|
83
|
+
# @param [Hash<String,String>] tags extra tags which should be added to the test.
|
84
|
+
# @return [Datadog::CI::Test] Returns the active, unfinished {Datadog::CI::Test}.
|
85
|
+
#
|
86
|
+
# @public_api
|
87
|
+
def start_test(test_name, service_name: nil, operation_name: "test", tags: {})
|
88
|
+
recorder.trace_test(test_name, service_name: service_name, operation_name: operation_name, tags: tags)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Trace any custom span inside a test. For example, you could trace:
|
92
|
+
# - cucumber step
|
93
|
+
# - database query
|
94
|
+
# - any custom operation you want to see in your trace view
|
95
|
+
#
|
96
|
+
# You can use thi method with a <tt>do-block</tt> like:
|
97
|
+
#
|
98
|
+
# ```
|
99
|
+
# Datadog::CI.trace(
|
100
|
+
# "step",
|
101
|
+
# "Given I have 42 cucumbers",
|
102
|
+
# tags: {}
|
103
|
+
# ) do
|
104
|
+
# run_operation
|
105
|
+
# end
|
106
|
+
# ```
|
107
|
+
#
|
108
|
+
# The {#trace} method can also be used without a block in this way:
|
109
|
+
# ```
|
110
|
+
# ci_span = Datadog::CI.trace(
|
111
|
+
# "step",
|
112
|
+
# "Given I have 42 cucumbers",
|
113
|
+
# tags: {}
|
114
|
+
# )
|
115
|
+
# run_test
|
116
|
+
# ci_span.finish
|
117
|
+
# ```
|
118
|
+
# Remember that in this case, calling {Datadog::CI::Span#finish} is mandatory.
|
119
|
+
#
|
120
|
+
# @param [String] span_type custom, user-defined span type (for example "step" or "query").
|
121
|
+
# @param [String] span_name the resource this span refers, or `test` if it's missing
|
122
|
+
# @param [Hash<String,String>] tags extra tags which should be added to the span.
|
123
|
+
# @return [Object] If a block is provided, returns the result of the block execution.
|
124
|
+
# @return [Datadog::CI::Span] If no block is provided, returns the active,
|
125
|
+
# unfinished {Datadog::CI::Span}.
|
126
|
+
# @yield Optional block where new newly created {Datadog::CI::Span} captures the execution.
|
127
|
+
# @yieldparam [Datadog::CI::Span] ci_span the newly created and active [Datadog::CI::Span]
|
128
|
+
#
|
129
|
+
# @public_api
|
130
|
+
def trace(span_type, span_name, tags: {}, &block)
|
131
|
+
recorder.trace(span_type, span_name, tags: tags, &block)
|
132
|
+
end
|
133
|
+
|
134
|
+
# The active, unfinished custom span if it matches given type.
|
135
|
+
# If no span is active, or if the active span is not a custom span with given type, returns nil.
|
136
|
+
#
|
137
|
+
# The active span belongs to an {.active_test}.
|
138
|
+
#
|
139
|
+
# Usage:
|
140
|
+
#
|
141
|
+
# ```
|
142
|
+
# # start span
|
143
|
+
# Datadog::CI.trace(
|
144
|
+
# "step",
|
145
|
+
# "Given I have 42 cucumbers",
|
146
|
+
# tags: {}
|
147
|
+
# )
|
148
|
+
#
|
149
|
+
# # somewhere else, access the active "step" span
|
150
|
+
# step_span = Datadog::CI.active_span("step")
|
151
|
+
# step_span.finish()
|
152
|
+
# ```
|
153
|
+
#
|
154
|
+
# @param [String] span_type type of the span to retrieve (for example "step" or "query") that was provided to {.trace}
|
155
|
+
# @return [Datadog::CI::Span] the active span
|
156
|
+
# @return [nil] if no span is active, or if the active span is not a custom span with given type
|
157
|
+
def active_span(span_type)
|
158
|
+
span = recorder.active_span
|
159
|
+
span if span && span.span_type == span_type
|
160
|
+
end
|
161
|
+
|
162
|
+
# The active, unfinished test span.
|
163
|
+
#
|
164
|
+
# Usage:
|
165
|
+
#
|
166
|
+
# ```
|
167
|
+
# # start a test
|
168
|
+
# Datadog::CI.start_test(
|
169
|
+
# "test_add_two_numbers',
|
170
|
+
# service: "my-web-site-tests",
|
171
|
+
# operation_name: "test",
|
172
|
+
# tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
|
173
|
+
# )
|
174
|
+
#
|
175
|
+
# # somewhere else, access the active test
|
176
|
+
# test_span = Datadog::CI.active_test
|
177
|
+
# test_span.passed!
|
178
|
+
# test_span.finish
|
179
|
+
# ```
|
180
|
+
#
|
181
|
+
# @return [Datadog::CI::Test] the active test
|
182
|
+
# @return [nil] if no test is active
|
183
|
+
def active_test
|
184
|
+
recorder.active_test
|
185
|
+
end
|
186
|
+
|
187
|
+
# Internal only, to finish a test use Datadog::CI::Test#finish
|
188
|
+
def deactivate_test(test)
|
189
|
+
recorder.deactivate_test(test)
|
190
|
+
end
|
191
|
+
|
192
|
+
private
|
193
|
+
|
194
|
+
def components
|
195
|
+
Datadog.send(:components)
|
196
|
+
end
|
197
|
+
|
198
|
+
def recorder
|
199
|
+
components.ci_recorder
|
200
|
+
end
|
201
|
+
end
|
13
202
|
end
|
14
203
|
end
|
15
204
|
|
@@ -2,11 +2,17 @@ module Datadog
|
|
2
2
|
module CI
|
3
3
|
module Configuration
|
4
4
|
module Components : Datadog::Core::Configuration::Components
|
5
|
+
@ci_recorder: Datadog::CI::Recorder
|
6
|
+
|
7
|
+
attr_reader ci_recorder: Datadog::CI::Recorder
|
8
|
+
|
5
9
|
def initialize: (untyped settings) -> void
|
6
10
|
|
7
11
|
def activate_ci!: (untyped settings) -> untyped
|
8
12
|
|
9
|
-
def build_agentless_transport: (untyped settings) -> Datadog::CI::TestVisibility::Transport
|
13
|
+
def build_agentless_transport: (untyped settings) -> Datadog::CI::TestVisibility::Transport?
|
14
|
+
def build_evp_proxy_transport: (untyped settings, untyped agent_settings) -> Datadog::CI::TestVisibility::Transport
|
15
|
+
def can_use_evp_proxy?: (untyped settings, untyped agent_settings) -> bool
|
10
16
|
end
|
11
17
|
end
|
12
18
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Datadog
|
2
|
+
module CI
|
3
|
+
module Context
|
4
|
+
class Local
|
5
|
+
@key: Symbol
|
6
|
+
|
7
|
+
def initialize: () -> void
|
8
|
+
|
9
|
+
def activate_test!: (Datadog::CI::Test test) ?{ () -> untyped } -> void
|
10
|
+
|
11
|
+
def deactivate_test!: (Datadog::CI::Test test) -> void
|
12
|
+
|
13
|
+
def active_test: () -> Datadog::CI::Test?
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def active_test=: (Datadog::CI::Test? test) -> untyped
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Datadog
|
2
|
+
module CI
|
3
|
+
module Ext
|
4
|
+
module Environment
|
5
|
+
module Providers
|
6
|
+
class AwsCodePipeline < Base
|
7
|
+
def self.handles?: (Hash[String, String?] env) -> bool
|
8
|
+
|
9
|
+
def provider_name: () -> "awscodepipeline"
|
10
|
+
|
11
|
+
def pipeline_id: () -> String?
|
12
|
+
|
13
|
+
def ci_env_vars: () -> String?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -5,6 +5,7 @@ module Datadog
|
|
5
5
|
module Providers
|
6
6
|
class GithubActions < Extractor
|
7
7
|
@ref: String
|
8
|
+
@github_server_url: String?
|
8
9
|
|
9
10
|
def provider_name: () -> "github"
|
10
11
|
|
@@ -29,6 +30,10 @@ module Datadog
|
|
29
30
|
def git_branch_or_tag: () -> String?
|
30
31
|
|
31
32
|
def ci_env_vars: () -> String?
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def github_server_url: () -> String?
|
32
37
|
end
|
33
38
|
end
|
34
39
|
end
|