datadog-ci 0.4.1 → 0.5.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -1
  3. data/README.md +26 -3
  4. data/lib/datadog/ci/concurrent_span.rb +59 -0
  5. data/lib/datadog/ci/configuration/components.rb +33 -3
  6. data/lib/datadog/ci/configuration/settings.rb +7 -1
  7. data/lib/datadog/ci/context/global.rb +80 -0
  8. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +12 -1
  9. data/lib/datadog/ci/contrib/cucumber/formatter.rb +3 -4
  10. data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +10 -1
  11. data/lib/datadog/ci/contrib/minitest/hooks.rb +3 -4
  12. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +10 -1
  13. data/lib/datadog/ci/contrib/rspec/example.rb +3 -4
  14. data/lib/datadog/ci/contrib/settings.rb +2 -0
  15. data/lib/datadog/ci/ext/app_types.rb +5 -0
  16. data/lib/datadog/ci/ext/settings.rb +11 -0
  17. data/lib/datadog/ci/ext/test.rb +12 -1
  18. data/lib/datadog/ci/null_span.rb +63 -0
  19. data/lib/datadog/ci/recorder.rb +207 -35
  20. data/lib/datadog/ci/span.rb +13 -3
  21. data/lib/datadog/ci/test.rb +0 -1
  22. data/lib/datadog/ci/test_module.rb +23 -0
  23. data/lib/datadog/ci/test_session.rb +36 -0
  24. data/lib/datadog/ci/test_suite.rb +25 -0
  25. data/lib/datadog/ci/test_visibility/serializers/base.rb +100 -12
  26. data/lib/datadog/ci/test_visibility/serializers/factories/test_suite_level.rb +37 -0
  27. data/lib/datadog/ci/test_visibility/serializers/span.rb +2 -16
  28. data/lib/datadog/ci/test_visibility/serializers/test_module.rb +46 -0
  29. data/lib/datadog/ci/test_visibility/serializers/test_session.rb +46 -0
  30. data/lib/datadog/ci/test_visibility/serializers/test_suite.rb +46 -0
  31. data/lib/datadog/ci/test_visibility/serializers/test_v1.rb +3 -17
  32. data/lib/datadog/ci/test_visibility/serializers/test_v2.rb +38 -0
  33. data/lib/datadog/ci/test_visibility/transport.rb +4 -4
  34. data/lib/datadog/ci/utils/test_run.rb +15 -0
  35. data/lib/datadog/ci/version.rb +2 -2
  36. data/lib/datadog/ci.rb +214 -32
  37. data/sig/datadog/ci/concurrent_span.rbs +23 -0
  38. data/sig/datadog/ci/configuration/components.rbs +2 -0
  39. data/sig/datadog/ci/context/global.rbs +37 -0
  40. data/sig/datadog/ci/ext/app_types.rbs +6 -1
  41. data/sig/datadog/ci/ext/settings.rbs +3 -0
  42. data/sig/datadog/ci/ext/test.rbs +15 -0
  43. data/sig/datadog/ci/null_span.rbs +37 -0
  44. data/sig/datadog/ci/recorder.rbs +54 -1
  45. data/sig/datadog/ci/span.rbs +4 -0
  46. data/sig/datadog/ci/test_module.rbs +6 -0
  47. data/sig/datadog/ci/test_session.rbs +9 -0
  48. data/sig/datadog/ci/test_suite.rbs +6 -0
  49. data/sig/datadog/ci/test_visibility/serializers/base.rbs +26 -5
  50. data/sig/datadog/ci/test_visibility/serializers/factories/test_suite_level.rbs +13 -0
  51. data/sig/datadog/ci/test_visibility/serializers/test_module.rbs +26 -0
  52. data/sig/datadog/ci/test_visibility/serializers/test_session.rbs +26 -0
  53. data/sig/datadog/ci/test_visibility/serializers/test_suite.rbs +26 -0
  54. data/sig/datadog/ci/test_visibility/serializers/test_v1.rbs +1 -1
  55. data/sig/datadog/ci/test_visibility/serializers/test_v2.rbs +25 -0
  56. data/sig/datadog/ci/test_visibility/transport.rbs +3 -3
  57. data/sig/datadog/ci/utils/test_run.rbs +11 -0
  58. data/sig/datadog/ci.rbs +18 -2
  59. metadata +26 -2
