Skip to content

[JS] Tracing missing "root" span for nextjs #434

Closed
@i2amsam

Description

@i2amsam

Describe the bug
When prod traces are logged with autoInstrumentation=true some traces fail to be shown in the DevUI. The proximate cause is that traces are logged without a startTime attribute on the span. You will also see spans in GCP with "Missing span ID" errors. The start/end dates are missing for the same reason. We determined that turning off autoinstrumentation restores startTime, because the root span will be provided by Genkit in that case.

Upon further investigation, this appears to be attributed to Nextjs specific behavior. Sentry also encountered this issue: getsentry/sentry-javascript#11046. Most likely Nextjs specific implementation details are required to resolve. Nextjs provides a "hook" (instrumentation.ts) for initializing OTel. See also: https://nextjs.org/docs/app/api-reference/file-conventions/instrumentation.

To Reproduce
Steps to reproduce the behavior. Code samples.

Expected behavior
All prod traces in the remote tracestore should be viewable in the DevUI

Screenshots
Here's an example trace in Firestore without startTime

image

And in cloud trace (missing root span)
image

Runtime (please complete the following information):
NextJS app deployed to Firebase App Hosting

Metadata

Metadata

Labels

bugSomething isn't workingjs

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions