Skip to content

Add css obfuscation test [APMSP-2764]#6648

Draft
Eldolfin wants to merge 10 commits intomainfrom
oscarld/add-css-obfuscation-test
Draft

Add css obfuscation test [APMSP-2764]#6648
Eldolfin wants to merge 10 commits intomainfrom
oscarld/add-css-obfuscation-test

Conversation

@Eldolfin
Copy link
Copy Markdown
Contributor

@Eldolfin Eldolfin commented Mar 31, 2026

btw I don't get the fail in test_the_tests because the new scenario TRACE_STATS_COMPUTATION_OBFUSCATION_DISABLED has agent_env variables that the existing TRACE_STATS_COMPUTATION doesn't so they're not equivalent.

Motivation

  • Test that libraries obfuscate spans before sending them to /stats

Changes

  • Add one testcase (is this considered a new feature ?)
  • Fix 2 small issues I found while looking at the repo

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

@Eldolfin Eldolfin changed the title Oscarld/add css obfuscation test [APMSP-2764] Add css obfuscation test [APMSP-2764] Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

CODEOWNERS have been resolved as:

.github/workflows/run-end-to-end.yml                                    @DataDog/system-tests-core
tests/stats/test_stats.py                                               @DataDog/system-tests-core
utils/_context/_scenarios/__init__.py                                   @DataDog/system-tests-core
utils/_context/_scenarios/endtoend.py                                   @DataDog/system-tests-core
utils/_context/containers.py                                            @DataDog/system-tests-core
utils/proxy/mocked_response.py                                          @DataDog/system-tests-core

@Eldolfin Eldolfin force-pushed the oscarld/add-css-obfuscation-test branch from 4871555 to 0cf62ff Compare March 31, 2026 11:09
@datadog-datadog-prod-us1

This comment has been minimized.

Comment thread utils/build/docker/python/flask/app.py Outdated
Comment thread tests/stats/test_stats.py Outdated
Comment on lines +163 to +164
assert headers["datadog-obfuscation-version"] == "1", (
f"Expected obfuscation version '1', got '{headers['datadog-obfuscation-version']}'"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should check for >=1 to make sure the test still passes if a tracer updates to a v2 someday

@Eldolfin Eldolfin force-pushed the oscarld/add-css-obfuscation-test branch from 0cf62ff to 714e99a Compare April 2, 2026 11:32
Comment thread tests/stats/test_stats.py Outdated
Comment thread tests/stats/test_stats.py Outdated

assert obfuscation_header_found, "Datadog-Obfuscation-Version header not found on any stats payload"

assert len(sql_stats) > 0, "Expected at least one SQL stats entry"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, is there something that can cause len(sql_stats) to not be 4 (1,2,admin,test), or is it just to make it easier to add more values to test_user_ids ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason stats appear to be sent twice by dd-trace-py so len(sql_stats) == 8 but I feel like other tracers might send them only once which would also be correct for this test. I could however assert that each bucket has 4 stats entry if you want

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I just tried it again and what I just said was something I misremembered from when I started working on this. it is indeed == 4 so I just change it to that instead

"DD_TRACE_TRACER_METRICS_ENABLED": "true", # java
},
agent_env={
"DD_APM_SQL_OBFUSCATION_MODE": "normalize_only",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything about disabling the obfuscation in the spec is it done by setting the obfuscation version to 0 (if not maybe we need a scenario for the missing/version 0 case)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a setting from the CSS spec but to avoid breaking changes in the obfuscation behavior when switching from agent obfuscation to client obfuscation I decided that following as much of the config as possible would be preferable.

https://github.com/DataDog/datadog-agent/blob/main/pkg/config/config_template.yaml#L1633

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants