datadog-ci 1.10.0 → 1.12.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 +27 -2
- data/lib/datadog/ci/codeowners/matcher.rb +1 -1
- data/lib/datadog/ci/contrib/cuprite/configuration/settings.rb +34 -0
- data/lib/datadog/ci/contrib/cuprite/driver.rb +94 -0
- data/lib/datadog/ci/contrib/cuprite/ext.rb +15 -0
- data/lib/datadog/ci/contrib/cuprite/integration.rb +44 -0
- data/lib/datadog/ci/contrib/cuprite/patcher.rb +24 -0
- data/lib/datadog/ci/contrib/cuprite/script_executor.rb +32 -0
- data/lib/datadog/ci/contrib/selenium/capybara_driver.rb +4 -4
- data/lib/datadog/ci/contrib/selenium/configuration/settings.rb +3 -1
- data/lib/datadog/ci/contrib/selenium/driver.rb +4 -4
- data/lib/datadog/ci/contrib/selenium/ext.rb +0 -15
- data/lib/datadog/ci/contrib/selenium/navigation.rb +2 -2
- data/lib/datadog/ci/ext/environment/providers/github_actions.rb +3 -0
- data/lib/datadog/ci/ext/environment.rb +4 -0
- data/lib/datadog/ci/ext/rum.rb +26 -0
- data/lib/datadog/ci/ext/telemetry.rb +8 -1
- data/lib/datadog/ci/ext/test.rb +3 -0
- data/lib/datadog/ci/remote/library_settings_client.rb +4 -1
- data/lib/datadog/ci/test_optimisation/component.rb +2 -0
- data/lib/datadog/ci/test_optimisation/skippable_percentage/calculator.rb +1 -1
- data/lib/datadog/ci/test_session.rb +1 -1
- data/lib/datadog/ci/test_visibility/context.rb +5 -0
- data/lib/datadog/ci/test_visibility/serializers/base.rb +4 -0
- data/lib/datadog/ci/test_visibility/serializers/test_session.rb +1 -1
- data/lib/datadog/ci/test_visibility/transport.rb +14 -1
- data/lib/datadog/ci/transport/event_platform_transport.rb +1 -1
- data/lib/datadog/ci/utils/configuration.rb +4 -0
- data/lib/datadog/ci/utils/rum.rb +42 -0
- data/lib/datadog/ci/version.rb +2 -2
- data/lib/datadog/ci.rb +1 -0
- metadata +12 -8
- data/lib/datadog/ci/contrib/selenium/rum.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccfa630b807e5675fd68f68e571aeda530a0923e4cd4bdd29451f3065f8c4c7c
|
4
|
+
data.tar.gz: 0a777e031ade13b09619a034206a1258285fd3e63c4bd36a5a3e24a3840590e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c47398d3cc2557b047741b7f8699e6464ee323bf3a32da43442fad8e666ca7cbc3fa973a88a006be3b86d0d3a61b44573755589b909fc21b75feb9b1f374de23
|
7
|
+
data.tar.gz: e183e41a31344d2beb1f03790d48f31259d52b043f23a340b1480db065e23909ce3f90204dbc9e98a4ef88a22a3fe16d759bf47fca080701c0a3a750ef7adfc9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [1.12.0] - 2025-01-23
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
* Add Datadog RUM integration support for browser tests with cuprite driver ([#283][])
|
8
|
+
|
9
|
+
## [1.11.0] - 2025-01-02
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
* bump maximum Ruby version to 3.4 ([#275][])
|
14
|
+
* Use logical test session name as part of test session span's resource instead of test command ([#271][])
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
* set the max payload size for events to 4.5MB ([#272][])
|
19
|
+
* Fix inline comments handling when parsing CODEOWNERS files ([#267][])
|
20
|
+
|
3
21
|
## [1.10.0] - 2024-12-05
|
4
22
|
|
5
23
|
### Added
|
@@ -368,7 +386,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
368
386
|
|
369
387
|
- Ruby versions < 2.7 no longer supported ([#8][])
|
370
388
|
|
371
|
-
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.
|
389
|
+
[Unreleased]: https://github.com/DataDog/datadog-ci-rb/compare/v1.12.0...main
|
390
|
+
[1.12.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.11.0...v1.12.0
|
391
|
+
[1.11.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.10.0...v1.11.0
|
372
392
|
[1.10.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.9.0...v1.10.0
|
373
393
|
[1.9.0]: https://github.com/DataDog/datadog-ci-rb/compare/v1.8.1...v1.9.0
|
374
394
|
[1.8.1]: https://github.com/DataDog/datadog-ci-rb/compare/v1.8.0...v1.8.1
|
@@ -529,4 +549,9 @@ Currently test suite level visibility is not used by our instrumentation: it wil
|
|
529
549
|
[#248]: https://github.com/DataDog/datadog-ci-rb/issues/248
|
530
550
|
[#250]: https://github.com/DataDog/datadog-ci-rb/issues/250
|
531
551
|
[#259]: https://github.com/DataDog/datadog-ci-rb/issues/259
|
532
|
-
[#262]: https://github.com/DataDog/datadog-ci-rb/issues/262
|
552
|
+
[#262]: https://github.com/DataDog/datadog-ci-rb/issues/262
|
553
|
+
[#267]: https://github.com/DataDog/datadog-ci-rb/issues/267
|
554
|
+
[#271]: https://github.com/DataDog/datadog-ci-rb/issues/271
|
555
|
+
[#272]: https://github.com/DataDog/datadog-ci-rb/issues/272
|
556
|
+
[#275]: https://github.com/DataDog/datadog-ci-rb/issues/275
|
557
|
+
[#283]: https://github.com/DataDog/datadog-ci-rb/issues/283
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "datadog/core"
|
4
|
+
|
5
|
+
require_relative "../ext"
|
6
|
+
require_relative "../../settings"
|
7
|
+
|
8
|
+
require_relative "../../../ext/rum"
|
9
|
+
|
10
|
+
module Datadog
|
11
|
+
module CI
|
12
|
+
module Contrib
|
13
|
+
module Cuprite
|
14
|
+
module Configuration
|
15
|
+
# Custom settings for the Cuprite integration
|
16
|
+
# @public_api
|
17
|
+
class Settings < Datadog::CI::Contrib::Settings
|
18
|
+
option :enabled do |o|
|
19
|
+
o.type :bool
|
20
|
+
o.env Ext::ENV_ENABLED
|
21
|
+
o.default true
|
22
|
+
end
|
23
|
+
|
24
|
+
option :rum_flush_wait_millis do |o|
|
25
|
+
o.type :int
|
26
|
+
o.env CI::Ext::RUM::ENV_RUM_FLUSH_WAIT_MILLIS
|
27
|
+
o.default 500
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "script_executor"
|
4
|
+
require_relative "../patcher"
|
5
|
+
|
6
|
+
require_relative "../../ext/rum"
|
7
|
+
require_relative "../../ext/test"
|
8
|
+
require_relative "../../utils/rum"
|
9
|
+
|
10
|
+
module Datadog
|
11
|
+
module CI
|
12
|
+
module Contrib
|
13
|
+
module Cuprite
|
14
|
+
# instruments Capybara::Cuprite::Driver
|
15
|
+
module Driver
|
16
|
+
def self.included(base)
|
17
|
+
base.prepend(InstanceMethods)
|
18
|
+
end
|
19
|
+
|
20
|
+
module InstanceMethods
|
21
|
+
def visit(url)
|
22
|
+
result = super
|
23
|
+
|
24
|
+
return result unless datadog_configuration[:enabled]
|
25
|
+
|
26
|
+
Datadog.logger.debug("[Cuprite] Navigation to #{url}")
|
27
|
+
|
28
|
+
# on session reset Capybara navigates to about:blank
|
29
|
+
return result if url == "about:blank"
|
30
|
+
|
31
|
+
active_test = Datadog::CI.active_test
|
32
|
+
Datadog.logger.debug("[Cuprite] Active test: #{active_test}")
|
33
|
+
|
34
|
+
return result unless active_test
|
35
|
+
|
36
|
+
# Set the test's trace id as a cookie in browser session
|
37
|
+
Datadog.logger.debug do
|
38
|
+
"[Cuprite] Setting cookie #{CI::Ext::RUM::COOKIE_TEST_EXECUTION_ID} to #{active_test.trace_id}"
|
39
|
+
end
|
40
|
+
set_cookie(CI::Ext::RUM::COOKIE_TEST_EXECUTION_ID, active_test.trace_id.to_s)
|
41
|
+
|
42
|
+
# set the test type to browser
|
43
|
+
active_test.set_tag(CI::Ext::Test::TAG_TYPE, CI::Ext::Test::Type::BROWSER)
|
44
|
+
|
45
|
+
# set the tags specific to the browser test
|
46
|
+
active_test.set_tag(CI::Ext::Test::TAG_BROWSER_DRIVER, "cuprite")
|
47
|
+
active_test.set_tag(CI::Ext::Test::TAG_BROWSER_DRIVER_VERSION, datadog_integration.version)
|
48
|
+
active_test.set_tag(CI::Ext::Test::TAG_BROWSER_NAME, browser.options.browser_name || "chrome")
|
49
|
+
active_test.set_tag(CI::Ext::Test::TAG_BROWSER_VERSION, browser.version.product)
|
50
|
+
|
51
|
+
result
|
52
|
+
end
|
53
|
+
|
54
|
+
def reset!
|
55
|
+
Datadog.logger.debug("[Cuprite] Driver reset! event")
|
56
|
+
|
57
|
+
datadog_end_rum_session
|
58
|
+
|
59
|
+
super
|
60
|
+
end
|
61
|
+
|
62
|
+
def quit
|
63
|
+
Datadog.logger.debug("[Cuprite] Driver quit event")
|
64
|
+
|
65
|
+
datadog_end_rum_session
|
66
|
+
|
67
|
+
super
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def datadog_integration
|
73
|
+
CI::Contrib::Instrumentation.fetch_integration(:cuprite)
|
74
|
+
end
|
75
|
+
|
76
|
+
def datadog_configuration
|
77
|
+
Datadog.configuration.ci[:cuprite]
|
78
|
+
end
|
79
|
+
|
80
|
+
def datadog_end_rum_session
|
81
|
+
return unless datadog_configuration[:enabled]
|
82
|
+
|
83
|
+
executor = ScriptExecutor.new(browser)
|
84
|
+
Utils::RUM.stop_rum_session(executor, rum_flush_wait_millis: datadog_configuration[:rum_flush_wait_millis])
|
85
|
+
|
86
|
+
Datadog.logger.debug("[Cuprite] Deleting Datadog cookie")
|
87
|
+
remove_cookie(CI::Ext::RUM::COOKIE_TEST_EXECUTION_ID)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../integration"
|
4
|
+
require_relative "configuration/settings"
|
5
|
+
require_relative "patcher"
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module CI
|
9
|
+
module Contrib
|
10
|
+
module Cuprite
|
11
|
+
# Description of Cuprite integration
|
12
|
+
class Integration < Contrib::Integration
|
13
|
+
MINIMUM_VERSION = Gem::Version.new("0.15.0")
|
14
|
+
|
15
|
+
def version
|
16
|
+
Gem.loaded_specs["cuprite"]&.version
|
17
|
+
end
|
18
|
+
|
19
|
+
def loaded?
|
20
|
+
!defined?(::Capybara).nil? && !defined?(::Capybara::Cuprite).nil? &&
|
21
|
+
!defined?(::Capybara::Cuprite::Driver).nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
def compatible?
|
25
|
+
super && version >= MINIMUM_VERSION
|
26
|
+
end
|
27
|
+
|
28
|
+
# additional instrumentations for test libraries are late instrumented on test session start
|
29
|
+
def late_instrument?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def new_configuration
|
34
|
+
Configuration::Settings.new
|
35
|
+
end
|
36
|
+
|
37
|
+
def patcher
|
38
|
+
Patcher
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../patcher"
|
4
|
+
|
5
|
+
require_relative "driver"
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module CI
|
9
|
+
module Contrib
|
10
|
+
module Cuprite
|
11
|
+
# Patcher enables patching of 'Capybara::Cuprite::Driver' class.
|
12
|
+
module Patcher
|
13
|
+
include Datadog::CI::Contrib::Patcher
|
14
|
+
|
15
|
+
module_function
|
16
|
+
|
17
|
+
def patch
|
18
|
+
::Capybara::Cuprite::Driver.include(Driver)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../ext/rum"
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module CI
|
7
|
+
module Contrib
|
8
|
+
module Cuprite
|
9
|
+
class ScriptExecutor
|
10
|
+
# Ferrum::Browser requires a JS script to be wrapped in a function() { ... } block
|
11
|
+
WRAPPED_SCRIPTS = {
|
12
|
+
CI::Ext::RUM::SCRIPT_IS_RUM_ACTIVE => "function() { #{CI::Ext::RUM::SCRIPT_IS_RUM_ACTIVE}; }",
|
13
|
+
CI::Ext::RUM::SCRIPT_STOP_RUM_SESSION => <<~JS
|
14
|
+
function() {
|
15
|
+
#{CI::Ext::RUM::SCRIPT_STOP_RUM_SESSION}
|
16
|
+
}
|
17
|
+
JS
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
def initialize(ferrum_browser)
|
21
|
+
@ferrum_browser = ferrum_browser
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute_script(script)
|
25
|
+
script = WRAPPED_SCRIPTS.fetch(script, script)
|
26
|
+
@ferrum_browser.evaluate_func(script)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require_relative "../patcher"
|
4
4
|
|
5
|
-
require_relative "ext"
|
6
|
-
require_relative "rum"
|
5
|
+
require_relative "../../ext/rum"
|
7
6
|
require_relative "../../ext/test"
|
7
|
+
require_relative "../../utils/rum"
|
8
8
|
|
9
9
|
module Datadog
|
10
10
|
module CI
|
@@ -22,10 +22,10 @@ module Datadog
|
|
22
22
|
|
23
23
|
Datadog.logger.debug("[Selenium] Capybara session reset event")
|
24
24
|
|
25
|
-
RUM.stop_rum_session(@browser)
|
25
|
+
Utils::RUM.stop_rum_session(@browser, rum_flush_wait_millis: datadog_configuration[:rum_flush_wait_millis])
|
26
26
|
|
27
27
|
Datadog.logger.debug("[Selenium] RUM session stopped, deleting cookie")
|
28
|
-
@browser.manage.delete_cookie(Ext::COOKIE_TEST_EXECUTION_ID)
|
28
|
+
@browser.manage.delete_cookie(CI::Ext::RUM::COOKIE_TEST_EXECUTION_ID)
|
29
29
|
rescue ::Selenium::WebDriver::Error::WebDriverError => e
|
30
30
|
Datadog.logger.debug("[Selenium] Error while resetting Capybara session: #{e.message}")
|
31
31
|
ensure
|
@@ -5,6 +5,8 @@ require "datadog/core"
|
|
5
5
|
require_relative "../ext"
|
6
6
|
require_relative "../../settings"
|
7
7
|
|
8
|
+
require_relative "../../../ext/rum"
|
9
|
+
|
8
10
|
module Datadog
|
9
11
|
module CI
|
10
12
|
module Contrib
|
@@ -21,7 +23,7 @@ module Datadog
|
|
21
23
|
|
22
24
|
option :rum_flush_wait_millis do |o|
|
23
25
|
o.type :int
|
24
|
-
o.env Ext::ENV_RUM_FLUSH_WAIT_MILLIS
|
26
|
+
o.env CI::Ext::RUM::ENV_RUM_FLUSH_WAIT_MILLIS
|
25
27
|
o.default 500
|
26
28
|
end
|
27
29
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative "../patcher"
|
4
4
|
|
5
|
-
require_relative "
|
6
|
-
require_relative "rum"
|
5
|
+
require_relative "../../utils/rum"
|
6
|
+
require_relative "../../ext/rum"
|
7
7
|
require_relative "../../ext/test"
|
8
8
|
|
9
9
|
module Datadog
|
@@ -22,10 +22,10 @@ module Datadog
|
|
22
22
|
|
23
23
|
Datadog.logger.debug("[Selenium] Driver quit event")
|
24
24
|
|
25
|
-
RUM.stop_rum_session(@bridge)
|
25
|
+
Utils::RUM.stop_rum_session(@bridge, rum_flush_wait_millis: datadog_configuration[:rum_flush_wait_millis])
|
26
26
|
|
27
27
|
Datadog.logger.debug("[Selenium] RUM session stopped, deleting cookie")
|
28
|
-
@bridge.manage.delete_cookie(Ext::COOKIE_TEST_EXECUTION_ID)
|
28
|
+
@bridge.manage.delete_cookie(CI::Ext::RUM::COOKIE_TEST_EXECUTION_ID)
|
29
29
|
rescue ::Selenium::WebDriver::Error::WebDriverError => e
|
30
30
|
Datadog.logger.debug("[Selenium] Error while quitting Selenium driver: #{e.message}")
|
31
31
|
ensure
|
@@ -8,21 +8,6 @@ module Datadog
|
|
8
8
|
# @public_api
|
9
9
|
module Ext
|
10
10
|
ENV_ENABLED = "DD_CIVISIBILITY_SELENIUM_ENABLED"
|
11
|
-
ENV_RUM_FLUSH_WAIT_MILLIS = "DD_CIVISIBILITY_RUM_FLUSH_WAIT_MILLIS"
|
12
|
-
|
13
|
-
COOKIE_TEST_EXECUTION_ID = "datadog-ci-visibility-test-execution-id"
|
14
|
-
|
15
|
-
SCRIPT_IS_RUM_ACTIVE = <<~JS
|
16
|
-
return !!window.DD_RUM
|
17
|
-
JS
|
18
|
-
SCRIPT_STOP_RUM_SESSION = <<~JS
|
19
|
-
if (window.DD_RUM && window.DD_RUM.stopSession) {
|
20
|
-
window.DD_RUM.stopSession();
|
21
|
-
return true;
|
22
|
-
} else {
|
23
|
-
return false;
|
24
|
-
}
|
25
|
-
JS
|
26
11
|
end
|
27
12
|
end
|
28
13
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative "../patcher"
|
4
4
|
|
5
|
-
require_relative "ext"
|
5
|
+
require_relative "../../ext/rum"
|
6
6
|
require_relative "../../ext/test"
|
7
7
|
|
8
8
|
module Datadog
|
@@ -32,7 +32,7 @@ module Datadog
|
|
32
32
|
return result unless active_test
|
33
33
|
|
34
34
|
# Set the test's trace id as a cookie in browser session
|
35
|
-
cookie_hash = {name: Ext::COOKIE_TEST_EXECUTION_ID, value: active_test.trace_id.to_s}
|
35
|
+
cookie_hash = {name: CI::Ext::RUM::COOKIE_TEST_EXECUTION_ID, value: active_test.trace_id.to_s}
|
36
36
|
Datadog.logger.debug { "[Selenium] Setting cookie: #{cookie_hash}" }
|
37
37
|
@bridge.manage.add_cookie(cookie_hash)
|
38
38
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "json"
|
4
4
|
|
5
|
+
require "datadog/core/telemetry/logging"
|
5
6
|
require "datadog/core/utils/url"
|
6
7
|
|
7
8
|
require_relative "base"
|
@@ -96,6 +97,8 @@ module Datadog
|
|
96
97
|
result
|
97
98
|
rescue => e
|
98
99
|
Datadog.logger.error("Failed to extract additional tags from GitHub Actions: #{e}")
|
100
|
+
Core::Telemetry::Logger.report(e, description: "Failed to extract additional tags from GitHub Actions")
|
101
|
+
|
99
102
|
{}
|
100
103
|
end
|
101
104
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "datadog/core/telemetry/logging"
|
4
|
+
|
3
5
|
require_relative "git"
|
4
6
|
require_relative "environment/extractor"
|
5
7
|
|
@@ -73,6 +75,7 @@ module Datadog
|
|
73
75
|
return if !repo_url.nil? && !repo_url.empty?
|
74
76
|
|
75
77
|
Datadog.logger.error("DD_GIT_REPOSITORY_URL is not set or empty; no repo URL was automatically extracted")
|
78
|
+
Core::Telemetry::Logger.error("DD_GIT_REPOSITORY_URL is not set or empty; no repo URL was automatically extracted")
|
76
79
|
end
|
77
80
|
|
78
81
|
def validate_git_sha(git_sha)
|
@@ -89,6 +92,7 @@ module Datadog
|
|
89
92
|
end
|
90
93
|
|
91
94
|
Datadog.logger.error(message)
|
95
|
+
Core::Telemetry::Logger.error(message)
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module CI
|
5
|
+
module Ext
|
6
|
+
# Defines constants for Git tags
|
7
|
+
module RUM
|
8
|
+
ENV_RUM_FLUSH_WAIT_MILLIS = "DD_CIVISIBILITY_RUM_FLUSH_WAIT_MILLIS"
|
9
|
+
|
10
|
+
COOKIE_TEST_EXECUTION_ID = "datadog-ci-visibility-test-execution-id"
|
11
|
+
|
12
|
+
SCRIPT_IS_RUM_ACTIVE = <<~JS
|
13
|
+
return !!window.DD_RUM
|
14
|
+
JS
|
15
|
+
SCRIPT_STOP_RUM_SESSION = <<~JS
|
16
|
+
if (window.DD_RUM && window.DD_RUM.stopSession) {
|
17
|
+
window.DD_RUM.stopSession();
|
18
|
+
return true;
|
19
|
+
} else {
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
JS
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -69,6 +69,7 @@ module Datadog
|
|
69
69
|
TAG_BROWSER_DRIVER = "browser_driver"
|
70
70
|
TAG_IS_RUM = "is_rum"
|
71
71
|
TAG_IS_RETRY = "is_retry"
|
72
|
+
TAG_EARLY_FLAKE_DETECTION_ABORT_REASON = "early_flake_detection_abort_reason"
|
72
73
|
TAG_IS_NEW = "is_new"
|
73
74
|
TAG_LIBRARY = "library"
|
74
75
|
TAG_ENDPOINT = "endpoint"
|
@@ -78,12 +79,18 @@ module Datadog
|
|
78
79
|
TAG_REQUEST_COMPRESSED = "rq_compressed"
|
79
80
|
TAG_RESPONSE_COMPRESSED = "rs_compressed"
|
80
81
|
TAG_COMMAND = "command"
|
82
|
+
# tags for git_requests.settings_response metric
|
81
83
|
TAG_COVERAGE_ENABLED = "coverage_enabled"
|
84
|
+
TAG_ITR_ENABLED = "itr_enabled"
|
82
85
|
TAG_ITR_SKIP_ENABLED = "itrskip_enabled"
|
86
|
+
TAG_REQUIRE_GIT = "require_git"
|
83
87
|
TAG_EARLY_FLAKE_DETECTION_ENABLED = "early_flake_detection_enabled"
|
84
|
-
|
88
|
+
TAG_FLAKY_TEST_RETRIES_ENABLED = "flaky_test_retries_enabled"
|
89
|
+
# tags for test_session metric
|
85
90
|
TAG_PROVIDER = "provider"
|
86
91
|
TAG_AUTO_INJECTED = "auto_injected"
|
92
|
+
TAG_AGENTLESS_LOG_SUBMISSION_ENABLED = "agentless_log_submission_enabled"
|
93
|
+
TAG_FAIL_FAST_TEST_ORDER_ENABLED = "fail_fast_test_order_enabled"
|
87
94
|
|
88
95
|
module EventType
|
89
96
|
TEST = "test"
|
data/lib/datadog/ci/ext/test.rb
CHANGED
@@ -74,6 +74,9 @@ module Datadog
|
|
74
74
|
# common tags that are serialized directly in msgpack header in metadata field
|
75
75
|
METADATA_TAG_TEST_SESSION_NAME = "test_session.name"
|
76
76
|
|
77
|
+
# internal tag indicating if datadog service was configured by the user
|
78
|
+
TAG_USER_PROVIDED_TEST_SERVICE = "_dd.test.is_user_provided_service"
|
79
|
+
|
77
80
|
# internal metric with the number of virtual CPUs
|
78
81
|
METRIC_CPU_COUNT = "_dd.host.vcpu_count"
|
79
82
|
|
@@ -59,7 +59,10 @@ module Datadog
|
|
59
59
|
{
|
60
60
|
Ext::Telemetry::TAG_COVERAGE_ENABLED => library_settings.code_coverage_enabled?.to_s,
|
61
61
|
Ext::Telemetry::TAG_ITR_SKIP_ENABLED => library_settings.tests_skipping_enabled?.to_s,
|
62
|
-
Ext::Telemetry::TAG_EARLY_FLAKE_DETECTION_ENABLED => library_settings.early_flake_detection_enabled?.to_s
|
62
|
+
Ext::Telemetry::TAG_EARLY_FLAKE_DETECTION_ENABLED => library_settings.early_flake_detection_enabled?.to_s,
|
63
|
+
Ext::Telemetry::TAG_FLAKY_TEST_RETRIES_ENABLED => library_settings.flaky_test_retries_enabled?.to_s,
|
64
|
+
Ext::Telemetry::TAG_ITR_ENABLED => library_settings.itr_enabled?.to_s,
|
65
|
+
Ext::Telemetry::TAG_REQUIRE_GIT => library_settings.require_git?.to_s
|
63
66
|
}
|
64
67
|
)
|
65
68
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "pp"
|
4
4
|
|
5
|
+
require "datadog/core/telemetry/logging"
|
5
6
|
require "datadog/core/utils/forking"
|
6
7
|
|
7
8
|
require_relative "../ext/test"
|
@@ -224,6 +225,7 @@ module Datadog
|
|
224
225
|
Datadog.logger.debug("Loaded Datadog code coverage collector, using coverage mode: #{code_coverage_mode}")
|
225
226
|
rescue LoadError => e
|
226
227
|
Datadog.logger.error("Failed to load coverage collector: #{e}. Code coverage will not be collected.")
|
228
|
+
Core::Telemetry::Logger.report(e, description: "Failed to load coverage collector")
|
227
229
|
|
228
230
|
@code_coverage_enabled = false
|
229
231
|
end
|
@@ -66,7 +66,7 @@ module Datadog
|
|
66
66
|
cli_options_array = @rspec_cli_options + ["--dry-run", @spec_path]
|
67
67
|
|
68
68
|
rspec_config_options = ::RSpec::Core::ConfigurationOptions.new(cli_options_array)
|
69
|
-
devnull = File.new(
|
69
|
+
devnull = File.new(File::NULL, "w")
|
70
70
|
out = @verbose ? $stdout : devnull
|
71
71
|
err = @verbose ? $stderr : devnull
|
72
72
|
|
@@ -25,7 +25,7 @@ module Datadog
|
|
25
25
|
# Return the test session's name which is equal to test command used
|
26
26
|
# @return [String] the command for this test session.
|
27
27
|
def name
|
28
|
-
|
28
|
+
test_visibility.logical_test_session_name || "test_session"
|
29
29
|
end
|
30
30
|
|
31
31
|
# Return the test session's command used to run the tests
|
@@ -11,6 +11,7 @@ require_relative "../ext/app_types"
|
|
11
11
|
require_relative "../ext/environment"
|
12
12
|
require_relative "../ext/test"
|
13
13
|
|
14
|
+
require_relative "../utils/configuration"
|
14
15
|
require_relative "../utils/test_run"
|
15
16
|
|
16
17
|
require_relative "../span"
|
@@ -207,6 +208,10 @@ module Datadog
|
|
207
208
|
ci_span.set_tags(@environment_tags)
|
208
209
|
|
209
210
|
ci_span.set_metric(Ext::Test::METRIC_CPU_COUNT, Utils::TestRun.virtual_cpu_count)
|
211
|
+
ci_span.set_tag(
|
212
|
+
Ext::Test::TAG_USER_PROVIDED_TEST_SERVICE,
|
213
|
+
Utils::Configuration.service_name_provided_by_user?.to_s
|
214
|
+
)
|
210
215
|
end
|
211
216
|
|
212
217
|
# PROPAGATING CONTEXT FROM TOP-LEVEL TO THE LOWER LEVELS
|
@@ -31,7 +31,7 @@ module Datadog
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def resource
|
34
|
-
"#{@span.get_tag(Ext::Test::TAG_FRAMEWORK)}.test_session.#{
|
34
|
+
"#{@span.get_tag(Ext::Test::TAG_FRAMEWORK)}.test_session.#{test_visibility.logical_test_session_name}"
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "datadog/core/environment/identity"
|
4
|
+
require "datadog/core/telemetry/logging"
|
5
|
+
require "datadog/core/utils/only_once"
|
4
6
|
|
5
7
|
require_relative "serializers/factories/test_level"
|
6
8
|
require_relative "../ext/app_types"
|
@@ -15,6 +17,10 @@ module Datadog
|
|
15
17
|
class Transport < Datadog::CI::Transport::EventPlatformTransport
|
16
18
|
attr_reader :serializers_factory, :dd_env
|
17
19
|
|
20
|
+
def self.log_once
|
21
|
+
@log_once ||= Datadog::Core::Utils::OnlyOnce.new
|
22
|
+
end
|
23
|
+
|
18
24
|
def initialize(
|
19
25
|
api:,
|
20
26
|
dd_env:,
|
@@ -64,8 +70,15 @@ module Datadog
|
|
64
70
|
|
65
71
|
encoded
|
66
72
|
else
|
67
|
-
|
73
|
+
message = "Invalid event skipped: #{serializer} Errors: #{serializer.validation_errors}"
|
74
|
+
Datadog.logger.warn(message)
|
68
75
|
CI::Transport::Telemetry.endpoint_payload_dropped(1, endpoint: telemetry_endpoint_tag)
|
76
|
+
|
77
|
+
# log invalid message once as error to internal telemetry
|
78
|
+
self.class.log_once.run do
|
79
|
+
Core::Telemetry::Logger.error(message)
|
80
|
+
end
|
81
|
+
|
69
82
|
nil
|
70
83
|
end
|
71
84
|
end
|
@@ -9,6 +9,10 @@ module Datadog
|
|
9
9
|
def self.fetch_service_name(default)
|
10
10
|
Datadog.configuration.service_without_fallback || CI::Git::LocalRepository.repository_name || default
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.service_name_provided_by_user?
|
14
|
+
!!Datadog.configuration.service_without_fallback
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../ext/rum"
|
4
|
+
require_relative "../ext/test"
|
5
|
+
require_relative "parsing"
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module CI
|
9
|
+
module Utils
|
10
|
+
# Provides functionality to interact with Datadog Real User Monitoring product
|
11
|
+
# via executing JavaScript code in the browser.
|
12
|
+
#
|
13
|
+
# Relevant docs: https://docs.datadoghq.com/real_user_monitoring/browser/
|
14
|
+
module RUM
|
15
|
+
def self.is_rum_active?(script_executor)
|
16
|
+
is_rum_active_script_result = script_executor.execute_script(Ext::RUM::SCRIPT_IS_RUM_ACTIVE)
|
17
|
+
|
18
|
+
Datadog.logger.debug { "[RUM] SCRIPT_IS_RUM_ACTIVE result is #{is_rum_active_script_result.inspect}" }
|
19
|
+
|
20
|
+
Utils::Parsing.convert_to_bool(is_rum_active_script_result)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.stop_rum_session(script_executor, rum_flush_wait_millis: 500)
|
24
|
+
return unless is_rum_active?(script_executor)
|
25
|
+
|
26
|
+
Datadog::CI.active_test&.set_tag(
|
27
|
+
CI::Ext::Test::TAG_IS_RUM_ACTIVE,
|
28
|
+
"true"
|
29
|
+
)
|
30
|
+
|
31
|
+
result = script_executor.execute_script(Ext::RUM::SCRIPT_STOP_RUM_SESSION)
|
32
|
+
Datadog.logger.debug { "[RUM] SCRIPT_STOP_RUM_SESSION result is #{result.inspect}" }
|
33
|
+
|
34
|
+
# introduce a delay to allow the RUM session to be stopped
|
35
|
+
delay = rum_flush_wait_millis / 1000.0
|
36
|
+
Datadog.logger.debug { "[RUM] Waiting for #{delay} seconds" }
|
37
|
+
sleep(delay)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/datadog/ci/version.rb
CHANGED
@@ -4,7 +4,7 @@ module Datadog
|
|
4
4
|
module CI
|
5
5
|
module VERSION
|
6
6
|
MAJOR = 1
|
7
|
-
MINOR =
|
7
|
+
MINOR = 12
|
8
8
|
PATCH = 0
|
9
9
|
PRE = nil
|
10
10
|
BUILD = nil
|
@@ -22,7 +22,7 @@ module Datadog
|
|
22
22
|
# To allow testing with the next unreleased version of Ruby, the version check is performed
|
23
23
|
# as `< #{MAXIMUM_RUBY_VERSION}`, meaning prereleases of MAXIMUM_RUBY_VERSION are allowed
|
24
24
|
# but not stable MAXIMUM_RUBY_VERSION releases.
|
25
|
-
MAXIMUM_RUBY_VERSION = "3.
|
25
|
+
MAXIMUM_RUBY_VERSION = "3.5"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/lib/datadog/ci.rb
CHANGED
@@ -418,6 +418,7 @@ require_relative "ci/contrib/ciqueue/integration"
|
|
418
418
|
|
419
419
|
# Additional test libraries (auto instrumented later on test session start)
|
420
420
|
require_relative "ci/contrib/selenium/integration"
|
421
|
+
require_relative "ci/contrib/cuprite/integration"
|
421
422
|
require_relative "ci/contrib/simplecov/integration"
|
422
423
|
|
423
424
|
# Configuration extensions
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datadog-ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-23 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: datadog
|
@@ -83,6 +82,12 @@ files:
|
|
83
82
|
- lib/datadog/ci/contrib/cucumber/instrumentation.rb
|
84
83
|
- lib/datadog/ci/contrib/cucumber/integration.rb
|
85
84
|
- lib/datadog/ci/contrib/cucumber/patcher.rb
|
85
|
+
- lib/datadog/ci/contrib/cuprite/configuration/settings.rb
|
86
|
+
- lib/datadog/ci/contrib/cuprite/driver.rb
|
87
|
+
- lib/datadog/ci/contrib/cuprite/ext.rb
|
88
|
+
- lib/datadog/ci/contrib/cuprite/integration.rb
|
89
|
+
- lib/datadog/ci/contrib/cuprite/patcher.rb
|
90
|
+
- lib/datadog/ci/contrib/cuprite/script_executor.rb
|
86
91
|
- lib/datadog/ci/contrib/instrumentation.rb
|
87
92
|
- lib/datadog/ci/contrib/integration.rb
|
88
93
|
- lib/datadog/ci/contrib/knapsack/extension.rb
|
@@ -113,7 +118,6 @@ files:
|
|
113
118
|
- lib/datadog/ci/contrib/selenium/integration.rb
|
114
119
|
- lib/datadog/ci/contrib/selenium/navigation.rb
|
115
120
|
- lib/datadog/ci/contrib/selenium/patcher.rb
|
116
|
-
- lib/datadog/ci/contrib/selenium/rum.rb
|
117
121
|
- lib/datadog/ci/contrib/settings.rb
|
118
122
|
- lib/datadog/ci/contrib/simplecov/configuration/settings.rb
|
119
123
|
- lib/datadog/ci/contrib/simplecov/ext.rb
|
@@ -142,6 +146,7 @@ files:
|
|
142
146
|
- lib/datadog/ci/ext/environment/providers/travis.rb
|
143
147
|
- lib/datadog/ci/ext/environment/providers/user_defined_tags.rb
|
144
148
|
- lib/datadog/ci/ext/git.rb
|
149
|
+
- lib/datadog/ci/ext/rum.rb
|
145
150
|
- lib/datadog/ci/ext/settings.rb
|
146
151
|
- lib/datadog/ci/ext/telemetry.rb
|
147
152
|
- lib/datadog/ci/ext/test.rb
|
@@ -217,6 +222,7 @@ files:
|
|
217
222
|
- lib/datadog/ci/utils/configuration.rb
|
218
223
|
- lib/datadog/ci/utils/git.rb
|
219
224
|
- lib/datadog/ci/utils/parsing.rb
|
225
|
+
- lib/datadog/ci/utils/rum.rb
|
220
226
|
- lib/datadog/ci/utils/telemetry.rb
|
221
227
|
- lib/datadog/ci/utils/test_run.rb
|
222
228
|
- lib/datadog/ci/version.rb
|
@@ -229,7 +235,6 @@ metadata:
|
|
229
235
|
changelog_uri: https://github.com/DataDog/datadog-ci-rb/blob/main/CHANGELOG.md
|
230
236
|
homepage_uri: https://github.com/DataDog/datadog-ci-rb
|
231
237
|
source_code_uri: https://github.com/DataDog/datadog-ci-rb
|
232
|
-
post_install_message:
|
233
238
|
rdoc_options: []
|
234
239
|
require_paths:
|
235
240
|
- lib
|
@@ -240,15 +245,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
240
245
|
version: 2.7.0
|
241
246
|
- - "<"
|
242
247
|
- !ruby/object:Gem::Version
|
243
|
-
version: '3.
|
248
|
+
version: '3.5'
|
244
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
250
|
requirements:
|
246
251
|
- - ">="
|
247
252
|
- !ruby/object:Gem::Version
|
248
253
|
version: 2.0.0
|
249
254
|
requirements: []
|
250
|
-
rubygems_version: 3.
|
251
|
-
signing_key:
|
255
|
+
rubygems_version: 3.6.2
|
252
256
|
specification_version: 4
|
253
257
|
summary: Datadog CI visibility for your ruby application
|
254
258
|
test_files: []
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "ext"
|
4
|
-
require_relative "../../ext/test"
|
5
|
-
require_relative "../../utils/parsing"
|
6
|
-
|
7
|
-
module Datadog
|
8
|
-
module CI
|
9
|
-
module Contrib
|
10
|
-
module Selenium
|
11
|
-
# Provides functionality to interact with Datadog Real User Monitoring product
|
12
|
-
# via executing JavaScript code in the browser.
|
13
|
-
#
|
14
|
-
# Relevant docs: https://docs.datadoghq.com/real_user_monitoring/browser/
|
15
|
-
module RUM
|
16
|
-
def self.is_rum_active?(script_executor)
|
17
|
-
is_rum_active_script_result = script_executor.execute_script(Ext::SCRIPT_IS_RUM_ACTIVE)
|
18
|
-
Datadog.logger.debug { "[Selenium] SCRIPT_IS_RUM_ACTIVE result is #{is_rum_active_script_result.inspect}" }
|
19
|
-
Utils::Parsing.convert_to_bool(is_rum_active_script_result)
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.stop_rum_session(script_executor)
|
23
|
-
config = Datadog.configuration.ci[:selenium]
|
24
|
-
if is_rum_active?(script_executor)
|
25
|
-
Datadog::CI.active_test&.set_tag(
|
26
|
-
CI::Ext::Test::TAG_IS_RUM_ACTIVE,
|
27
|
-
"true"
|
28
|
-
)
|
29
|
-
|
30
|
-
result = script_executor.execute_script(Ext::SCRIPT_STOP_RUM_SESSION)
|
31
|
-
Datadog.logger.debug { "[Selenium] SCRIPT_STOP_RUM_SESSION result is #{result.inspect}" }
|
32
|
-
|
33
|
-
# introduce a delay to allow the RUM session to be stopped
|
34
|
-
delay = config[:rum_flush_wait_millis] / 1000.0
|
35
|
-
Datadog.logger.debug { "[Selenium] Waiting for #{delay} seconds" }
|
36
|
-
sleep(delay)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|