Skip to content

Support DD_APM_TRACING_ENABLED=false for AI Guard traces#11885

Open
claponcet wants to merge 5 commits into
masterfrom
clara.poncet/ai-guard-standalone
Open

Support DD_APM_TRACING_ENABLED=false for AI Guard traces#11885
claponcet wants to merge 5 commits into
masterfrom
clara.poncet/ai-guard-standalone

Conversation

@claponcet

@claponcet claponcet commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

When DD_APM_TRACING_ENABLED=false, AI Guard traces are now preserved and sent
to the backend. The tracer no longer lets the sampler override the USER_KEEP
priority that AI Guard sets via ai_guard.keep.

Concretely, TraceCollector.setSamplingPriorityIfNecessary gains a guard: if a
span carries ai_guard.event=true, the sampler is skipped (whether that sampler
is the regular priority sampler or the AsmStandaloneSampler rate-limiter used
in ASM standalone mode).

The ai_guard.event tag is also promoted from a local string constant in
AIGuardInternal to a canonical constant in Tags, alongside ai_guard.keep.

Root spans for AI Guard evaluations carry:

  • _sampling_priority_v1:2 (USER_KEEP) — set by forceKeep(SamplingMechanism.AI_GUARD)
  • _dd.p.dm:-13 (decision maker: AI Guard) — set by the same mechanism
  • ai_guard.event:true

Motivation

Part of APPSEC-61460 (AI Guard without APM billing). AI Guard customers should
not require APM host billing. Unlike ASM standalone mode, AI Guard does not need
the "1 trace per minute" allowance — every AI Guard trace must go through.

Additional Notes

The AsmStandaloneSampler (used when APM is disabled and AppSec is enabled)
has a rate limiter that allows only 1 trace/minute for regular APM traces. The
new bypass ensures AI Guard traces are never dropped by this limiter, while
regular traces remain subject to it.

Contributor Checklist

  • Format the title according to the contribution guidelines
  • Assign the type: and (comp: or inst:) labels in addition to any other useful labels
  • Avoid using close, fix, or any linking keywords when referencing an issue
    Use solves instead, and assign the PR milestone to the issue
  • Update the CODEOWNERS file on source file addition, migration, or deletion
  • Update public documentation with any new configuration flags or behaviors
  • Add your completed PR to the merge queue by commenting /merge. You can also:
    • Customize the commit message associated with the merge with /merge --commit-message "..."
    • Remove your PR from the merge queue with /merge -c
    • Skip all merge queue checks with /merge -f --reason "reason"; please use this judiciously, as some checks do not run at the PR-level (note: the PR still needs to be mergeable, this will only skip the pre-merge build)
    • Get more information in this doc

Jira ticket: APPSEC-68487

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claponcet claponcet added type: feature Enhancements and improvements comp: ai-guard AI Guard labels Jul 8, 2026
@claponcet

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42d77deb22

ℹ️ 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".

@claponcet claponcet marked this pull request as ready for review July 8, 2026 12:41
@claponcet claponcet requested review from a team as code owners July 8, 2026 12:41
@claponcet claponcet requested review from daniel-romano-DD, manuel-alvarez-alvarez and mcculls and removed request for a team July 8, 2026 12:41
@dd-octo-sts dd-octo-sts Bot added the tag: ai generated Largely based on code generated by an AI or LLM label Jul 8, 2026
@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 56.58% (-0.46%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2490539 | Docs | Datadog PR Page | Give us feedback!

Comment thread dd-trace-core/src/main/java/datadog/trace/core/TraceCollector.java Outdated
@dd-octo-sts

dd-octo-sts Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 13.98 s 13.97 s [-0.5%; +0.6%] (no difference)
startup:insecure-bank:tracing:Agent 12.94 s 13.04 s [-1.5%; +0.0%] (no difference)
startup:petclinic:appsec:Agent 16.83 s 16.64 s [+0.2%; +2.1%] (maybe worse)
startup:petclinic:iast:Agent 16.78 s 16.96 s [-1.9%; -0.2%] (maybe better)
startup:petclinic:profiling:Agent 16.43 s 16.70 s [-6.2%; +3.0%] (no difference)
startup:petclinic:sca:Agent 16.91 s 16.87 s [-0.7%; +1.2%] (no difference)
startup:petclinic:tracing:Agent 16.05 s 16.39 s [-3.1%; -1.1%] (significantly better)

Commit: 2490539f · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@claponcet claponcet requested a review from smola July 10, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: ai-guard AI Guard tag: ai generated Largely based on code generated by an AI or LLM type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants