datadog-ci 0.4.0 → 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 +50 -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 +37 -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 +1 -1
  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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60a81205d586462fc1e58ff85bcddd69bbab3dc597abe2a730ad393fe9261040
4
- data.tar.gz: d44884f838dd3b50db30796d581017127ff6de63dc3121fc531ad54f786ae389
3
+ metadata.gz: 262f238c451500ef744ff6f24ba5176a5e2064ef49d46055965bb5ed13bc70ea
4
+ data.tar.gz: 3023b3bca603feb1a591ebf8e68c9339cc887aaea2466fda2596c3cb6a209295
5
5
  SHA512:
6
- metadata.gz: e69a35a679697d2b142140f71f0704f2c9a4fcf28d2fc9ddff79dd4f514172711c50123c4294252b2e89188ce17ced36656f08290e4c86ee187c3b22965d56da
7
- data.tar.gz: c12c56c96a6b31be3b931afdc441890ac88a59e7d12cf663b3fbbce7408ea8338b8d31fb4f49360fcaddfd425e36088bf638f960032cae6c1507d9c83fe36c7a
6
+ metadata.gz: a15556f403d45a9b4384643028ca42971f40847f7cb0a090ae4776a2e4f1615931fe8612f5306f21578ed30d72e15d725d1fbe74f488752cbec01f30f74a67ed
7
+ data.tar.gz: 02c7f199399babed0311149c2abca1a3cad27b705d92b139e0485351589707e24ee136ccebae5cef1361afdaabdfe5e2209fa97bd65edfeb947777156bd91c68
data/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.0] - 2023-12-06
4
+
5
+ ### Test suite level visibility
6
+
7
+ This release includes experimental manual API for [test suite level visibility](https://docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#sessions) in Ruby.
8
+
9
+ Currently test suite level visibility is not used by our instrumentation: it will be released in v0.6.
10
+
11
+ ### Added
12
+
13
+ * Test suite level visibility: add test session public API ([#72][])
14
+ * Test suite level visibility: test module support ([#76][])
15
+ * Test suite level visibility: test suites support ([#77][])
16
+ * add YARD documentation ([#82][])
17
+ * support validation errors for CI spans ([#78][])
18
+
19
+ ### Changed
20
+
21
+ * Validate DD_SITE variable ([#79][])
22
+ * Document how to use WebMock with datadog-ci ([#80][])
23
+
24
+ ### Fixed
25
+
26
+ * Datadog::CI.trace_test always starts a new trace ([#74][])
27
+ * Skip tracing when CI mode disabled and manual API is used ([#75][])
28
+
29
+ ### Removed
30
+
31
+ * Deprecate operation name setting, change service_name to service in public API ([#81][])
32
+
33
+ ## [0.4.1] - 2023-11-22
34
+
35
+ ### Fixed
36
+
37
+ * disable 128-bit trace id generation in CI mode ([#70][])
38
+
3
39
  ## [0.4.0] - 2023-11-21
4
40
 
5
41
  ### Added
@@ -65,7 +101,9 @@
65
101
 
66
102
  * Ruby versions < 2.7 no longer supported ([#8][])
67
103
 
68
- [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.4.0...main
104
+ [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.5.0...main
105
+ [0.5.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.4.1...v0.5.0
106
+ [0.4.1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.4.0...v0.4.1
69
107
  [0.4.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.3.0...v0.4.0
70
108
  [0.3.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.2.0...v0.3.0
71
109
  [0.2.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.1.1...v0.2.0
@@ -90,3 +128,14 @@
90
128
  [#64]: https://github.com/DataDog/datadog-ci-rb/issues/64
91
129
  [#65]: https://github.com/DataDog/datadog-ci-rb/issues/65
92
130
  [#66]: https://github.com/DataDog/datadog-ci-rb/issues/66
131
+ [#70]: https://github.com/DataDog/datadog-ci-rb/issues/70
132
+ [#72]: https://github.com/DataDog/datadog-ci-rb/issues/72
133
+ [#74]: https://github.com/DataDog/datadog-ci-rb/issues/74
134
+ [#75]: https://github.com/DataDog/datadog-ci-rb/issues/75
135
+ [#76]: https://github.com/DataDog/datadog-ci-rb/issues/76
136
+ [#77]: https://github.com/DataDog/datadog-ci-rb/issues/77
137
+ [#78]: https://github.com/DataDog/datadog-ci-rb/issues/78
138
+ [#79]: https://github.com/DataDog/datadog-ci-rb/issues/79
139
+ [#80]: https://github.com/DataDog/datadog-ci-rb/issues/80
140
+ [#81]: https://github.com/DataDog/datadog-ci-rb/issues/81
141
+ [#82]: https://github.com/DataDog/datadog-ci-rb/issues/82
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Datadog CI Visibility for Ruby
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/datadog-ci.svg)](https://badge.fury.io/rb/datadog-ci)
4
+ [![YARD documentation](https://img.shields.io/badge/YARD-documentation-blue)](https://datadoghq.dev/datadog-ci-rb/)
4
5
  [![codecov](https://codecov.io/gh/DataDog/datadog-ci-rb/branch/main/graph/badge.svg)](https://app.codecov.io/gh/DataDog/datadog-ci-rb/branch/main)
5
6
  [![CircleCI](https://dl.circleci.com/status-badge/img/gh/DataDog/datadog-ci-rb/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/DataDog/datadog-ci-rb/tree/main)
6
7
 
@@ -51,7 +52,7 @@ end
51
52
  | --- | ----------- | ------- |
52
53
  | `enabled` | Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
53
54
  | `service_name` | Service name used for `rspec` instrumentation. | `'rspec'` |
54
- | `operation_name` | Operation name used for `rspec` instrumentation. | `'rspec.example'` |
55
+ | `operation_name` | *DEPRECATED, to be removed in 1.0* Operation name used for `rspec` instrumentation (has no effect in agentless mode or when using newer agent versions). | `'rspec.example'` |
55
56
 
56
57
  ### Minitest
57
58
 
@@ -84,7 +85,7 @@ end
84
85
  | --- | ----------- | ------- |
85
86
  | `enabled` | Defines whether Minitest tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
86
87
  | `service_name` | Service name used for `minitest` instrumentation. | `'minitest'` |
87
- | `operation_name` | Operation name used for `minitest` instrumentation. | `'minitest.test'` |
88
+ | `operation_name` | *DEPRECATED, to be removed in 1.0* Operation name used for `minitest` instrumentation (has no effect in agentless mode or when using newer agent versions). | `'minitest.test'` |
88
89
 
89
90
  ### Cucumber
90
91
 
@@ -115,7 +116,7 @@ end
115
116
  | --- | ----------- | ------- |
116
117
  | `enabled` | Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
117
118
  | `service_name` | Service name used for `cucumber` instrumentation. | `'cucumber'` |
118
- | `operation_name` | Operation name used for `cucumber` instrumentation. | `'cucumber.test'` |
119
+ | `operation_name` | *DEPRECATED, to be removed in 1.0* Operation name used for `cucumber` instrumentation (has no effect in agentless mode or when using newer agent versions). | `'cucumber.test'` |
119
120
 
120
121
  ## Agentless mode
121
122
 
@@ -161,6 +162,28 @@ they will **not** show up in Datadog APM.
161
162
 
162
163
  For the full list of available instrumentations see [ddtrace documentation](https://github.com/DataDog/dd-trace-rb/blob/master/docs/GettingStarted.md)
163
164
 
165
+ ### WebMock
166
+
167
+ [WebMock](https://github.com/bblimke/webmock)
168
+ is a popular Ruby library that stubs HTTP requests when running tests.
169
+ By default it fails when used together with datadog-ci as traces are being sent
170
+ to Datadog via HTTP calls.
171
+
172
+ In order to allow HTTP connections for Datadog backend you would need to configure
173
+ Webmock accordingly.
174
+
175
+ ```ruby
176
+ # when using agentless mode
177
+ # note to use the correct datadog site (e.g. datadoghq.eu, etc)
178
+ WebMock.disable_net_connect!(:allow => "citestcycle-intake.datadoghq.com")
179
+
180
+ # when using agent
181
+ WebMock.disable_net_connect!(:allow_localhost => true)
182
+
183
+ # or for more granular setting set your agent URL
184
+ WebMock.disable_net_connect!(:allow => "localhost:8126")
185
+ ```
186
+
164
187
  ### Disabling startup logs
165
188
 
166
189
  Startup logs produce a report of tracing state when the application is initially configured.
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "span"
4
+
5
+ module Datadog
6
+ module CI
7
+ # Represents a single part of a test run that can be safely shared between threads.
8
+ # Examples of shared objects are: TestSession, TestModule, TestSpan.
9
+ #
10
+ # @public_api
11
+ class ConcurrentSpan < Span
12
+ def initialize(tracer_span)
13
+ super
14
+
15
+ @mutex = Mutex.new
16
+ end
17
+
18
+ # Gets tag value by key. This method is thread-safe.
19
+ # @param [String] key the key of the tag.
20
+ # @return [String] the value of the tag.
21
+ def get_tag(key)
22
+ synchronize { super }
23
+ end
24
+
25
+ # Sets tag value by key. This method is thread-safe.
26
+ # @param [String] key the key of the tag.
27
+ # @param [String] value the value of the tag.
28
+ # @return [void]
29
+ def set_tag(key, value)
30
+ synchronize { super }
31
+ end
32
+
33
+ # Sets metric value by key. This method is thread-safe.
34
+ # @param [String] key the key of the metric.
35
+ # @param [Numeric] value the value of the metric.
36
+ # @return [void]
37
+ def set_metric(key, value)
38
+ synchronize { super }
39
+ end
40
+
41
+ # Finishes the span. This method is thread-safe.
42
+ # @return [void]
43
+ def finish
44
+ synchronize { super }
45
+ end
46
+
47
+ # Sets multiple tags at once. This method is thread-safe.
48
+ # @param [Hash[String, String]] tags the tags to set.
49
+ # @return [void]
50
+ def set_tags(tags)
51
+ synchronize { super }
52
+ end
53
+
54
+ def synchronize
55
+ @mutex.synchronize { yield }
56
+ end
57
+ end
58
+ end
59
+ end
@@ -4,8 +4,11 @@ require "datadog/core/configuration/agent_settings_resolver"
4
4
  require "datadog/core/remote/negotiation"
5
5
 
6
6
  require_relative "../ext/transport"
7
+ require_relative "../ext/settings"
7
8
  require_relative "../test_visibility/flush"
8
9
  require_relative "../test_visibility/transport"
10
+ require_relative "../test_visibility/serializers/factories/test_level"
11
+ require_relative "../test_visibility/serializers/factories/test_suite_level"
9
12
  require_relative "../transport/api/builder"
10
13
  require_relative "../recorder"
11
14
 
@@ -20,6 +23,11 @@ module Datadog
20
23
  # Activate CI mode if enabled
21
24
  activate_ci!(settings) if settings.ci.enabled
22
25
 
26
+ @ci_recorder = Recorder.new(
27
+ enabled: settings.ci.enabled,
28
+ test_suite_level_visibility_enabled: settings.ci.experimental_test_suite_level_visibility_enabled
29
+ )
30
+
23
31
  # Initialize normally
24
32
  super
25
33
  end
@@ -29,9 +37,12 @@ module Datadog
29
37
  agent_settings = Datadog::Core::Configuration::AgentSettingsResolver.call(settings)
30
38
 
31
39
  if settings.ci.agentless_mode_enabled
40
+ check_dd_site(settings)
32
41
  test_visibility_transport = build_agentless_transport(settings)
33
42
  elsif can_use_evp_proxy?(settings, agent_settings)
34
43
  test_visibility_transport = build_evp_proxy_transport(settings, agent_settings)
44
+ else
45
+ settings.ci.experimental_test_suite_level_visibility_enabled = false
35
46
  end
36
47
 
37
48
  # Deactivate telemetry
@@ -40,11 +51,15 @@ module Datadog
40
51
  # Deactivate remote configuration
41
52
  settings.remote.enabled = false
42
53
 
54
+ # do not use 128-bit trace ids for CI visibility
55
+ # they are used for OTEL compatibility in Datadog tracer
56
+ settings.tracing.trace_id_128_bit_generation_enabled = false
57
+
43
58
  # Activate underlying tracing test mode
44
59
  settings.tracing.test_mode.enabled = true
45
60
 
46
61
  # Choose user defined TraceFlush or default to CI TraceFlush
47
- settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestVisibility::Flush::Finished.new
62
+ settings.tracing.test_mode.trace_flush = settings.ci.trace_flush || CI::TestVisibility::Flush::Partial.new
48
63
 
49
64
  writer_options = settings.ci.writer_options
50
65
  if test_visibility_transport
@@ -55,8 +70,6 @@ module Datadog
55
70
  end
56
71
 
57
72
  settings.tracing.test_mode.writer_options = writer_options
58
-
59
- @ci_recorder = Recorder.new
60
73
  end
61
74
 
62
75
  def can_use_evp_proxy?(settings, agent_settings)
@@ -85,6 +98,7 @@ module Datadog
85
98
 
86
99
  Datadog::CI::TestVisibility::Transport.new(
87
100
  api: Transport::Api::Builder.build_ci_test_cycle_api(settings),
101
+ serializers_factory: serializers_factory(settings),
88
102
  dd_env: settings.env
89
103
  )
90
104
  end
@@ -95,9 +109,29 @@ module Datadog
95
109
 
96
110
  Datadog::CI::TestVisibility::Transport.new(
97
111
  api: Transport::Api::Builder.build_evp_proxy_api(agent_settings),
112
+ serializers_factory: serializers_factory(settings),
98
113
  dd_env: settings.env
99
114
  )
100
115
  end
116
+
117
+ def serializers_factory(settings)
118
+ if settings.ci.experimental_test_suite_level_visibility_enabled
119
+ Datadog::CI::TestVisibility::Serializers::Factories::TestSuiteLevel
120
+ else
121
+ Datadog::CI::TestVisibility::Serializers::Factories::TestLevel
122
+ end
123
+ end
124
+
125
+ def check_dd_site(settings)
126
+ return if settings.site.nil?
127
+ return if Ext::Settings::DD_SITE_ALLOWLIST.include?(settings.site)
128
+
129
+ Datadog.logger.warn(
130
+ "CI VISIBILITY CONFIGURATION " \
131
+ "Agentless mode was enabled but DD_SITE is not set to one of the following: #{Ext::Settings::DD_SITE_ALLOWLIST.join(", ")}. " \
132
+ "Please make sure to set valid site in DD_SITE environment variable"
133
+ )
134
+ end
101
135
  end
102
136
  end
103
137
  end
@@ -34,6 +34,12 @@ module Datadog
34
34
  o.env CI::Ext::Settings::ENV_AGENTLESS_URL
35
35
  end
36
36
 
37
+ option :experimental_test_suite_level_visibility_enabled do |o|
38
+ o.type :bool
39
+ o.env CI::Ext::Settings::ENV_EXPERIMENTAL_TEST_SUITE_LEVEL_VISIBILITY_ENABLED
40
+ o.default false
41
+ end
42
+
37
43
  define_method(:instrument) do |integration_name, options = {}, &block|
38
44
  return unless enabled
39
45
 
@@ -56,7 +62,7 @@ module Datadog
56
62
  fetch_integration(integration_name).configuration
57
63
  end
58
64
 
59
- # TODO: Deprecate in the next major version, as `instrument` better describes this method's purpose
65
+ # @deprecated Will be removed on datadog-ci-rb 1.0.
60
66
  alias_method :use, :instrument
61
67
 
62
68
  option :trace_flush
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module CI
5
+ module Context
6
+ # This context is shared between threads and represents the current test session and test module.
7
+ class Global
8
+ def initialize
9
+ # we are using Monitor instead of Mutex because it is reentrant
10
+ @mutex = Monitor.new
11
+
12
+ @test_session = nil
13
+ @test_module = nil
14
+ @test_suites = {}
15
+ end
16
+
17
+ def fetch_or_activate_test_suite(test_suite_name, &block)
18
+ @mutex.synchronize do
19
+ @test_suites[test_suite_name] ||= block.call
20
+ end
21
+ end
22
+
23
+ def fetch_or_activate_test_module(&block)
24
+ @mutex.synchronize do
25
+ @test_module ||= block.call
26
+ end
27
+ end
28
+
29
+ def fetch_or_activate_test_session(&block)
30
+ @mutex.synchronize do
31
+ @test_session ||= block.call
32
+ end
33
+ end
34
+
35
+ def active_test_module
36
+ @test_module
37
+ end
38
+
39
+ def active_test_session
40
+ @test_session
41
+ end
42
+
43
+ def active_test_suite(test_suite_name)
44
+ @mutex.synchronize { @test_suites[test_suite_name] }
45
+ end
46
+
47
+ def service
48
+ @mutex.synchronize do
49
+ # thank you RBS for this weirdness
50
+ test_session = @test_session
51
+ test_session.service if test_session
52
+ end
53
+ end
54
+
55
+ def inheritable_session_tags
56
+ @mutex.synchronize do
57
+ test_session = @test_session
58
+ if test_session
59
+ test_session.inheritable_tags
60
+ else
61
+ {}
62
+ end
63
+ end
64
+ end
65
+
66
+ def deactivate_test_session!
67
+ @mutex.synchronize { @test_session = nil }
68
+ end
69
+
70
+ def deactivate_test_module!
71
+ @mutex.synchronize { @test_module = nil }
72
+ end
73
+
74
+ def deactivate_test_suite!(test_suite_name)
75
+ @mutex.synchronize { @test_suites.delete(test_suite_name) }
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "datadog/core"
4
+
3
5
  require_relative "../ext"
4
6
  require_relative "../../settings"
5
7
 
@@ -9,7 +11,7 @@ module Datadog
9
11
  module Cucumber
10
12
  module Configuration
11
13
  # Custom settings for the Cucumber integration
12
- # TODO: mark as `@public_api` when GA
14
+ # @public_api
13
15
  class Settings < Datadog::CI::Contrib::Settings
14
16
  option :enabled do |o|
15
17
  o.type :bool
@@ -22,10 +24,19 @@ module Datadog
22
24
  o.default { Datadog.configuration.service_without_fallback || Ext::SERVICE_NAME }
23
25
  end
24
26
 
27
+ # @deprecated Will be removed in 1.0
25
28
  option :operation_name do |o|
26
29
  o.type :string
27
30
  o.env Ext::ENV_OPERATION_NAME
28
31
  o.default Ext::OPERATION_NAME
32
+
33
+ o.after_set do |value|
34
+ if value && value != Ext::OPERATION_NAME
35
+ Datadog::Core.log_deprecation do
36
+ "The operation_name setting has no effect and will be removed in 1.0"
37
+ end
38
+ end
39
+ end
29
40
  end
30
41
  end
31
42
  end
@@ -29,14 +29,13 @@ module Datadog
29
29
  def on_test_case_started(event)
30
30
  CI.start_test(
31
31
  event.test_case.name,
32
+ event.test_case.location.file,
32
33
  tags: {
33
34
  CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
34
35
  CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Cucumber::Integration.version.to_s,
35
- CI::Ext::Test::TAG_TYPE => Ext::TEST_TYPE,
36
- CI::Ext::Test::TAG_SUITE => event.test_case.location.file
36
+ CI::Ext::Test::TAG_TYPE => Ext::TEST_TYPE
37
37
  },
38
- service_name: configuration[:service_name],
39
- operation_name: configuration[:operation_name]
38
+ service: configuration[:service_name]
40
39
  )
41
40
  end
42
41
 
@@ -9,7 +9,7 @@ module Datadog
9
9
  module Minitest
10
10
  module Configuration
11
11
  # Custom settings for the Minitest integration
12
- # TODO: mark as `@public_api` when GA
12
+ # @public_api
13
13
  class Settings < Datadog::CI::Contrib::Settings
14
14
  option :enabled do |o|
15
15
  o.type :bool
@@ -22,10 +22,19 @@ module Datadog
22
22
  o.default { Datadog.configuration.service_without_fallback || Ext::SERVICE_NAME }
23
23
  end
24
24
 
25
+ # @deprecated Will be removed in 1.0
25
26
  option :operation_name do |o|
26
27
  o.type :string
27
28
  o.env Ext::ENV_OPERATION_NAME
28
29
  o.default Ext::OPERATION_NAME
30
+
31
+ o.after_set do |value|
32
+ if value && value != Ext::OPERATION_NAME
33
+ Datadog::Core.log_deprecation do
34
+ "The operation_name setting has no effect and will be removed in 1.0"
35
+ end
36
+ end
37
+ end
29
38
  end
30
39
  end
31
40
  end
@@ -20,14 +20,13 @@ module Datadog
20
20
 
21
21
  CI.start_test(
22
22
  test_name,
23
+ test_suite,
23
24
  tags: {
24
25
  CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
25
26
  CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::Minitest::Integration.version.to_s,
26
- CI::Ext::Test::TAG_TYPE => Ext::TEST_TYPE,
27
- CI::Ext::Test::TAG_SUITE => test_suite
27
+ CI::Ext::Test::TAG_TYPE => Ext::TEST_TYPE
28
28
  },
29
- service_name: configuration[:service_name],
30
- operation_name: configuration[:operation_name]
29
+ service: configuration[:service_name]
31
30
  )
32
31
  end
33
32
 
@@ -9,7 +9,7 @@ module Datadog
9
9
  module RSpec
10
10
  module Configuration
11
11
  # Custom settings for the RSpec integration
12
- # TODO: mark as `@public_api` when GA
12
+ # @public_api
13
13
  class Settings < Datadog::CI::Contrib::Settings
14
14
  option :enabled do |o|
15
15
  o.type :bool
@@ -22,10 +22,19 @@ module Datadog
22
22
  o.default { Datadog.configuration.service_without_fallback || Ext::SERVICE_NAME }
23
23
  end
24
24
 
25
+ # @deprecated Will be removed in 1.0
25
26
  option :operation_name do |o|
26
27
  o.type :string
27
28
  o.env Ext::ENV_OPERATION_NAME
28
29
  o.default Ext::OPERATION_NAME
30
+
31
+ o.after_set do |value|
32
+ if value && value != Ext::OPERATION_NAME
33
+ Datadog::Core.log_deprecation do
34
+ "The operation_name setting has no effect and will be removed in 1.0"
35
+ end
36
+ end
37
+ end
29
38
  end
30
39
  end
31
40
  end
@@ -26,14 +26,13 @@ module Datadog
26
26
 
27
27
  CI.trace_test(
28
28
  test_name,
29
+ metadata[:example_group][:file_path],
29
30
  tags: {
30
31
  CI::Ext::Test::TAG_FRAMEWORK => Ext::FRAMEWORK,
31
32
  CI::Ext::Test::TAG_FRAMEWORK_VERSION => CI::Contrib::RSpec::Integration.version.to_s,
32
- CI::Ext::Test::TAG_TYPE => Ext::TEST_TYPE,
33
- CI::Ext::Test::TAG_SUITE => metadata[:example_group][:file_path]
33
+ CI::Ext::Test::TAG_TYPE => Ext::TEST_TYPE
34
34
  },
35
- service_name: configuration[:service_name],
36
- operation_name: configuration[:operation_name]
35
+ service: configuration[:service_name]
37
36
  ) do |test_span|
38
37
  result = super
39
38
 
@@ -10,6 +10,8 @@ module Datadog
10
10
 
11
11
  option :enabled, default: true
12
12
  option :service_name
13
+
14
+ # @deprecated Will be removed in 1.0
13
15
  option :operation_name
14
16
 
15
17
  def configure(options = {})
@@ -5,6 +5,11 @@ module Datadog
5
5
  module Ext
6
6
  module AppTypes
7
7
  TYPE_TEST = "test"
8
+ TYPE_TEST_SESSION = "test_session_end"
9
+ TYPE_TEST_MODULE = "test_module_end"
10
+ TYPE_TEST_SUITE = "test_suite_end"
11
+
12
+ CI_SPAN_TYPES = [TYPE_TEST, TYPE_TEST_SESSION, TYPE_TEST_MODULE, TYPE_TEST_SUITE].freeze
8
13
  end
9
14
  end
10
15
  end
@@ -8,6 +8,17 @@ module Datadog
8
8
  ENV_MODE_ENABLED = "DD_TRACE_CI_ENABLED"
9
9
  ENV_AGENTLESS_MODE_ENABLED = "DD_CIVISIBILITY_AGENTLESS_ENABLED"
10
10
  ENV_AGENTLESS_URL = "DD_CIVISIBILITY_AGENTLESS_URL"
11
+ ENV_EXPERIMENTAL_TEST_SUITE_LEVEL_VISIBILITY_ENABLED = "DD_CIVISIBILITY_EXPERIMENTAL_TEST_SUITE_LEVEL_VISIBILITY_ENABLED"
12
+
13
+ # Source: https://docs.datadoghq.com/getting_started/site/
14
+ DD_SITE_ALLOWLIST = [
15
+ "datadoghq.com",
16
+ "us3.datadoghq.com",
17
+ "us5.datadoghq.com",
18
+ "datadoghq.eu",
19
+ "ddog-gov.com",
20
+ "ap1.datadoghq.com"
21
+ ].freeze
11
22
  end
12
23
  end
13
24
  end
@@ -4,6 +4,7 @@ module Datadog
4
4
  module CI
5
5
  module Ext
6
6
  # Defines constants for test tags
7
+ # @public_api
7
8
  module Test
8
9
  CONTEXT_ORIGIN = "ciapp-test"
9
10
 
@@ -14,8 +15,19 @@ module Datadog
14
15
  TAG_SKIP_REASON = "test.skip_reason" # DEV: Not populated yet
15
16
  TAG_STATUS = "test.status"
16
17
  TAG_SUITE = "test.suite"
18
+ TAG_MODULE = "test.module"
17
19
  TAG_TRAITS = "test.traits"
18
20
  TAG_TYPE = "test.type"
21
+ TAG_COMMAND = "test.command"
22
+
23
+ # those tags are special and they are used to correlate tests with the test sessions, suites, and modules
24
+ TAG_TEST_SESSION_ID = "_test.session_id"
25
+ TAG_TEST_MODULE_ID = "_test.module_id"
26
+ TAG_TEST_SUITE_ID = "_test.suite_id"
27
+ SPECIAL_TAGS = [TAG_TEST_SESSION_ID, TAG_TEST_MODULE_ID, TAG_TEST_SUITE_ID].freeze
28
+
29
+ # tags that can be inherited from the test session
30
+ INHERITABLE_TAGS = [TAG_FRAMEWORK, TAG_FRAMEWORK_VERSION, TAG_TYPE].freeze
19
31
 
20
32
  # Environment runtime tags
21
33
  TAG_OS_ARCHITECTURE = "os.architecture"
@@ -23,7 +35,6 @@ module Datadog
23
35
  TAG_RUNTIME_NAME = "runtime.name"
24
36
  TAG_RUNTIME_VERSION = "runtime.version"
25
37
 
26
- # TODO: is there a better place for SPAN_KIND?
27
38
  TAG_SPAN_KIND = "span.kind"
28
39
 
29
40
  module Status