Add span tags to AI Guard spans for Anomaly Detection#5752
Conversation
Typing analysisNote: Ignored files are excluded from the next sections.
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 1c93f9e | Docs | Datadog PR Page | Give us feedback! |
080a84a to
cd71108
Compare
BenchmarksBenchmark execution time: 2026-05-28 08:53:15 Comparing candidate commit 1c93f9e in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 45 metrics, 1 unstable metrics.
|
ad91751 to
de1d85b
Compare
Strech
left a comment
There was a problem hiding this comment.
I have 2 minor concerns to raise and it would be good to know how complex it to type with steep as most of the methods excluded
What does this PR do?
This PR adds tags that are required for Anomaly Detection to AI Guard spans:
ai_guard.http.useragent,ai_guard.http.client_ip, andai_guard.network.client.ip.Since AI Guard has no access to Rack env, we have to stash those attributes in the active trace under
_dd.ai_guardprefix, set them on AI Guard span when AI Guard evaluation runs, and remove them from the active trace.Out of scope for this PR:
Datadog::Tracing.active_trace- since it will require review from tracing team.ai_guard.usr.idandai_guard.session_idtags - this requires code changes for AppSec, and needs to be well thought throughMotivation:
We want to support Anomaly Detection in Ruby AI Guard SDK.
Change log entry
No. The follow-up PR with user and session IDs will have a changelog entry.
Additional Notes:
APPSEC-62451
How to test the change?
CI and manual testing.