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

fix(tracing): set prisma parent span on the scope #5781

Closed
wants to merge 1 commit into from

Conversation

AbhiPrasad
Copy link
Member

Fixes #5779

Make sure we set parent span of span that generated prisma span on the scope after span is finished so parent child relationship is held properly.

We do this by introducing a tracing utility, that:

  • starts a span
  • does the callback
  • if the callback is a promise
    • finish the span in a .then callback, return the value
  • else
    • finish the span and return the value

the tracing utility also handles errors, and makes sure that the correct span is on the scope.

Make sure that correct prisma parent is put on the scope
so that the parent child relationship between child spans holds.
Comment on lines +47 to +52
// if the parent span is already finished, put the transaction on the scope
if (parentSpan?.endTimestamp) {
scope?.setSpan(transaction);
} else {
scope?.setSpan(parentSpan);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about this logic, but feedback appreciated.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.47 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 60.16 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.06 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 53.08 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.85 KB (0%)
@sentry/browser - Webpack (minified) 64.49 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.88 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.74 KB (+0.03% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.93 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.33 KB (0%)

@AbhiPrasad AbhiPrasad marked this pull request as draft September 20, 2022 13:09
@AbhiPrasad
Copy link
Member Author

Going to close this for now, we can come back to it later on - but it's good we tried the trace func out.

@AbhiPrasad AbhiPrasad closed this Sep 20, 2022
@AbhiPrasad AbhiPrasad deleted the abhi-parent-child-prisma branch September 20, 2022 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NextJS doesn't wrap API routes so DB Spans are only attached to root transaction
1 participant