← Back to Pull requests

feat: propagate configured request headers through query and task con… #20920

Open
unknown opened this pull request with 461 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 17, 2026 20:06 UTC
Author

Description

Allows correlation metadata from inbound HTTP headers to follow Druid queries and submitted tasks.

Adds druid.request.headers.headerToContextKey to map HTTP headers to query and task context keys. The default mapping is X-Druid-Trace-Id → traceId; custom mappings replace the default, and {} disables configured capture and propagation. Configure participating services and task processes consistently, and restart them after changes.

Configured headers are captured after authentication and copied into native query, SQL query, and HTTP-submitted task context. Captured values override matching context values; missing, blank, or invalid header values preserve existing values. Query-context authorization applies to captured and inherited query keys.

The change:

  • Preserves configured metadata across query and task execution, lazy results, and supported asynchronous execution paths. Scoped state is restored when work completes or fails.

  • Forwards configured headers on native query fan-out and cancellation, internal service requests, and supported Netty, HTTP ingestion, S3, and AWS STS calls. Explicit outbound header values take precedence.

  • Includes captured metadata in audit entries under request.requestMetadata, omitted when empty.
  • Druid does not generate IDs. Authentication extensions can supply missing IDs before capture through Authenticator.getFilter(). RequestHeaders and RequestHeaderContextConfig.fromContext(...) provide integration hooks for extensions and clients outside the paths covered here. This PR does not add OpenTelemetry spans or exporters.

    Issue #11246 - Opentracing / Opentelemetry Support.
    This PR extends and proposes a narrower alternative to #19572: configurable header capture, query and submitted task context transport, native query forwarding, and audit metadata. Request state stays on the HTTP request and in serialized operation context. ID generation and service-specific client propagation remain extension responsibilities.

    Validation

    Focused tests cover configuration, request capture, SQL and native query context, task submission, audit metadata, and native query forwarding and cancellation. Checkstyle, documentation spellcheck, and whitespace checks passed.

    Release note

    Druid can capture configured HTTP headers into query and submitted task context, forward them on native query fan-out and cancellation requests, and include captured metadata in audit entries. Configure the mapping with druid.request.headers.headerToContextKey.

    <hr>

    ##### Key changed/added classes in this PR

  • RequestHeaderContextConfig

  • RequestHeaderContextFilterHolder

  • RequestHeaders

  • QueryLifecycle

  • DirectDruidClient

  • ServiceClientImpl

  • Execs and ScheduledExecutors

  • NettyHttpClient

  • S3RequestHeaderInterceptor

  • RequestInfo
  • <hr>

    This PR has:

  • been self-reviewed.

  • added documentation for new or modified features or behaviors.

  • a release note entry in the PR description.

  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.

  • added or updated version, license, or notice information in licenses.yaml

  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.

  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.

  • added integration tests.

  • been tested in a test Druid cluster.
  • Diff: 461 lines (+345 / -116) across 5 files Reviewer: agali-09 Review duration: 18456m
    All Vouch review confidence checks passed
    Residual risk 0.37 = Change Risk (0.69) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.69 · 461 lines diff across 5 files
    0.69
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.367
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.069
    Real PR Conversation Timeline
    1 comments
    "Review active on #20920"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 46.7% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 68.7% (HIGH) · Higher = larger blast radius
    68.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 36.6% · Moderate risk
    36.6%
    Repository