Skip to content

Prevent OkHttp TaskRunner from retaining request contexts - #12468

Open
amarziali wants to merge 1 commit into
masterfrom
andrea.marziali/diag-fix-okhttp-taskrunner-continuation
Open

Prevent OkHttp TaskRunner from retaining request contexts#12468
amarziali wants to merge 1 commit into
masterfrom
andrea.marziali/diag-fix-okhttp-taskrunner-continuation

Conversation

@amarziali

@amarziali amarziali commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Excludes OkHttp's internal TaskRunner worker loop from generic Runnable context propagation.

TaskRunner$runnable$1 is a long-lived scheduler loop, not a single request task. Capturing the submitting request context on it keeps that trace open until the runner becomes idle, causing delayed or missing traces.

Individual OkHttp tasks already handle their own request context, so the scheduler itself should not inherit one.

flowchart LR
    A[Test worker<br/>okhttp.request active]
    B[OkHttp TaskRunner<br/>long-lived scheduler]
    C[Individual HTTP task]
    D[Request completes]

    A -->|🔴 previous: capture context| B
    B -->|scope retained until idle| R[🔴 Scope left open]

    A -->|🟢 request handoff| C
    C --> D
    D -->|close request scope| G[🟢 Trace is written]

    A -. TaskRunner excluded .-> B
Loading

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@amarziali
amarziali requested a review from a team as a code owner September 11, 2026 15:12
@amarziali
amarziali requested review from dougqh and removed request for a team September 11, 2026 15:12
@amarziali amarziali added type: bug fix Bug fix inst: okhttp Square OkHttp instrumentation labels 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-11T15:17:33.141764Z 6922111 PR opened
🔒 Security Review Completed 2026-09-11T15:16:45.731741Z 6922111 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-4 datadog-prod-us1-4 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 OkHttp TaskRunner exclusion has a narrow scope. It blocks generic Runnable context capture for TaskRunner nested classes and does not change other exclusion types.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@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: 69221116cf

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

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Sep 11, 2026

Copy link
Copy Markdown

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 62.88% (+3.74%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6922111 | 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.77 s 14.57 s [+0.4%; +2.4%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.62 s 13.69 s [-1.5%; +0.4%] (no difference)
startup:petclinic:appsec:Agent 16.95 s 16.78 s [+0.2%; +1.9%] (maybe worse)
startup:petclinic:iast:Agent 16.77 s 16.94 s [-1.7%; -0.2%] (maybe better)
startup:petclinic:profiling:Agent 16.66 s 16.70 s [-1.1%; +0.6%] (no difference)
startup:petclinic:sca:Agent 16.85 s 16.58 s [+0.7%; +2.6%] (maybe worse)
startup:petclinic:tracing:Agent 16.07 s 16.25 s [-2.1%; -0.2%] (maybe better)

Commit: 69221116 · 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: okhttp Square OkHttp instrumentation type: bug fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant