Skip to content

Fix span enrichment singleton initialization - #12273

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
sameerank/ffl-3090-fix-span-enrichment-singleton
Aug 24, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
sameerank/ffl-3090-fix-span-enrichment-singleton

Conversation

@sameerank

@sameerank sameerank commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What Does This Do

  • Initializes SpanEnrichmentWriter lazily after its production resolver and interceptor registrar.
  • Adds a regression test for the production singleton dependencies.
  • Adds OpenFeature smoke coverage that verifies runtime-default enrichment on a traced request.

Motivation

Feature-flag evaluations succeed, but span enrichment silently fails because the eager singleton captures null dependencies during static initialization. The failure is visible in debug logs as:

DEBUG com.datadog.featureflag.SpanEnrichmentWriter - Span-enrichment accumulation failed
NullPointerException: Cannot invoke RootSpanResolver.activeLocalRoot()
because this.rootSpanResolver is null

Consequently, span-enrichment events were dropped, and traces were emitted without the expected feature-flag tags.

Additional Notes

  • The existing experimental span-enrichment gate remains unchanged.
  • Focused unit and OpenFeature smoke tests pass after rebasing onto master.
  • Verified ingestion of traces from the dogfooding app running the Java SDK
Screenshot 2026-08-24 at 6 56 38 AM

Contributor Checklist

  • Title follows the contribution guidelines.
  • Component and change-type labels are assigned.
  • No CODEOWNERS or public configuration documentation changes are required.

Jira ticket: FFL-3090

@sameerank sameerank added type: bug fix Bug fix tag: ai generated Largely based on code generated by an AI or LLM comp: openfeature OpenFeature labels Aug 24, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 24, 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 14.04 s 13.97 s [-0.5%; +1.5%] (no difference)
startup:insecure-bank:tracing:Agent 12.99 s 13.09 s [-1.8%; +0.2%] (no difference)
startup:petclinic:appsec:Agent 17.47 s 17.29 s [+0.1%; +1.9%] (maybe worse)
startup:petclinic:iast:Agent 17.39 s 16.50 s [-2.1%; +12.9%] (unstable)
startup:petclinic:profiling:Agent 17.35 s 17.41 s [-1.7%; +1.0%] (no difference)
startup:petclinic:sca:Agent 16.95 s 17.18 s [-5.6%; +2.9%] (no difference)
startup:petclinic:tracing:Agent 16.56 s 16.60 s [-1.0%; +0.5%] (no difference)

Commit: 3fea5236 · 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.

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Aug 24, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 76.79% (+17.99%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3fea523 | Docs | View more details | Give us feedback!

@sameerank
sameerank marked this pull request as ready for review August 24, 2026 15:12
@sameerank
sameerank requested a review from a team as a code owner August 24, 2026 15:12
@sameerank
sameerank requested review from greghuels and pavlokhrebto and removed request for a team August 24, 2026 15:12

@datadog-datadog-us1-prod datadog-datadog-us1-prod 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.

Datadog Autotest: PASS

More details

The lazy holder creates the singleton after its production dependencies and keeps the same process-wide writer across restarts.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 3fea523 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@leoromanovsky leoromanovsky left a comment

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.

Thanks for finding and resolving this. What made it missed in system tests?

@sameerank

Copy link
Copy Markdown
Contributor Author

What made it missed in system tests?

The regression test for this already exists: Test_Span_Enrichment_Default_Fallback evaluates a missing flag inside a span and requires ffe_runtime_defaults, so it would have failed with the null resolver. However, it is marked as missing_feature: https://github.com/DataDog/system-tests/blob/f2a487de79d9771b7fbd8402a97324ad8b9f6f77/manifests/java.yml#L3876

So that needs to be updated

@sameerank
sameerank added this pull request to the merge queue Aug 24, 2026
@dd-octo-sts

dd-octo-sts Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Aug 24, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-08-24 16:13:00 UTC ℹ️ Start processing command /merge


2026-08-24 16:13:04 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-08-24 17:13:52 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 24, 2026
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit 5c41117 into master Aug 24, 2026
604 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the sameerank/ffl-3090-fix-span-enrichment-singleton branch August 24, 2026 17:13
@github-actions github-actions Bot added this to the 1.66.0 milestone Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: openfeature OpenFeature tag: ai generated Largely based on code generated by an AI or LLM type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants