Skip to content

Commit 827e5cd

Browse files
fix(ci_visibility): fix distributed tracing when using CIVisibility [backport 2.1] (#7224)
Backport 0fec776 from #7210 to 2.1. `CIContextProvider` was introduced in #6548 to enable running tests in this repo with the `pytest` plugin, but disabled distributed tracing. `_DD_CIVISIBILITY_USE_CI_CONTEXT_PROVIDER` is introduced as a private env var that can be used to activate the `CIContextProvider`. It is false by default, returning the behavior of the tracer for regular users to what it was before the CI context provider was introduced. This is primarily a band-aid patch. Using the pytest plugin in this repo remains a WIP. This change also sets `_DD_CIVISIBILITY_USE_CI_CONTEXT_PROVIDER` in `riotfile.py` so that the change is transparent in this repo's CI runs. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) - [x] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [x] This PR doesn't touch any of that. --------- Co-authored-by: Romain Komorn <[email protected]>
1 parent dff1b18 commit 827e5cd

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

ddtrace/internal/ci_visibility/recorder.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@ def __init__(self, tracer=None, config=None, service=None):
9797
if tracer:
9898
self.tracer = tracer
9999
else:
100-
# Create a new CI tracer
101-
self.tracer = Tracer(context_provider=CIContextProvider())
100+
if asbool(os.getenv("_DD_CIVISIBILITY_USE_CI_CONTEXT_PROVIDER")):
101+
# Create a new CI tracer
102+
self.tracer = Tracer(context_provider=CIContextProvider())
103+
else:
104+
self.tracer = Tracer()
102105

103106
self._api_key = os.getenv("_CI_DD_API_KEY", os.getenv("DD_API_KEY"))
104107

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
CI Visibility: fixes distributed tracing when using the CI Visibility
5+
integration
6+

riotfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
9898
"hypothesis": "<6.45.1",
9999
},
100100
env={
101+
"_DD_CIVISIBILITY_USE_CI_CONTEXT_PROVIDER": "1",
101102
"DD_TESTING_RAISE": "1",
102103
"DD_REMOTE_CONFIGURATION_ENABLED": "false",
103104
"DD_CIVISIBILITY_AGENTLESS_ENABLED": "1",

0 commit comments

Comments
 (0)