data/lib/datadog/ci.rb CHANGED
@@ -10,16 +10,180 @@ module Datadog
10
10
  # @public_api
11
11
  module CI
12
12
  class << self
13
+ # Starts a {Datadog::CI::TestSession ci_test_session} that represents the whole test session run.
14
+ #
15
+ # Read Datadog documentation on test sessions
16
+ # [here](https://docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#sessions).
17
+ #
18
+ # Returns the existing test session if one is already active. There is at most a single test session per process.
19
+ #
20
+ # The {.start_test_session} method is used to mark the start of the test session:
21
+ # ```
22
+ # Datadog::CI.start_test_session(
23
+ # service: "my-web-site-tests",
24
+ # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
25
+ # )
26
+ #
27
+ # # Somewhere else after test run has ended
28
+ # Datadog::CI.active_test_session.finish
29
+ # ```
30
+ #
31
+ # Remember that calling {Datadog::CI::TestSession#finish} is mandatory.
32
+ #
33
+ # @param [String] service the service name for this session (optional, defaults to DD_SERVICE)
34
+ # @param [Hash<String,String>] tags extra tags which should be added to the test session.
35
+ # @return [Datadog::CI::TestSession] returns the active, running {Datadog::CI::TestSession}.
36
+ # @return [Datadog::CI::NullSpan] ci_span null object if CI visibility is disabled or if old Datadog agent is
37
+ # detected and test suite level visibility cannot be supported.
38
+ def start_test_session(service: nil, tags: {})
39
+ service ||= Datadog.configuration.service
40
+ recorder.start_test_session(service: service, tags: tags)
41
+ end
42
+
43
+ # The active, unfinished test session.
44
+ #
45
+ # Usage:
46
+ #
47
+ # ```
48
+ # # start a test session
49
+ # Datadog::CI.start_test_session(
50
+ # service: "my-web-site-tests",
51
+ # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
52
+ # )
53
+ #
54
+ # # somewhere else, access the session
55
+ # test_session = Datadog::CI.active_test_session
56
+ # test_session.finish
57
+ # ```
58
+ #
59
+ # @return [Datadog::CI::TestSession] the active test session
60
+ # @return [nil] if no test session is active
61
+ def active_test_session
62
+ recorder.active_test_session
63
+ end
64
+
65
+ # Starts a {Datadog::CI::TestModule ci_test_module} that represents a single test module (for most Ruby test frameworks
66
+ # module will correspond 1-1 to the test session).
67
+ #
68
+ # Read Datadog documentation on test modules
69
+ # [here](https://docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#module).
70
+ #
71
+ # Returns the existing test session if one is already active. There is at most a single test module per process
72
+ # active at any given time.
73
+ #
74
+ # The {.start_test_module} method is used to mark the start of the test session:
75
+ # ```
76
+ # Datadog::CI.start_test_module(
77
+ # "my-module",
78
+ # service: "my-web-site-tests",
79
+ # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
80
+ # )
81
+ #
82
+ # # Somewhere else after the module has ended
83
+ # Datadog::CI.active_test_module.finish
84
+ # ```
85
+ #
86
+ # Remember that calling {Datadog::CI::TestModule#finish} is mandatory.
87
+ #
88
+ # @param [String] test_module_name the name for this module
89
+ # @param [String] service the service name for this session (optional, inherited from test session if not provided)
90
+ # @param [Hash<String,String>] tags extra tags which should be added to the test module (optional, some tags are inherited from test session).
91
+ # @return [Datadog::CI::TestModule] returns the active, running {Datadog::CI::TestModule}.
92
+ # @return [Datadog::CI::NullSpan] ci_span null object if CI visibility is disabled or if old Datadog agent is
93
+ # detected and test suite level visibility cannot be supported.
94
+ def start_test_module(test_module_name, service: nil, tags: {})
95
+ recorder.start_test_module(test_module_name, service: service, tags: tags)
96
+ end
97
+
98
+ # The active, unfinished test module.
99
+ #
100
+ # Usage:
101
+ #
102
+ # ```
103
+ # # start a test module
104
+ # Datadog::CI.start_test_module(
105
+ # "my-module",
106
+ # service: "my-web-site-tests",
107
+ # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
108
+ # )
109
+ #
110
+ # # somewhere else, access the current module
111
+ # test_module = Datadog::CI.active_test_module
112
+ # test_module.finish
113
+ # ```
114
+ #
115
+ # @return [Datadog::CI::TestModule] the active test module
116
+ # @return [nil] if no test module is active
117
+ def active_test_module
118
+ recorder.active_test_module
119
+ end
120
+
121
+ # Starts a {Datadog::CI::TestSuite ci_test_suite} that represents a single test suite.
122
+ # If a test suite with given name is running, returns the existing test suite.
123
+ #
124
+ # Read Datadog documentation on test suites
125
+ # [here](https://docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#module).
126
+ #
127
+ # The {.start_test_suite} method is used to mark the start of a test suite:
128
+ # ```
129
+ # Datadog::CI.start_test_suite(
130
+ # "calculator_tests",
131
+ # service: "my-web-site-tests",
132
+ # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
133
+ # )
134
+ #
135
+ # # Somewhere else after the suite has ended
136
+ # Datadog::CI.active_test_suite("calculator_tests").finish
137
+ # ```
138
+ #
139
+ # Remember that calling {Datadog::CI::TestSuite#finish} is mandatory.
140
+ #
141
+ # @param [String] test_suite_name the name of the test suite
142
+ # @param [String] service the service name for this test suite (optional, inherited from test session if not provided)
143
+ # @param [Hash<String,String>] tags extra tags which should be added to the test module (optional, some tags are inherited from test session)
144
+ # @return [Datadog::CI::TestSuite] returns the active, running {Datadog::CI::TestSuite}.
145
+ # @return [Datadog::CI::NullSpan] ci_span null object if CI visibility is disabled or if old Datadog agent is
146
+ # detected and test suite level visibility cannot be supported.
147
+ def start_test_suite(test_suite_name, service: nil, tags: {})
148
+ recorder.start_test_suite(test_suite_name, service: service, tags: tags)
149
+ end
150
+
151
+ # The active, unfinished test suite.
152
+ #
153
+ # Usage:
154
+ #
155
+ # ```
156
+ # # start a test suite
157
+ # Datadog::CI.start_test_suite(
158
+ # "calculator_tests",
159
+ # service: "my-web-site-tests",
160
+ # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
161
+ # )
162
+ #
163
+ # # Somewhere else after the suite has ended
164
+ # test_suite = Datadog::CI.active_test_suite("calculator_tests")
165
+ # test_suite.finish
166
+ # ```
167
+ #
168
+ # @return [Datadog::CI::TestSuite] the active test suite
169
+ # @return [nil] if no test suite with given name is active
170
+ def active_test_suite(test_suite_name)
171
+ recorder.active_test_suite(test_suite_name)
172
+ end
173
+
13
174
  # Return a {Datadog::CI::Test ci_test} that will trace a test called `test_name`.
14
175
  # Raises an error if a test is already active.
176
+ # If there is an active test session, the new test will be connected to the session.
177
+ # The test will inherit service name and tags from the running test session if not provided
178
+ # in parameters.
15
179
  #
16
180
  # You could trace your test using a <tt>do-block</tt> like:
17
181
  #
18
182
  # ```
19
183
  # Datadog::CI.trace_test(
20
184
  # "test_add_two_numbers",
21
- # service_name: "my-web-site-tests",
22
- # operation_name: "test",
185
+ # "calculator_tests",
186
+ # service: "my-web-site-tests",
23
187
  # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
24
188
  # ) do |ci_test|
25
189
  # result = run_test
@@ -32,60 +196,59 @@ module Datadog
32
196
  # end
33
197
  # ```
34
198
  #
35
- # The {#trace_test} method can also be used without a block in this way:
199
+ # The {.trace_test} method can also be used without a block in this way:
36
200
  # ```
37
201
  # ci_test = Datadog::CI.trace_test(
38
- # "test_add_two_numbers',
202
+ # "test_add_two_numbers",
203
+ # "calculator_tests",
39
204
  # service: "my-web-site-tests",
40
- # operation_name: "test",
41
205
  # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
42
206
  # )
43
- # run_test
207
+ # # ... run test here ...
44
208
  # ci_test.finish
45
209
  # ```
46
210
  #
47
211
  # Remember that in this case, calling {Datadog::CI::Test#finish} is mandatory.
48
212
  #
49
213
  # @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
214
+ # @param [String] test_suite_name name of test suite this test belongs to (example: "CalculatorTest").
215
+ # @param [String] service the service name for this test (optional, inherited from test session if not provided)
52
216
  # @param [Hash<String,String>] tags extra tags which should be added to the test.
53
217
  # @return [Object] If a block is provided, returns the result of the block execution.
54
218
  # @return [Datadog::CI::Test] If no block is provided, returns the active,
55
219
  # unfinished {Datadog::CI::Test}.
56
- # @yield Optional block where new newly created {Datadog::CI::Test} captures the execution.
220
+ # @return [Datadog::CI::NullSpan] ci_span null object if CI visibility is disabled
221
+ # @yield Optional block where newly created {Datadog::CI::Test} captures the execution.
57
222
  # @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)
223
+ # @yieldparam [Datadog::CI::NullSpan] ci_span null object if CI visibility is disabled
224
+ def trace_test(test_name, test_suite_name, service: nil, tags: {}, &block)
225
+ recorder.trace_test(test_name, test_suite_name, service: service, tags: tags, &block)
62
226
  end
63
227
 
64
- # Same as {#trace_test} but it does not accept a block.
228
+ # Same as {.trace_test} but it does not accept a block.
65
229
  # Raises an error if a test is already active.
66
230
  #
67
231
  # Usage:
68
232
  #
69
233
  # ```
70
234
  # ci_test = Datadog::CI.start_test(
71
- # "test_add_two_numbers',
235
+ # "test_add_two_numbers",
236
+ # "calculator_tests",
72
237
  # service: "my-web-site-tests",
73
- # operation_name: "test",
74
238
  # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
75
239
  # )
76
- # run_test
240
+ # # ... run test here ...
77
241
  # ci_test.finish
78
242
  # ```
79
243
  #
80
244
  # @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.
245
+ # @param [String] test_suite_name name of test suite this test belongs to (example: "CalculatorTest").
246
+ # @param [String] service the service name for this span (optional, inherited from test session if not provided)
83
247
  # @param [Hash<String,String>] tags extra tags which should be added to the test.
84
248
  # @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)
249
+ # @return [Datadog::CI::NullSpan] ci_span null object if CI visibility is disabled
250
+ def start_test(test_name, test_suite_name, service: nil, tags: {})
251
+ recorder.trace_test(test_name, test_suite_name, service: service, tags: tags)
89
252
  end
90
253
 
91
254
  # Trace any custom span inside a test. For example, you could trace:
@@ -93,7 +256,7 @@ module Datadog
93
256
  # - database query
94
257
  # - any custom operation you want to see in your trace view
95
258
  #
96
- # You can use thi method with a <tt>do-block</tt> like:
259
+ # You can use this method with a <tt>do-block</tt> like:
97
260
  #
98
261
  # ```
99
262
  # Datadog::CI.trace(
@@ -105,14 +268,14 @@ module Datadog
105
268
  # end
106
269
  # ```
107
270
  #
108
- # The {#trace} method can also be used without a block in this way:
271
+ # The {.trace} method can also be used without a block in this way:
109
272
  # ```
110
273
  # ci_span = Datadog::CI.trace(
111
274
  # "step",
112
275
  # "Given I have 42 cucumbers",
113
276
  # tags: {}
114
277
  # )
115
- # run_test
278
+ # # ... run test here ...
116
279
  # ci_span.finish
117
280
  # ```
118
281
  # Remember that in this case, calling {Datadog::CI::Span#finish} is mandatory.
@@ -123,10 +286,10 @@ module Datadog
123
286
  # @return [Object] If a block is provided, returns the result of the block execution.
124
287
  # @return [Datadog::CI::Span] If no block is provided, returns the active,
125
288
  # unfinished {Datadog::CI::Span}.
126
- # @yield Optional block where new newly created {Datadog::CI::Span} captures the execution.
289
+ # @return [Datadog::CI::NullSpan] ci_span null object if CI visibility is disabled
290
+ # @yield Optional block where newly created {Datadog::CI::Span} captures the execution.
127
291
  # @yieldparam [Datadog::CI::Span] ci_span the newly created and active [Datadog::CI::Span]
128
- #
129
- # @public_api
292
+ # @yieldparam [Datadog::CI::NullSpan] ci_span null object if CI visibility is disabled
130
293
  def trace(span_type, span_name, tags: {}, &block)
131
294
  recorder.trace(span_type, span_name, tags: tags, &block)
132
295
  end
@@ -166,9 +329,9 @@ module Datadog
166
329
  # ```
167
330
  # # start a test
168
331
  # Datadog::CI.start_test(
169
- # "test_add_two_numbers',
332
+ # "test_add_two_numbers",
333
+ # "calculator_tests",
170
334
  # service: "my-web-site-tests",
171
- # operation_name: "test",
172
335
  # tags: { Datadog::CI::Ext::Test::TAG_FRAMEWORK => "my-test-framework" }
173
336
  # )
174
337
  #
@@ -184,11 +347,30 @@ module Datadog
184
347
  recorder.active_test
185
348
  end
186
349
 
187
- # Internal only, to finish a test use Datadog::CI::Test#finish
350
+ # Internal only, to finish a test use {Datadog::CI::Test#finish}
351
+ # @private
188
352
  def deactivate_test(test)
189
353
  recorder.deactivate_test(test)
190
354
  end
191
355
 
356
+ # Internal only, to finish a test session use {Datadog::CI::TestSession#finish}
357
+ # @private
358
+ def deactivate_test_session
359
+ recorder.deactivate_test_session
360
+ end
361
+
362
+ # Internal only, to finish a test module use {Datadog::CI::TestModule#finish}
363
+ # @private
364
+ def deactivate_test_module
365
+ recorder.deactivate_test_module
366
+ end
367
+
368
+ # Internal only, to finish a test suite use {Datadog::CI::TestSuite#finish}
369
+ # @private
370
+ def deactivate_test_suite(test_suite_name)
371
+ recorder.deactivate_test_suite(test_suite_name)
372
+ end
373
+
192
374
  private
193
375
 
194
376
  def components
@@ -0,0 +1,23 @@
1
+ module Datadog
2
+ module CI
3
+ class ConcurrentSpan < Span
4
+ @mutex: Thread::Mutex
5
+
6
+ def initialize: (Datadog::Tracing::SpanOperation tracer_span) -> void
7
+ def passed!: () -> void
8
+ def failed!: (?exception: untyped?) -> void
9
+ def skipped!: (?exception: untyped?, ?reason: String?) -> void
10
+ def get_tag: (String key) -> untyped?
11
+ def set_tag: (String key, untyped? value) -> void
12
+ def set_metric: (String key, untyped value) -> void
13
+ def finish: () -> void
14
+ def set_tags: (Hash[untyped, untyped] tags) -> void
15
+
16
+ def set_environment_runtime_tags: () -> void
17
+
18
+ def set_default_tags: () -> void
19
+
20
+ def synchronize: () { () -> untyped } -> untyped
21
+ end
22
+ end
23
+ end
@@ -13,6 +13,8 @@ module Datadog
13
13
  def build_agentless_transport: (untyped settings) -> Datadog::CI::TestVisibility::Transport?
14
14
  def build_evp_proxy_transport: (untyped settings, untyped agent_settings) -> Datadog::CI::TestVisibility::Transport
15
15
  def can_use_evp_proxy?: (untyped settings, untyped agent_settings) -> bool
16
+ def serializers_factory: (untyped settings) -> (singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel) | singleton(Datadog::CI::TestVisibility::Serializers::Factories::TestLevel))
17
+ def check_dd_site: (untyped settings) -> void
16
18
  end
17
19
  end
18
20
  end
@@ -0,0 +1,37 @@
1
+ module Datadog
2
+ module CI
3
+ module Context
4
+ class Global
5
+ @mutex: Thread::Mutex
6
+
7
+ @test_session: Datadog::CI::TestSession?
8
+ @test_module: Datadog::CI::TestModule?
9
+ @test_suites: Hash[String, Datadog::CI::TestSuite]
10
+
11
+ def initialize: () -> void
12
+
13
+ def fetch_or_activate_test_suite: (String test_suite_name) {() -> Datadog::CI::TestSuite} -> Datadog::CI::TestSuite
14
+
15
+ def fetch_or_activate_test_module: () {() -> Datadog::CI::TestModule} -> Datadog::CI::TestModule
16
+
17
+ def fetch_or_activate_test_session: () {() -> Datadog::CI::TestSession} -> Datadog::CI::TestSession
18
+
19
+ def active_test_session: () -> Datadog::CI::TestSession?
20
+
21
+ def active_test_suite: (String test_suite_name) -> Datadog::CI::TestSuite?
22
+
23
+ def service: () -> String?
24
+
25
+ def inheritable_session_tags: () -> Hash[untyped, untyped]
26
+
27
+ def active_test_module: () -> Datadog::CI::TestModule?
28
+
29
+ def deactivate_test_session!: () -> void
30
+
31
+ def deactivate_test_module!: () -> void
32
+
33
+ def deactivate_test_suite!: (String test_suite_name) -> void
34
+ end
35
+ end
36
+ end
37
+ end
@@ -2,7 +2,12 @@ module Datadog
2
2
  module CI
3
3
  module Ext
4
4
  module AppTypes
5
- TYPE_TEST: String
5
+ TYPE_TEST: "test"
6
+ TYPE_TEST_SESSION: "test_session_end"
7
+ TYPE_TEST_MODULE: "test_module_end"
8
+ TYPE_TEST_SUITE: "test_suite_end"
9
+
10
+ CI_SPAN_TYPES: Array[String]
6
11
  end
7
12
  end
8
13
  end
@@ -5,6 +5,9 @@ module Datadog
5
5
  ENV_MODE_ENABLED: String
6
6
  ENV_AGENTLESS_MODE_ENABLED: String
7
7
  ENV_AGENTLESS_URL: String
8
+ ENV_EXPERIMENTAL_TEST_SUITE_LEVEL_VISIBILITY_ENABLED: String
9
+
10
+ DD_SITE_ALLOWLIST: Array[String]
8
11
  end
9
12
  end
10
13
  end
@@ -18,9 +18,24 @@ module Datadog
18
18
 
19
19
  TAG_SUITE: String
20
20
 
21
+ TAG_MODULE: String
22
+
21
23
  TAG_TRAITS: String
22
24
 
23
25
  TAG_TYPE: String
26
+
27
+ TAG_COMMAND: String
28
+
29
+ TAG_TEST_SESSION_ID: String
30
+
31
+ TAG_TEST_MODULE_ID: String
32
+
33
+ TAG_TEST_SUITE_ID: String
34
+
35
+ SPECIAL_TAGS: Array[String]
36
+
37
+ INHERITABLE_TAGS: Array[String]
38
+
24
39
  TAG_OS_ARCHITECTURE: String
25
40
 
26
41
  TAG_OS_PLATFORM: String
@@ -0,0 +1,37 @@
1
+ module Datadog
2
+ module CI
3
+ class NullSpan < Span
4
+ def initialize: () -> void
5
+
6
+ def id: () -> nil
7
+
8
+ def name: () -> nil
9
+
10
+ def service: () -> nil
11
+
12
+ def span_type: () -> nil
13
+
14
+ def passed!: () -> nil
15
+
16
+ def failed!: (?exception: untyped?) -> nil
17
+
18
+ def skipped!: (?exception: untyped?, ?reason: untyped?) -> nil
19
+
20
+ def get_tag: (untyped key) -> nil
21
+
22
+ def set_tag: (untyped key, untyped value) -> nil
23
+
24
+ def set_metric: (untyped key, untyped value) -> nil
25
+
26
+ def finish: () -> nil
27
+
28
+ def set_tags: (untyped tags) -> nil
29
+
30
+ def set_environment_runtime_tags: () -> nil
31
+
32
+ def set_default_tags: () -> nil
33
+
34
+ def to_s: () -> untyped
35
+ end
36
+ end
37
+ end
@@ -1,21 +1,49 @@
1
1
  module Datadog
2
2
  module CI
3
3
  class Recorder
4
+ @test_suite_level_visibility_enabled: bool
5
+ @enabled: bool
6
+
4
7
  @environment_tags: Hash[String, String]
5
8
  @local_context: Datadog::CI::Context::Local
9
+ @global_context: Datadog::CI::Context::Global
10
+
11
+ @null_span: Datadog::CI::NullSpan
6
12
 
7
13
  attr_reader environment_tags: Hash[String, String]
14
+ attr_reader test_suite_level_visibility_enabled: bool
15
+ attr_reader enabled: bool
16
+
17
+ def initialize: (?enabled: bool, ?test_suite_level_visibility_enabled: bool) -> void
8
18
 
9
- def trace_test: (String span_name, ?service_name: String?, ?operation_name: String, ?tags: Hash[untyped, untyped]) ?{ (Datadog::CI::Test span) -> untyped } -> untyped
19
+ def trace_test: (String span_name, String test_suite_name, ?service: String?, ?tags: Hash[untyped, untyped]) ?{ (Datadog::CI::Span span) -> untyped } -> untyped
10
20
 
11
21
  def trace: (String span_type, String span_name, ?tags: Hash[untyped, untyped]) ?{ (Datadog::CI::Span span) -> untyped } -> untyped
12
22
 
23
+ def start_test_session: (?service: String?, ?tags: Hash[untyped, untyped]) -> Datadog::CI::Span
24
+
25
+ def start_test_module: (String test_module_name, ?service: String?, ?tags: Hash[untyped, untyped]) -> Datadog::CI::Span
26
+
27
+ def start_test_suite: (String test_suite_name, ?service: String?, ?tags: Hash[untyped, untyped]) -> Datadog::CI::Span
28
+
29
+ def active_test_session: () -> Datadog::CI::TestSession?
30
+
31
+ def active_test_module: () -> Datadog::CI::TestModule?
32
+
33
+ def active_test_suite: (String test_suite_name) -> Datadog::CI::TestSuite?
34
+
13
35
  def active_test: () -> Datadog::CI::Test?
14
36
 
15
37
  def active_span: () -> Datadog::CI::Span?
16
38
 
17
39
  def deactivate_test: (Datadog::CI::Test test) -> void
18
40
 
41
+ def deactivate_test_session: () -> void
42
+
43
+ def deactivate_test_module: () -> void
44
+
45
+ def deactivate_test_suite: (String test_suite_name) -> void
46
+
19
47
  def create_datadog_span: (String span_name, ?span_options: Hash[untyped, untyped], ?tags: Hash[untyped, untyped]) ?{ (Datadog::CI::Span span) -> untyped } -> untyped
20
48
 
21
49
  def set_trace_origin: (Datadog::Tracing::TraceOperation trace) -> untyped
@@ -24,7 +52,32 @@ module Datadog
24
52
 
25
53
  def build_test: (Datadog::Tracing::SpanOperation tracer_span, Hash[untyped, untyped] tags) -> Datadog::CI::Test
26
54
 
55
+ def build_test_session: (Datadog::Tracing::SpanOperation tracer_span, Hash[untyped, untyped] tags) -> Datadog::CI::TestSession
56
+
57
+ def build_test_module: (Datadog::Tracing::SpanOperation tracer_span, Hash[untyped, untyped] tags) -> Datadog::CI::TestModule
58
+
59
+ def build_test_suite: (Datadog::Tracing::SpanOperation tracer_span, Hash[untyped, untyped] tags) -> Datadog::CI::TestSuite
60
+
27
61
  def build_span: (Datadog::Tracing::SpanOperation tracer_span, Hash[untyped, untyped] tags) -> Datadog::CI::Span
62
+
63
+ def build_span_options: (String? service_name, String span_type, ?Hash[Symbol, untyped] other_options) -> Hash[Symbol, untyped]
64
+
65
+ def set_initial_tags: (Datadog::CI::Span ci_span, Hash[untyped, untyped] tags) -> void
66
+
67
+ # the type (Datadog::CI::TestSession | Datadog::Tracing::SpanOperation) screams of wrong/mising abstraction
68
+ def set_session_context: (Hash[untyped, untyped] tags, ?Datadog::CI::TestSession | Datadog::Tracing::SpanOperation? test_session) -> void
69
+
70
+ def set_suite_context: (Hash[untyped, untyped] tags, ?span: Datadog::Tracing::SpanOperation, ?name: String) -> void
71
+
72
+ def set_module_context: (Hash[untyped, untyped] tags, ?Datadog::CI::TestModule | Datadog::Tracing::SpanOperation? test_module) -> void
73
+
74
+ def null_span: () -> Datadog::CI::Span
75
+
76
+ def skip_tracing: (?untyped block) -> untyped
77
+
78
+ def start_datadog_tracer_span: (String span_name, Hash[untyped, untyped] span_options) ?{ (untyped) -> untyped } -> untyped
79
+
80
+ def set_inherited_globals: (Hash[untyped, untyped] tags) -> void
28
81
  end
29
82
  end
30
83
  end
@@ -7,8 +7,12 @@ module Datadog
7
7
 
8
8
  def initialize: (Datadog::Tracing::SpanOperation tracer_span) -> void
9
9
 
10
+ def id: () -> Integer
11
+
10
12
  def name: () -> String
11
13
 
14
+ def service: () -> String
15
+
12
16
  def passed!: () -> void
13
17
 
14
18
  def failed!: (?exception: untyped?) -> void
@@ -0,0 +1,6 @@
1
+ module Datadog
2
+ module CI
3
+ class TestModule < ConcurrentSpan
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ module Datadog
2
+ module CI
3
+ class TestSession < ConcurrentSpan
4
+ @inheritable_tags: Hash[untyped, untyped]
5
+
6
+ def inheritable_tags: () -> Hash[untyped, untyped]
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ module Datadog
2
+ module CI
3
+ class TestSuite < ConcurrentSpan
4
+ end
5
+ end
6
+ end