Skip to content

Conversation

@vpellan
Copy link
Contributor

@vpellan vpellan commented Jan 19, 2026

What does this PR do?

This PR adds support for datadog-ci-rb on config inversion.

Motivation:

We miss all of datadog-ci-rb configs on the config registry

Change log entry

None.

Additional Notes:

DataDog/datadog-ci-rb#459 depends on this PR

How to test the change?

@github-actions github-actions bot added the core Involves Datadog core libraries label Jan 19, 2026
Comment on lines +15 to +16
LOG_DEPRECATIONS_ONLY_ONCE[deprecations] ||= Datadog::Core::Utils::OnlyOnce.new
LOG_DEPRECATIONS_ONLY_ONCE[deprecations].run do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The OnlyOnce is designed to be thread safe; when used in this manner it's not going to be thread-safe. I think in practice that's fine (I don't think we need to rely on its thread-safety properties here), but perhaps it's worth leaving a comment along the lines of

# This way of initializing the `OnlyOnce` is not thread-safe but that's OK here
LOG_DEPRECATIONS_ONLY_ONCE[deprecations] ||= Datadog::Core::Utils::OnlyOnce.new

@datadog-official
Copy link

datadog-official bot commented Jan 19, 2026

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

🧪 1 Test failed

❄️ Known flaky: tests.parametric.test_parametric_endpoints.Test_Parametric_DDTrace_Crash.test_crash[library_env0, parametric-ruby] from system_tests_suite (Datadog) (Fix with Cursor)
assert not True
 +  where True = <bound method ParametricTestClientApi.is_alive of <utils.docker_fixtures._test_clients._test_client_parametric.ParametricTestClientApi object at 0x7fbd14d32840>>()
 +    where <bound method ParametricTestClientApi.is_alive of <utils.docker_fixtures._test_clients._test_client_parametric.ParametricTestClientApi object at 0x7fbd14d32840>> = <utils.docker_fixtures._test_clients._test_client_parametric.ParametricTestClientApi object at 0x7fbd14d32840>.is_alive

self = <tests.parametric.test_parametric_endpoints.Test_Parametric_DDTrace_Crash object at 0x7fbd49775310>
test_library = <utils.docker_fixtures._test_clients._test_client_parametric.ParametricTestClientApi object at 0x7fbd14d32840>

    def test_crash(self, test_library: APMLibrary):
        """Validates that /trace/crash crashes the current process.
    
...

ℹ️ Info

❄️ No new flaky tests detected

🎯 Code Coverage
Patch Coverage: 88.89%
Overall Coverage: 95.18% (-0.01%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 789eda4 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@pr-commenter
Copy link

pr-commenter bot commented Jan 19, 2026

Benchmarks

Benchmark execution time: 2026-01-21 14:11:50

Comparing candidate commit 789eda4 in PR branch vpellan/config-inversion-datadog-ci-rb with baseline commit b92b5b6 in branch master.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 43 metrics, 2 unstable metrics.

scenario:profiling - gvl benchmark samples

  • 🟥 throughput [-711.067op/s; -700.908op/s] or [-5.351%; -5.274%]

@vpellan vpellan marked this pull request as ready for review January 19, 2026 17:23
@vpellan vpellan requested a review from a team as a code owner January 19, 2026 17:23
@vpellan vpellan marked this pull request as draft January 19, 2026 17:30
@vpellan vpellan marked this pull request as ready for review January 20, 2026 11:49
alias_method :member?, :key?

# This method will be used by datadog-ci-rb once it will bump its minimum dependancy of dd-trace-rb to 2.27.0.
# In the meantime, it uses ConfigHelper#instance_variable_get(:@source_env) to set environment variables.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this step and not just update to 2.27.0?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious myself -- I think that's a question for @anmarchenko -- would it be worth doing that bump first there and then coming back to this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose that some customers uses an old version of dd-trace-rb with latest version of datadog-ci-rb and we want to maintain compatibility ? If not then we can indeed skip this step and this should make it easier than trying to maintain compatibility without introducing breaking changes.

Copy link
Member

@anmarchenko anmarchenko Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datadog-ci-rb once it will bump its minimum dependancy of dd-trace-rb to 2.27.0

I wasn't planning to bump the minimum dependency because I will need then to go other tools that do sanity checks for customer setups (test-visibility-instrumentation-script, ddtest, etc) and adapt the checks to correctly tell the customer which versions we support. This isn't something we plan to invest right now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general as much as possible I think we should "push" users to use the latest versions because there's lots of bugs on the old ones AND it creates a big matrix of combinations we don't really test with (any dd-trace-rb x any datadog-ci-rb is a lot of versions...).

But I do think the ultimate owner of this is @anmarchenko so do think it makes sense to leave the decision to him ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree with @ivoanjo, this is what I tried to do as much as possible, but unfortunately life always gets more complicated over time, so this becomes harder when we have more tools that we need to keep in sync.

I would be happy to bump this minimum version for a customer-facing feature that unlocks real value for our customers - then it would a worth endeavour to upgrade for us and the customers. This PR is for internal purposes and we should not make any changes here that might affect customers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify: This PR does not introduce any breaking change to the exisiting codebase of datadog-ci-rb and should not change the behaviour of previously released datadog-ci-rb gems (If someone uses datadog-ci-rb 1.26.0 with dd-trace-rb release that contains these changes, there will be no change in behaviour)

And that is also true for the other way around, if someone uses the version of datadog-ci-rb that contains this PR, it will work with any version of dd-trace-rb that is supported (I've tested with 2.20.0, which doesn't even include config inversion/ConfigHelper code, 2.21.0 which contains the v1 code of config inversion and skip any checks if it detects datadog-ci-rb, and with this PR)

We do not need to bump the dependency of dd-trace-rb on datadog-ci-rb

alias_method :include?, :key?
alias_method :member?, :key?

# This method will be used by datadog-ci-rb once it will bump its minimum dependancy of dd-trace-rb to 2.27.0.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# This method will be used by datadog-ci-rb once it will bump its minimum dependancy of dd-trace-rb to 2.27.0.
# This method will be used by datadog-ci-rb after it increases minimum required version of dd-trace-rb to 2.27.0.

# datadog-ci-rb is using dd-trace-rb config DSL, which uses this method.
# Until we've correctly implemented support for datadog-ci-rb, we disable config inversion if ci is enabled.
if !defined?(::Datadog::CI) &&
if (!defined?(::Datadog::CI) || Gem::Version.new(::Datadog::CI::VERSION::STRING) >= Gem::Version.new('1.27.0')) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.27.0 is not released yet, it's a bit sketchy to merge this to our master because if we were to release tomorrow I assume this code will break datadog-ci.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this PR should not be merged until @anmarchenko gives the green light to merge both this PR and DataDog/datadog-ci-rb#459 at the same time. I will change the title of the PR to add "DO-NOT-MERGE"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not check for version ever, we must check for capabilities (like specific class present)

because otherwise we will not be able to release datadog-ci gem because CI will be broken

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI will not be broken but the checks will be skipped. But checking for capabilities is much better because it will not wait for the version to be bumped by fast_castle to actually do the checks, thanks for the feedback!

module Deprecations
LOG_DEPRECATIONS_ONLY_ONCE = Datadog::Core::Utils::OnlyOnce.new
# Hash of OnlyOnce, as we may call log_deprecations_from_all_sources from datadog-ci-rb too with different deprecations set
# This way of initializing the `OnlyOnce` is not thread-safe but that's OK here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but this comment goes with the write on line 16, not with the assignment on line 13.

module Configuration
module Deprecations
LOG_DEPRECATIONS_ONLY_ONCE = Datadog::Core::Utils::OnlyOnce.new
# Hash of OnlyOnce, as we may call log_deprecations_from_all_sources from datadog-ci-rb too with different deprecations set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Hash of OnlyOnce, as we may call log_deprecations_from_all_sources from datadog-ci-rb too with different deprecations set
# Hash of OnlyOnce instances, as we may call log_deprecations_from_all_sources from datadog-ci-rb too with different deprecations set

The current comment reads as a hash (digest) of a single OnlyOnce instance which is confusing and not what is actually happening.


# This method will be used by datadog-ci-rb once it will bump its minimum dependancy of dd-trace-rb to 2.27.0.
# In the meantime, it uses ConfigHelper#instance_variable_get(:@source_env) to set environment variables.
def []=(name, value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused why this method is being added and immediately stated to be unused in the upcoming datadog-ci release, can a comment be added explaining this in more detail please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datadog-ci-rb is compatible with dd-trace-rb 2.4.0. To make config inversion work on datadog-ci-rb, we monkey-patch DATADOG_ENV, which was introduced in dd-trace-rb 2.21.0 IIRC. For version lower that 2.21.0, DATADOG_ENV will be equal to ENV, but versions above that is a ConfigHelper instance. It is not planned to bump dd-trace-rb dependency in datadog-ci-rb yet, but I added this so it is future proof, and can be used to simplify the code once datadog-ci-rb bumps dd-trace-rb dependency

@vpellan vpellan requested a review from anmarchenko January 21, 2026 10:08
@vpellan vpellan changed the title [APMAPI-1594] Add support for config inversion on datadog-ci-rb [APMAPI-1594] (DO-NOT-MERGE) Add support for config inversion on datadog-ci-rb Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Involves Datadog core libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants