Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace upload: only send traces for current session #71838

Merged
merged 1 commit into from
Oct 25, 2024

Commits on Oct 25, 2024

  1. Trace upload: only send traces for current session

    The `.next/trace` file contains trace events spanning multiple traces from different sessions. This changes our upload process to only send trace events for the current session that’s ending.
    
    Before this change, we would send a single set of metadata for many traces, but these older session traces could have been invoked with different parameters like `mode`, `isTurboSession`, etc. Because of this, we started including `isTurboSession` as a span attribute on spans, but this value was dependent on an environment variable that wasn’t always set. In this case, the top-level `next-dev` span never had the correct value.
    
    This makes it so the metadata, now always determined at upload time, always reflects the session sent, and never any others.
    
    Other bugs fixed:
    
    - Trace events within a single logical session had different trace ids because of worker threads. This aligns them.
    - Because we upload traces out-of-process, the Telemetry `sessionId` did not reflect the real session id of other analytics sent. This passes it along to the external process.
    
    Test Plan:
    
    In a test app, using `NEXT_TRACE_UPLOAD_DEBUG=1` and a running Otel server:
    - Start a non-turbopack dev session and end it. Verify trace events are sent with `isTurboSession: false` and note the trace id.
    - Start a turbopack dev session and end it. Verify trace events are sent with `isTurboSession: true` and note events are sent for this trace, and not the previous one.
    - Start a build and verify trace events are sent with `mode: build` and `isTurboSession: false` and that no older trace events are sent.
    wbinnssmith committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    30e547a View commit details
    Browse the repository at this point in the history