datadog-ci 0.4.1 → 0.5.1

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -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 +34 -4
  6. data/lib/datadog/ci/configuration/extensions.rb +21 -0
  7. data/lib/datadog/ci/configuration/settings.rb +7 -1
  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/span.rb +13 -3
  20. data/lib/datadog/ci/test.rb +0 -1
  21. data/lib/datadog/ci/test_module.rb +23 -0
  22. data/lib/datadog/ci/test_session.rb +36 -0
  23. data/lib/datadog/ci/test_suite.rb +25 -0
  24. data/lib/datadog/ci/test_visibility/context/global.rb +82 -0
  25. data/lib/datadog/ci/test_visibility/context/local.rb +52 -0
  26. data/lib/datadog/ci/test_visibility/recorder.rb +293 -0
  27. data/lib/datadog/ci/test_visibility/serializers/base.rb +100 -12
  28. data/lib/datadog/ci/test_visibility/serializers/factories/test_suite_level.rb +37 -0
  29. data/lib/datadog/ci/test_visibility/serializers/span.rb +2 -16
  30. data/lib/datadog/ci/test_visibility/serializers/test_module.rb +46 -0
  31. data/lib/datadog/ci/test_visibility/serializers/test_session.rb +46 -0
  32. data/lib/datadog/ci/test_visibility/serializers/test_suite.rb +46 -0
  33. data/lib/datadog/ci/test_visibility/serializers/test_v1.rb +3 -17
  34. data/lib/datadog/ci/test_visibility/serializers/test_v2.rb +38 -0
  35. data/lib/datadog/ci/test_visibility/transport.rb +4 -4
  36. data/lib/datadog/ci/utils/test_run.rb +15 -0
  37. data/lib/datadog/ci/version.rb +1 -1
  38. data/lib/datadog/ci.rb +217 -35
  39. data/sig/datadog/ci/concurrent_span.rbs +23 -0
  40. data/sig/datadog/ci/configuration/components.rbs +4 -2
  41. data/sig/datadog/ci/configuration/extensions.rbs +9 -0
  42. data/sig/datadog/ci/ext/app_types.rbs +6 -1
  43. data/sig/datadog/ci/ext/settings.rbs +3 -0
  44. data/sig/datadog/ci/ext/test.rbs +15 -0
  45. data/sig/datadog/ci/null_span.rbs +37 -0
  46. data/sig/datadog/ci/span.rbs +4 -0
  47. data/sig/datadog/ci/test_module.rbs +6 -0
  48. data/sig/datadog/ci/test_session.rbs +9 -0
  49. data/sig/datadog/ci/test_suite.rbs +6 -0
  50. data/sig/datadog/ci/test_visibility/context/global.rbs +39 -0
  51. data/sig/datadog/ci/test_visibility/context/local.rbs +23 -0
  52. data/sig/datadog/ci/test_visibility/recorder.rbs +85 -0
  53. data/sig/datadog/ci/test_visibility/serializers/base.rbs +26 -5
  54. data/sig/datadog/ci/test_visibility/serializers/factories/test_suite_level.rbs +13 -0
  55. data/sig/datadog/ci/test_visibility/serializers/test_module.rbs +26 -0
  56. data/sig/datadog/ci/test_visibility/serializers/test_session.rbs +26 -0
  57. data/sig/datadog/ci/test_visibility/serializers/test_suite.rbs +26 -0
  58. data/sig/datadog/ci/test_visibility/serializers/test_v1.rbs +1 -1
  59. data/sig/datadog/ci/test_visibility/serializers/test_v2.rbs +25 -0
  60. data/sig/datadog/ci/test_visibility/transport.rbs +3 -3
  61. data/sig/datadog/ci/utils/test_run.rbs +11 -0
  62. data/sig/datadog/ci.rbs +19 -3
  63. metadata +32 -8
  64. data/lib/datadog/ci/context/local.rb +0 -50
  65. data/lib/datadog/ci/extensions.rb +0 -19
  66. data/lib/datadog/ci/recorder.rb +0 -119
  67. data/sig/datadog/ci/context/local.rbs +0 -21
  68. data/sig/datadog/ci/extensions.rbs +0 -7
  69. data/sig/datadog/ci/recorder.rbs +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce9361bb71547db2fcf5e1798e5a7d2984bdad921b966b25a0ca593707a6a416
4
- data.tar.gz: a4459f627e99c32d6bd90291dde6d02a7b7101bf7557a5848b0e007e2c42b649
3
+ metadata.gz: 85bb3584dc8081e8f6e8531d2a600e3948f4f9ea23d551dd99df0eab9daf2a3c
4
+ data.tar.gz: b6f686d49d3dbb1695c0f6e20b434b77648a118c32e1691f4a0f30b13d38dc62
5
5
  SHA512:
6
- metadata.gz: 458b2167df9899f700d0c64b107f96aa65108f5baa184b1d28cfd43ecd942b0a5669d84f376cdae00f4b6a2c0d86d54512d67325252197d9d7820a11de2c4e0f
7
- data.tar.gz: 1f9fbcae386aaea7459ea15c66f30fbb9a3f4b9dbcc2e626d632f33e53fe634595669770d6b6bf0acfa6b5c84b652716071c438ad6214252836ba58298aa0727
6
+ metadata.gz: 8e8ae716ea7c7408c59c11efa5a3bc30e0767a02c659e231f1cec2a02d5494d451c1e2b43c7c16240cbe7c9418f004ead32faa09b08c83bcd878156fa1062ae9
7
+ data.tar.gz: 15bdfb45e32660356fcc4c5726c4a640c78cfc2d5007807623f532a0b7c321f0b11a32d0a75f571a64ae263159d4b86b0a750dda5d7e8a5c33f9c110bf7682a0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.1] - 2023-12-11
4
+
5
+ ### Fixed
6
+
7
+ * do not collect environment tags when CI is not enabled ([#87][])
8
+
9
+ ### Changed
10
+
11
+ * Move private classes and modules deeper in module hierarchy ([#85][])
12
+ * update appraisal dependencies ([#84][])
13
+
14
+ ## [0.5.0] - 2023-12-06
15
+
16
+ ### Test suite level visibility
17
+
18
+ This release includes experimental manual API for [test suite level visibility](https://docs.datadoghq.com/continuous_integration/explorer/?tab=testruns#sessions) in Ruby.
19
+
20
+ Currently test suite level visibility is not used by our instrumentation: it will be released in v0.6.
21
+
22
+ ### Added
23
+
24
+ * Test suite level visibility: add test session public API ([#72][])
25
+ * Test suite level visibility: test module support ([#76][])
26
+ * Test suite level visibility: test suites support ([#77][])
27
+ * add YARD documentation ([#82][])
28
+ * support validation errors for CI spans ([#78][])
29
+
30
+ ### Changed
31
+
32
+ * Validate DD_SITE variable ([#79][])
33
+ * Document how to use WebMock with datadog-ci ([#80][])
34
+
35
+ ### Fixed
36
+
37
+ * Datadog::CI.trace_test always starts a new trace ([#74][])
38
+ * Skip tracing when CI mode disabled and manual API is used ([#75][])
39
+
40
+ ### Removed
41
+
42
+ * Deprecate operation name setting, change service_name to service in public API ([#81][])
43
+
3
44
  ## [0.4.1] - 2023-11-22
4
45
 
5
46
  ### Fixed
@@ -71,7 +112,9 @@
71
112
 
72
113
  * Ruby versions < 2.7 no longer supported ([#8][])
73
114
 
74
- [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.4.1...main
115
+ [Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v0.5.1...main
116
+ [0.5.1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.5.0...v0.5.1
117
+ [0.5.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.4.1...v0.5.0
75
118
  [0.4.1]: https://github.com/DataDog/datadog-ci-rb/compare/v0.4.0...v0.4.1
76
119
  [0.4.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.3.0...v0.4.0
77
120
  [0.3.0]: https://github.com/DataDog/datadog-ci-rb/compare/v0.2.0...v0.3.0
@@ -98,3 +141,16 @@
98
141
  [#65]: https://github.com/DataDog/datadog-ci-rb/issues/65
99
142
  [#66]: https://github.com/DataDog/datadog-ci-rb/issues/66
100
143
  [#70]: https://github.com/DataDog/datadog-ci-rb/issues/70
144
+ [#72]: https://github.com/DataDog/datadog-ci-rb/issues/72
145
+ [#74]: https://github.com/DataDog/datadog-ci-rb/issues/74
146
+ [#75]: https://github.com/DataDog/datadog-ci-rb/issues/75
147
+ [#76]: https://github.com/DataDog/datadog-ci-rb/issues/76
148
+ [#77]: https://github.com/DataDog/datadog-ci-rb/issues/77
149
+ [#78]: https://github.com/DataDog/datadog-ci-rb/issues/78
150
+ [#79]: https://github.com/DataDog/datadog-ci-rb/issues/79
151
+ [#80]: https://github.com/DataDog/datadog-ci-rb/issues/80
152
+ [#81]: https://github.com/DataDog/datadog-ci-rb/issues/81
153
+ [#82]: https://github.com/DataDog/datadog-ci-rb/issues/82
154
+ [#84]: https://github.com/DataDog/datadog-ci-rb/issues/84
155
+ [#85]: https://github.com/DataDog/datadog-ci-rb/issues/85
156
+ [#87]: https://github.com/DataDog/datadog-ci-rb/issues/87
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,10 +4,13 @@ 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"
9
+ require_relative "../test_visibility/recorder"
10
+ require_relative "../test_visibility/serializers/factories/test_level"
11
+ require_relative "../test_visibility/serializers/factories/test_suite_level"
8
12
  require_relative "../test_visibility/transport"
9
13
  require_relative "../transport/api/builder"
10
- require_relative "../recorder"
11
14
 
12
15
  module Datadog
13
16
  module CI
@@ -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 = TestVisibility::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
@@ -48,7 +59,7 @@ module Datadog
48
59
  settings.tracing.test_mode.enabled = true
49
60
 
50
61
  # Choose user defined TraceFlush or default to CI TraceFlush
51
- 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
52
63
 
53
64
  writer_options = settings.ci.writer_options
54
65
  if test_visibility_transport
@@ -59,8 +70,6 @@ module Datadog
59
70
  end
60
71
 
61
72
  settings.tracing.test_mode.writer_options = writer_options
62
-
63
- @ci_recorder = Recorder.new
64
73
  end
65
74
 
66
75
  def can_use_evp_proxy?(settings, agent_settings)
@@ -89,6 +98,7 @@ module Datadog
89
98
 
90
99
  Datadog::CI::TestVisibility::Transport.new(
91
100
  api: Transport::Api::Builder.build_ci_test_cycle_api(settings),
101
+ serializers_factory: serializers_factory(settings),
92
102
  dd_env: settings.env
93
103
  )
94
104
  end
@@ -99,9 +109,29 @@ module Datadog
99
109
 
100
110
  Datadog::CI::TestVisibility::Transport.new(
101
111
  api: Transport::Api::Builder.build_evp_proxy_api(agent_settings),
112
+ serializers_factory: serializers_factory(settings),
102
113
  dd_env: settings.env
103
114
  )
104
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
105
135
  end
106
136
  end
107
137
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "datadog/core/configuration/settings"
4
+ require "datadog/core/configuration/components"
5
+
6
+ require_relative "settings"
7
+ require_relative "components"
8
+
9
+ module Datadog
10
+ module CI
11
+ module Configuration
12
+ # Extends Datadog tracing with CI features
13
+ module Extensions
14
+ def self.activate!
15
+ Core::Configuration::Settings.extend(CI::Configuration::Settings)
16
+ Core::Configuration::Components.prepend(CI::Configuration::Components)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ 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
@@ -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
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "datadog/tracing/span_operation"
4
+
5
+ module Datadog
6
+ module CI
7
+ # Represents an ignored span when CI visibility is disabled.
8
+ # Replaces all methods with no-op.
9
+ #
10
+ # @public_api
11
+ class NullSpan < Span
12
+ def initialize
13
+ super(Datadog::Tracing::SpanOperation.new("null.span"))
14
+ end
15
+
16
+ def id
17
+ end
18
+
19
+ def name
20
+ end
21
+
22
+ def service
23
+ end
24
+
25
+ def span_type
26
+ end
27
+
28
+ def passed!
29
+ end
30
+
31
+ def failed!(exception: nil)
32
+ end
33
+
34
+ def skipped!(exception: nil, reason: nil)
35
+ end
36
+
37
+ def get_tag(key)
38
+ end
39
+
40
+ def set_tag(key, value)
41
+ end
42
+
43
+ def set_metric(key, value)
44
+ end
45
+
46
+ def finish
47
+ end
48
+
49
+ def set_tags(tags)
50
+ end
51
+
52
+ def set_environment_runtime_tags
53
+ end
54
+
55
+ def set_default_tags
56
+ end
57
+
58
+ def to_s
59
+ self.class.to_s
60
+ end
61
+ end
62
+ end
63
+ end