Skip to content

Fix Akka and Pekko HTTP flow scope ownership - #12701

Draft
amarziali wants to merge 1 commit into
masterfrom
andrea.marziali/akka-pekko-flow-scope-order
Draft

amarziali wants to merge 1 commit into
masterfrom
andrea.marziali/akka-pekko-flow-scope-order

Conversation

@amarziali

Copy link
Copy Markdown
Contributor

What Does This Do

Akka and Pekko HTTP response callbacks can close a request scope after actor cleanup already closed it, sometimes from another thread. Checking whether the request span is active does not establish ownership of the original scope.

Queue request contexts instead of scopes. Actor invocation cleanup remains responsible for scope closure, while response callbacks decorate and finish spans.

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@amarziali
amarziali requested a review from a team as a code owner September 30, 2026 12:46
@amarziali
amarziali removed the request for review from a team September 30, 2026 12:46
@amarziali amarziali added the type: bug fix Bug fix label Sep 30, 2026
@amarziali amarziali added the inst: akka Akka instrumentation label Sep 30, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 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-30T12:56:41.551829Z 7afe7de PR opened
🔒 Security Review ✅ Completed 2026-09-30T12:56:10.555251Z 7afe7de 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.

@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: 7afe7deec7

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

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +143 to 145
DatadogWrapperHelper.finishSpan(context, response);
}
push(responseOutlet, response);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore the context before pushing synchronous responses

When a fused or synchronous handler returns a response within the same actor invocation, actor cleanup has not run yet, so this finishes the server span while its context is still current and then push(responseOutlet, response) executes downstream stages under that finished span. The actor advice restores the checkpoint only when ActorCell.invoke exits, which can cause response-stage work, logging, or nested instrumentation to use an incorrect parent; retain a safe way to detach the request context before the push when it is still current. The parallel Pekko change at lines 114–116 has the same issue.

AGENTS.md reference: AGENTS.md:L43-L46

Useful? React with 👍 / 👎.

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

Bits Code Review: PASS

More details

Response callbacks now finish spans from queued contexts without closing actor-owned scopes, while both Akka and Pekko paths retain their in-order request/response matching.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 7afe7de · @DataDog review to ask questions

@datadog-datadog-prod-us1-2

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Sep 30, 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.01 s 13.96 s [-0.4%; +1.1%] (no difference)
startup:insecure-bank:tracing:Agent 12.93 s 13.04 s [-1.5%; -0.2%] (maybe better)
startup:petclinic:appsec:Agent 17.07 s 16.69 s [+1.4%; +3.2%] (significantly worse)
startup:petclinic:iast:Agent 16.96 s 17.01 s [-1.3%; +0.8%] (no difference)
startup:petclinic:profiling:Agent 16.04 s 16.19 s [-7.0%; +5.2%] (unstable)
startup:petclinic:sca:Agent 16.95 s 16.91 s [-0.7%; +1.2%] (no difference)
startup:petclinic:tracing:Agent 16.15 s 16.22 s [-1.3%; +0.4%] (no difference)

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

@amarziali
amarziali marked this pull request as draft September 30, 2026 18:56

This branch has not been deployed

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

Labels

inst: akka Akka instrumentation type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant