← Back to Pull requests

test(ai): add preserve OpenTelemetry span receiver test #9309

Closed
unknown closed this pull request without merging on Aug 05, 2026 11:26 UTC
View on GitHub
unknown unknown commented on Jul 13, 2026 18:41 UTC
Author

What does this PR do?

Builds on #9152's fix for #9151 by keeping the delegating OTel span wrapper private and making its forwarding contract exact. Every Span method runs against the real underlying span with the caller's original arguments, while chainable methods return the per-invocation wrapper and end, setAttributes, and recordException continue publishing the existing diagnostic-channel events.

The wrapper remains fresh per invocation, so the AI SDK's shared no-op span is not mutated and each publication keeps the correct invocation context.

Why is this stronger than the implementation on master?

The implementation on master fixes the private-field receiver bug, but manually restates each method signature. This version uses apply(span, arguments) so optional arguments, return behavior, and future compatible Span signature changes are forwarded without drift. The helper stays local to the instrumentation and is not exported for tests.

Test coverage

  • Exercises the AI SDK 6 error path with a real dd-trace OTel TracerProvider, asserting that the original model error is preserved and the emitted span records that error.

  • Exercises every OTel Span method through the public AI SDK instrumentation path, asserting the underlying receiver, exact arguments, chainability, and return behavior.

  • Retains the existing private-field regression across supported AI SDK 4, 5, and 6 fixtures.
  • Verification

  • Focused error and complete-delegation regressions: 8 passing across AI SDK 6.0.0 and 6.0.227 with the minimum and latest compatible OpenAI providers.

  • Retained cross-version private-field regression: 10 passing across AI SDK 4, 5, and 6 fixtures.

  • Focused ESLint: passing.

  • git diff --check: passing.
  • Diff: 220 lines (+165 / -55) across 2 files Reviewer: crysmags Review duration: 32685m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 220 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.323
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #9309"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    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: 36.8% (MEDIUM) · Higher = larger blast radius
    36.8%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 14.5% · Safe to merge
    14.5%