Skip to content

Commit

Permalink
chore(ci_visibility): fix API telemetry and make ordering stable with…
Browse files Browse the repository at this point in the history
… better logging (#11549)

Follow-up to #11545 that was missed in the last PR.

## Checklist
- [x] PR author has checked that all the criteria below are met
- The PR description includes an overview of the change
- The PR description articulates the motivation for the change
- The change includes tests OR the PR description describes a testing
strategy
- The PR description notes risks associated with the change, if any
- Newly-added code is easy to change
- The change follows the [library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
- The change includes or references documentation updates if necessary
- Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))

## Reviewer Checklist
- [x] Reviewer has checked that all the criteria below are met 
- Title is accurate
- All changes are related to the pull request's stated goal
- Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- Testing strategy adequately addresses listed risks
- Newly-added code is easy to change
- Release note makes sense to a user of the library
- If necessary, author has acknowledged and discussed the performance
implications of this PR as reported in the benchmarks PR comment
- 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)
  • Loading branch information
romainkomorndatadog authored Nov 26, 2024
1 parent a098029 commit 935454a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
12 changes: 6 additions & 6 deletions ddtrace/internal/ci_visibility/_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ def fetch_settings(self) -> TestVisibilityAPISettings:
)

record_settings_response(
api_settings.coverage_enabled,
api_settings.skipping_enabled,
api_settings.require_git,
api_settings.itr_enabled,
api_settings.flaky_test_retries_enabled,
api_settings.early_flake_detection.enabled,
coverage_enabled=api_settings.coverage_enabled,
skipping_enabled=api_settings.skipping_enabled,
require_git=api_settings.require_git,
itr_enabled=api_settings.itr_enabled,
flaky_test_retries_enabled=api_settings.flaky_test_retries_enabled,
early_flake_detection_enabled=api_settings.early_flake_detection.enabled,
)

return api_settings
Expand Down
16 changes: 11 additions & 5 deletions ddtrace/internal/ci_visibility/telemetry/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,23 @@ def record_settings_response(
skipping_enabled: Optional[bool] = False,
require_git: Optional[bool] = False,
itr_enabled: Optional[bool] = False,
early_flake_detection_enabled: Optional[bool] = False,
flaky_test_retries_enabled: Optional[bool] = False,
early_flake_detection_enabled: Optional[bool] = False,
) -> None:
log.debug(
"Recording settings telemetry: %s, %s, %s, %s, %s, %s",
"Recording settings telemetry:"
" coverage_enabled=%s"
", skipping_enabled=%s"
", require_git=%s"
", itr_enabled=%s"
", flaky_test_retries_enabled=%s"
", early_flake_detection_enabled=%s",
coverage_enabled,
skipping_enabled,
require_git,
itr_enabled,
early_flake_detection_enabled,
flaky_test_retries_enabled,
early_flake_detection_enabled,
)
# Telemetry "booleans" are true if they exist, otherwise false
response_tags = []
Expand All @@ -72,10 +78,10 @@ def record_settings_response(
response_tags.append(("require_git", "true"))
if itr_enabled:
response_tags.append(("itr_enabled", "true"))
if early_flake_detection_enabled:
response_tags.append(("early_flake_detection_enabled", "true"))
if flaky_test_retries_enabled:
response_tags.append(("flaky_test_retries_enabled", "true"))
if early_flake_detection_enabled:
response_tags.append(("early_flake_detection_enabled", "true"))

if response_tags:
telemetry_writer.add_count_metric(_NAMESPACE, GIT_TELEMETRY.SETTINGS_RESPONSE, 1, tuple(response_tags))

0 comments on commit 935454a

Please sign in to comment.