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

feat(koa): Update scope transactionName when creating router span #11476

Merged
merged 2 commits into from
Apr 10, 2024

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Apr 8, 2024

This PR updates the current scope's transactionName in our Koa integration. Unfortunately, I didn't find a reliable way to get the parameterized route in our error handler/via app.use because similarly to Express, koa doesn't seem to expose this information before going through the actual route layers. A couple of stackoverflow posts suggest a way if potentially obtaining a routename via a private ctx variable but in my testing this didn't work. Seems like there are multiple versions of koa-router/@koa/router where some support this and others don't...

Consequence: In case of a negative sampling decision for the span, we can't update the scope's transaction name which most likely will be the unparameterized route set by our Http integration.

ref #10846

@Lms24 Lms24 requested review from mydea and s1gr1d April 8, 2024 12:37
instrumentations: [
new KoaInstrumentation({
requestHook(span, info) {
if (span.isRecording() && info.layerType === 'router') {
Copy link
Member

Choose a reason for hiding this comment

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

l: do we need this check? Can we not just directly check if the HTTP_ROUTE attribute exist, and if so use it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we can 🤔 I wanted to play it safe. q: is it safe to call spanToJSON on a non-recording span?

Copy link
Member

Choose a reason for hiding this comment

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

yes, it will just return {} then, basically!

@Lms24 Lms24 force-pushed the lms/feat-koa-update-scope-transactionName branch from 4a3c92f to 7cdd7f4 Compare April 9, 2024 13:12
Copy link
Contributor

github-actions bot commented Apr 9, 2024

size-limit report 📦

Path Size
@sentry/browser 22.1 KB (0%)
@sentry/browser (incl. Tracing) 31.71 KB (0%)
@sentry/browser (incl. Tracing, Replay) 66.92 KB (0%)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 60.52 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) 70.75 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) 75.67 KB (0%)
@sentry/browser (incl. Feedback) 30.87 KB (0%)
@sentry/browser (incl. Feedback, Feedback Modal) 30.88 KB (0%)
@sentry/browser (incl. Feedback, Feedback Modal, Feedback Screenshot) 30.89 KB (0%)
@sentry/browser (incl. sendFeedback) 26.88 KB (0%)
@sentry/react 24.78 KB (0%)
@sentry/react (incl. Tracing) 34.61 KB (0%)
@sentry/vue 25.53 KB (0%)
@sentry/vue (incl. Tracing) 33.44 KB (0%)
@sentry/svelte 22.23 KB (0%)
CDN Bundle 24.11 KB (0%)
CDN Bundle (incl. Tracing) 32.66 KB (0%)
CDN Bundle (incl. Tracing, Replay) 66.37 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) 71.63 KB (0%)
CDN Bundle - uncompressed 71.67 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 97.71 KB (0%)
CDN Bundle (incl. Tracing, Replay) - uncompressed 207.1 KB (0%)
@sentry/nextjs (client) 33.8 KB (0%)
@sentry/sveltekit (client) 32.24 KB (0%)
@sentry/node 120.03 KB (+0.08% 🔺)

@Lms24 Lms24 requested a review from mydea April 9, 2024 13:44
@Lms24 Lms24 self-assigned this Apr 9, 2024
@Lms24 Lms24 merged commit a1bb8d0 into develop Apr 10, 2024
79 checks passed
@Lms24 Lms24 deleted the lms/feat-koa-update-scope-transactionName branch April 10, 2024 09:09
cadesalaberry pushed a commit to cadesalaberry/sentry-javascript that referenced this pull request Apr 19, 2024
…etsentry#11476)

Update the current scope's `transactionName` in our Koa
integration. Unfortunately, I didn't find a reliable way to get the
parameterized route in our error handler/via `app.use` because similarly
to Express, koa doesn't seem to expose this information before going
through the actual route layers.
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.

3 participants