Skip to content

Prevent Pekko stream lifecycle context retention - #12470

Open
amarziali wants to merge 1 commit into
masterfrom
andrea.marziali/fix-pekko-http-iast-scope
Open

Prevent Pekko stream lifecycle context retention#12470
amarziali wants to merge 1 commit into
masterfrom
andrea.marziali/fix-pekko-http-iast-scope

Conversation

@amarziali

Copy link
Copy Markdown
Contributor

What Does This Do

Pekko HTTP registers a shutdown callback from StreamUtils.preStart(). When this happens during a request, Scala’s callback instrumentation captures the active context and retains it until the stream shuts down.

This change temporarily disables async propagation only while that callback is registered. It uses the existing context-tracking instrumentation, without creating a no-op span or affecting the active request
context.

  flowchart LR
      A[Active request context] --> B[StreamUtils.preStart]
      B -->|async propagation disabled| C[Register shutdown callback]
      C --> D[Restore async propagation]
      A -. not captured .-> C
Loading

Why?

The shutdown callback belongs to the stream lifecycle, not to the request that happened to initialize it. Propagating the request context there creates a continuation that can remain unresolved until server
shutdown.

The matcher is limited to the exact Pekko stream-stage type and its preStart() method.

Akka

Akka has similar code, but its equivalent IAST scenario does not retain a continuation. Tests passed with Akka HTTP 10.1, 10.2, and the latest supported dependencies, so no speculative Akka suppression was added.

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@amarziali amarziali added the type: bug fix Bug fix label Sep 11, 2026
@amarziali
amarziali requested review from a team as code owners September 11, 2026 16:12
@amarziali amarziali added the inst: others All other instrumentations label Sep 11, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-11T16:15:18.677626Z 9c27dfe PR opened
🔒 Security Review Completed 2026-09-11T16:16:48.858798Z 9c27dfe PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-prod-us1-6 datadog-prod-us1-6 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 exact Pekko stream-stage matcher applies existing async propagation control only during preStart. The advice restores propagation after each exit.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@datadog-prod-us1-6

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 69.74% (+10.60%)

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

@dd-octo-sts

dd-octo-sts Bot commented Sep 11, 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.00 s 14.00 s [-0.9%; +0.9%] (no difference)
startup:insecure-bank:tracing:Agent 12.90 s 12.99 s [-1.4%; +0.1%] (no difference)
startup:petclinic:appsec:Agent 16.93 s 16.27 s [-0.3%; +8.4%] (no difference)
startup:petclinic:iast:Agent 16.88 s 16.91 s [-1.0%; +0.6%] (no difference)
startup:petclinic:profiling:Agent 16.67 s 16.87 s [-2.5%; +0.1%] (no difference)
startup:petclinic:sca:Agent 16.88 s 16.71 s [+0.0%; +2.0%] (maybe worse)
startup:petclinic:tracing:Agent 15.97 s 15.96 s [-0.9%; +1.1%] (no difference)

Commit: 9c27dfed · 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.

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

Labels

inst: others All other instrumentations type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant