Add test for incorrect trace+span sampling with propagated sampling decision#5014
Conversation
58693a0 to
be6541d
Compare
be6541d to
ab97179
Compare
| assert len(traces) == 0 | ||
|
|
||
|
|
||
| @bug(context.library == "cpp", reason="APMAPI-1545") |
There was a problem hiding this comment.
Created a ticket for this issue, hopefully at the right place with the right fields
https://datadoghq.atlassian.net/browse/APMAPI-1545
There was a problem hiding this comment.
@LotharSee I added e5fe5a6 to fix the issue with the C++ tracer. For short, spans created during the test were not flushed, consequently they were not received by the agent.
There was a problem hiding this comment.
Thanks for the fix!
The CI test fails, apparently on a 404 response from trace_extract_headers. Retries didn't fix it.
Does it relate to your change? Should I keep it or skip it?
| } | ||
| ], | ||
| ) | ||
| def test_single_rule_with_head_and_rule_trace_sampling_019(self, test_agent, test_library): |
There was a problem hiding this comment.
All tests seem to finish with a number, not sure why, so I did so too :noideawhatiamdoing:
ab97179 to
3e01524
Compare
3e01524 to
7dc7e54
Compare
The `dd_extract_headers_and_make_child_span` does not flush traces, which was causing the test to fail for C++ because the agent does not receive the span generated. This commit explicitly flushes spans. Changes: - Explicitly flush traces. - Format `test_span_sampling.py`.
…#14308) Fixes an issue where the trace sampling decision tag (_dd.p.dm) was being incorrectly set during header extraction even when a sampling priority was already propagated. This issue was discovered when [new system-tests ](DataDog/system-tests#5014) were introduced. ## 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)
…#14308) Fixes an issue where the trace sampling decision tag (_dd.p.dm) was being incorrectly set during header extraction even when a sampling priority was already propagated. This issue was discovered when [new system-tests ](DataDog/system-tests#5014) were introduced. ## 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)
Motivation
I started activating some remote rules on Datadog account for Go services, and it resulted in the incorrect flagging of
ingestion_reason:remote_rulefor some traces which should beingestion_reason:rum.After digging more, I realized trace rule were applied when they shouldn't.
The added test here isn't exhaustive but catches exactly the issue I'm facing on production. I'm not sure it is the right file to put it (since it mixes spans sampling and trace sampling) but hopefully, this isn't mattering too much.
Changes
Add test
test_single_rule_with_head_and_rule_trace_sampling_keep_019andtest_single_rule_with_head_and_rule_trace_sampling_drop_020to ensure trace sampling and span sampling applies properly when there is already a parent sampling decision.Note: CI is currently red in Python because of
TestServiceActivationEnvVarMetric.test_service_activation_metric, I'll rebase whenever it gets fixed onmain.