Add trace filter tests [APMSP-2763]#6952
Conversation
|
|
… scheme (#2008) These fields were renamed in version 7.79.0 of the agent for consistency. # What does this PR do? Allow both PascalCase and the newer snake_case format for these fields. # Motivation The trace exporter was crashing in a confusing way in new system tests I wrote for another feature: DataDog/system-tests#6952. I had an older agent. # Additional Notes Anything else we should know when reviewing? # How to test the change? Describe here in detail how the change can be validated. Co-authored-by: oscar.ledauphin <[email protected]>
# What does this PR do? Implements the CSS trace-level filtering mechanism, that is applied before stats computation. # Motivation It's un unmet requirement from the spec. # Additional Notes ~Please Ctrl+F `FIXME` when reviewing, I let some questions in the code that I'd like answers for before merging~ ## TODO: - [x] unit tests - [x] system-tests DataDog/system-tests#6952 - [x] normalization before filtering - [x] regex keys (currently only regex values are checked) - [x] new spec or CSS spec RFC - [x] telemetry ? Count dropped traces with the reason - [x] trim spaces when parsing config - [x] Move implementation to trace-utils - [x] stop using v4 span but generic spans instead for php - [x] move arcswap to the trace exporter (remove update_conf) - [x] use test agent for snapshot tests ## Wont do - [ ] ~advanced resource normalization (sql, redis etc...).~ No other implementation does that - [ ] ~100% normalization edge cases (empty service field + non-normalized name + filter depending on that)~ Too specific edge case. Ignoring it for now - [ ] ~check on meta_struct too~ Not in the spec [APMSP-2763] [APMSP-2763]: https://datadoghq.atlassian.net/browse/APMSP-2763?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Co-authored-by: oscar.ledauphin <[email protected]>
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 85ab44e | Docs | Datadog PR Page | Give us feedback! |
💡 Codex ReviewThis helper is called from the new system-tests/tests/test_the_test/scenarios.json Lines 5641 to 5643 in 2e3ce18
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
97052c0 to
1a7794c
Compare
| """A require filter drops traces whose root span lacks the required tag.""" | ||
| with test_library, test_library.dd_start_span(name="web.request"): | ||
| pass | ||
| assert not test_agent.traces(), "trace lacking the required tag should be dropped" |
There was a problem hiding this comment.
nit: why not check for stats here ?
There was a problem hiding this comment.
These tests are focused on trace filters specifically, so they should not fail if CSS has a problem.
When I tried checking stats here using php it failed for the same reason as why CSS tests are disabled for php:
missing_feature (CSS v1.2.0: dd-trace-php ships CSS since v1.19.0, but the sidecar stats exporter retains buckets younger than ~20s (buffer_len=2 * bucket_size=10s) and dd_trace_synchronous_flush passes force=false, so short-lived parametric tests never observe a /v0.6/stats request)
cbeauchesne
left a comment
There was a problem hiding this comment.
From framework usage, all good.
I let someone familiar with the feature validate the test logic and approve the PR
| ) -> pytest.MarkDecorator: | ||
| """Configure agent-side trace filters and pin the test agent version. | ||
|
|
||
| Filters are advertised in the test agent's /info response (via DD_AGENT_EXTRA_INFO) so the |
There was a problem hiding this comment.
Why is this behind an env var? The real agent always exposes them (since 7.75)
There was a problem hiding this comment.
I'm not sure I understand what you're asking.
To clarify the env var DD_AGENT_EXTRA_INFO is used to add the trace filter configuration to the test agent /info response, AFAIK there is no other way to configure trace filters in the test agent.
And with the real agent we could've used the official parameters
| tests/parametric/test_telemetry.py::Test_TelemetrySCAEnvVar: v2.50.0 | ||
| tests/parametric/test_telemetry.py::Test_TelemetrySCAEnvVar::test_telemetry_sca_enabled_propagated_specifics: irrelevant | ||
| tests/parametric/test_telemetry.py::Test_TelemetrySSIConfigs: v2.53.0 | ||
| tests/parametric/test_trace_filters.py::Test_Trace_Filters: missing_feature |
There was a problem hiding this comment.
I believe dotnet does have support for this feature? https://datadoghq.atlassian.net/wiki/spaces/APM/pages/6378587288/Implementation+Status#6.-Trace-Filters-(root-span%2C-applied-BEFORE-stats)
cc/ @andrewlock could you confirm whether this should be marked as implemented?
There was a problem hiding this comment.
Looking at the test results, I see that 2 tests are failing for dotnet:
test_trace_filters_ignore_resources -> surprised this fails, it's a basic case
test_trace_filters_trim -> edge case behavior where the tag filter reject_tag : true is trimmed to be equivalent to reject_tag:true
| tracer applies them client-side. The agent version is pinned to the minimum that supports | ||
| client-side stats according to the spec. | ||
| """ | ||
| agent_version = MIN_AGENT_VERSION_FOR_CSS |
There was a problem hiding this comment.
Should we hard code the agent version here? It would be nice to have at least one test case that runs against the latest version of the agent
There was a problem hiding this comment.
I'm not sure how I would go about it tbh.
I can't just let the default version of the test agent (test won't work because it's not in the \d+.\d+.\d+ format)
This only seems possible by using the real agent, so with end-to-end tests (or by using a quick hack where I fetch it from the github release page...)
These tests were previously end-to-end so if you want I can partially revert my deletion of end-to-end tests ?
| import pytest | ||
|
|
||
| from .conftest import APMLibrary | ||
| from .test_library_tracestats import MIN_AGENT_VERSION_FOR_CSS, enable_tracestats |
There was a problem hiding this comment.
Can you move MIN_AGENT_VERSION_FOR_CSS and enable_tracestats into tests/parametric/utils.py ? (long story short, because of the CI orchestrator that determine which scneario to run, a test file should never import something from another test file.)
APMSP-2763
APMSP-3048
Motivation
Changes
Add system-tests coverage for the CSS V1.2 spec trace filters (filter_tags, filter_tags_regex, ignore_resources).
TODO
Workflow
🚀 Once your PR is reviewed and the CI green, you can merge it!
🛟 #apm-shared-testing 🛟
Reviewer checklist
tests/ormanifests/is modified ? I have the approval from R&P teambuild-XXX-imagelabel is present