Skip to content

Commit

Permalink
OpenTelemetry: ignore bubble errors to avoid spamming traces (vercel#…
Browse files Browse the repository at this point in the history
…56625)

The "bubble" errors are created here: https://github.com/vercel/next.js/blob/3f25a2e747fc27da6c2166e45d54fc95e96d7895/packages/next/src/server/next-server.ts#L1636-L1639

These errors do not appear to be true errors, but they tend to spam tracing. E.g.

<img width="1412" alt="image" src="https://github.com/vercel/next.js/assets/726049/d62f3116-5f94-45ac-947c-e59ac4bfa533">
  • Loading branch information
dvoytenko authored Oct 12, 2023
1 parent 8013ef7 commit 3da643a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/next/src/server/lib/trace/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ const isPromise = <T>(p: any): p is Promise<T> => {
return p !== null && typeof p === 'object' && typeof p.then === 'function'
}

type BubbledError = Error & { bubble?: boolean }

const closeSpanWithError = (span: Span, error?: Error) => {
if (error) {
span.recordException(error)
if ((error as BubbledError | undefined)?.bubble === true) {
span.setAttribute('next.bubble', true)
} else {
if (error) {
span.recordException(error)
}
span.setStatus({ code: SpanStatusCode.ERROR, message: error?.message })
}
span.setStatus({ code: SpanStatusCode.ERROR, message: error?.message })
span.end()
}

Expand Down

0 comments on commit 3da643a

Please sign in to comment.