← Back to Pull requests

stdouttrace: preserve input event timestamps with WithoutTimestamps #9092

Closed
unknown closed this pull request without merging on Oct 08, 2026 16:32 UTC
View on GitHub
unknown unknown commented on Oct 07, 2026 07:04 UTC
Author

Using stdouttrace.WithoutTimestamps() clears event timestamps in the original input span because SpanStubFromReadOnlySpan retains the event slice. A later exporter receiving the same span consequently sees zero event timestamps.

Clone the event slice before clearing timestamps. The copy is only needed when timestamps are disabled; event attributes are not modified.

The regression test exports the same span before and after a timestamp-free export, checks that the timestamp-free JSON has zero timestamps, and verifies that the subsequent normal export is identical to the original. It fails on the unmodified implementation.

Validation:

  • go test -race ./... in exporters/stdout/stdouttrace

  • make precommit (passed, including all module tests with -race)
  • The focused two-event benchmark adds one allocation (144 bytes) per export to preserve the input. The existing timestamp-enabled benchmarks retain their allocation counts. Timing results are local measurements and show some run-to-run variation.

    <details>
    <summary>benchstat: before and after (Go 1.26.0, darwin/arm64)</summary>

    Command: go test -run '^$' -bench BenchmarkExporter -benchtime=200ms -count=6 (same benchmark source on both revisions).

    goos: darwin
    goarch: arm64
    pkg: go.opentelemetry.io/otel/exporters/stdout/stdouttrace
    cpu: Apple M1 Pro
                                          │ before │     after      │
                                          │           sec/op           │    sec/op     vs base              │
    ExporterWithoutTimestamps-8                           4.864µ ±  2%   4.951µ ±  6%  +1.79% (p=0.009 n=6)
    ExporterExportSpans/Observability-8                   14.47µ ±  3%   14.91µ ± 16%  +3.09% (p=0.041 n=6)
    ExporterExportSpans/NoObservability-8                 15.34µ ± 14%   15.52µ ± 43%       ~ (p=0.818 n=6)
    geomean                                               10.26µ         10.47µ        +2.02%
    
                                          │ before │      after      │
                                          │            B/op            │     B/op      vs base               │
    ExporterWithoutTimestamps-8                           1.244Ki ± 0%   1.385Ki ± 0%  +11.30% (p=0.002 n=6)
    ExporterExportSpans/Observability-8                   3.976Ki ± 0%   3.975Ki ± 0%        ~ (p=0.242 n=6)
    ExporterExportSpans/NoObservability-8                 3.975Ki ± 0%   3.975Ki ± 0%        ~ (p=0.545 n=6)
    geomean                                               2.699Ki        2.797Ki        +3.63%
    
                                          │ before │     after      │
                                          │         allocs/op          │ allocs/op   vs base                │
    ExporterWithoutTimestamps-8                             21.00 ± 0%   22.00 ± 0%  +4.76% (p=0.002 n=6)
    ExporterExportSpans/Observability-8                     64.00 ± 0%   64.00 ± 0%       ~ (p=1.000 n=6) ¹
    ExporterExportSpans/NoObservability-8                   64.00 ± 0%   64.00 ± 0%       ~ (p=1.000 n=6) ¹
    geomean                                                 44.14        44.83       +1.56%
    ¹ all samples are equal
    

    </details>

    Diff: 388 lines (+291 / -97) across 4 files Reviewer: dmathieu Review duration: 2007m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 388 lines diff across 4 files
    0.43
    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.357
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #9092"
    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: 43.1% (MEDIUM) · Higher = larger blast radius
    43.1%
    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: 17% · Safe to merge
    17%