Skip to content

Commit

Permalink
chore(ci_visibility): override API answer if _DD_CIVISIBILITY_ITR_FOR…
Browse files Browse the repository at this point in the history
…CE_ENABLE_COVERAGE is set (#7656)

## Motivation

This PR moves the `_DD_CIVISIBILITY_ITR_FORCE_ENABLE_COVERAGE` to the
`_should_collect_coverage()` function to override API answers.

## 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.
  • Loading branch information
ericlaz committed Nov 20, 2023
1 parent 1116c8d commit d0e50ca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ddtrace/internal/ci_visibility/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ def __init__(self, tracer=None, config=None, service=None):

@staticmethod
def _should_collect_coverage(coverage_enabled_by_api):
if not coverage_enabled_by_api:
if not coverage_enabled_by_api and not asbool(
os.getenv("_DD_CIVISIBILITY_ITR_FORCE_ENABLE_COVERAGE", default=False)
):
return False
if compat.PY2:
log.warning("CI Visibility code coverage tracking is enabled, but Python 2 is not supported.")
Expand Down Expand Up @@ -240,8 +242,6 @@ def _check_enabled_features(self):
return False, False

attributes = parsed["data"]["attributes"]
if asbool(os.getenv("_DD_CIVISIBILITY_ITR_FORCE_ENABLE_COVERAGE", default=False)):
return True, attributes["tests_skipping"]
return attributes["code_coverage"], attributes["tests_skipping"]

def _configure_writer(self, coverage_enabled=False, requests_mode=None):
Expand Down

0 comments on commit d0e50ca

Please sign in to comment.