Add Test_AnomalyDetectionTags for AI Guard span enrichment#6784
Add Test_AnomalyDetectionTags for AI Guard span enrichment#6784
Conversation
|
@codex review |
|
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5309eb6ed5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
🎉 All green!❄️ No new flaky tests detected 🔗 Commit SHA: e81dfc6 | Docs | Datadog PR Page | Give us feedback! |
Add a new test class that verifies anomaly detection attributes are propagated from the local root span into every AI Guard span with the ai_guard. prefix: - ai_guard.http.client_ip - ai_guard.network.client.ip - ai_guard.http.useragent - ai_guard.usr.id - ai_guard.session.id Update the /ai_guard/evaluate endpoint in all weblogs to accept two new optional HTTP headers: - X-User-Id: sets usr.id on the local root span - X-Session-Id: sets session.id on the local root span The two headers are handled independently. All languages use the local root span API (not the active/current span) to ensure tags land on the right span: - Python: tracer.current_root_span() - Node.js: tracer.scope().active()?.context()._trace.started[0] - Java: ((MutableSpan) activeSpan).getLocalRootSpan() - Ruby: Datadog::Tracing.active_trace The test is marked missing_feature (APPSEC-62448) across all tracers. Manifests and endpoint docs updated accordingly.
5309eb6 to
e81dfc6
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e81dfc6514
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| interfaces.library.validate_one_span( | ||
| self.r, | ||
| validator=self._assert_span(root_span=root_span), | ||
| full_trace=True, | ||
| ) |
There was a problem hiding this comment.
Validate anomaly tags on every AI Guard span
The new test claims to verify propagation to every ai_guard span, but it calls validate_one_span, which stops after the first matching span and leaves any additional ai_guard spans unchecked. If a trace contains multiple AI Guard spans (for example, after SDK/tracer changes), a regression on later spans would pass unnoticed, so this test does not enforce the behavior described by the class and method docs.
Useful? React with 👍 / 👎.
PerfectSlayer
left a comment
There was a problem hiding this comment.
Approved for the java part (java manifest + SB controller)
Motivation
APPSEC-62448
Changes
Add a new test class that verifies anomaly detection attributes are propagated from the local root span into every AI Guard span with the ai_guard. prefix:
ai_guard.http.client_ipai_guard.network.client.ipai_guard.http.useragentai_guard.usr.idai_guard.session.idUpdate the
/ai_guard/evaluateendpoint in all weblogs to accept two new optional HTTP headers:X-User-Id: setsusr.idon the local root spanX-Session-Id: setssession.idon the local root spanWorkflow
🚀 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