-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(astro): Isolate request instrumentation middleware on server side #9709
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
Conversation
size-limit report 📦
|
headers.forEach((value, key) => { | ||
allHeaders[key] = value; | ||
}); | ||
const { dynamicSamplingContext, traceparentData, propagationContext } = tracingContextFromHeaders( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can now use continueTrace
for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, will change it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! 89c1ec0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Great call - avoiding duplicating this logic is worth the refactor)
d3a2f0e
to
7f908d9
Compare
@@ -226,7 +226,6 @@ export function continueTrace<V>( | |||
* These values can be obtained from incoming request headers, | |||
* or in the browser from `<meta name="sentry-trace">` and `<meta name="baggage">` HTML tags. | |||
* | |||
* It also takes an optional `request` option, which if provided will also be added to the scope & transaction metadata. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line was outdated, the function doesn't take a request arg anymore
@anonrig if you're curious, this PR deals with Node AsyncLocalStorage and how we use it to isolate request context |
return res; | ||
} catch (e) { | ||
sendErrorToSentry(e); | ||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: This will change the error stack. If we want to change this, we need something like hideStackFrames
in Node.js. Is it intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this creates stack frames but when processing them in the Sentry backend, we remove them. You can compare the stack trace and the raw original stack trace on this event: https://sentry-sdks.sentry.io/issues/4674142395/?project=4506099854475265&query=is%3Aunresolved&referrer=issue-stream&statsPeriod=14d&stream_index=1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link gave Too Many Redirects
error to me.
b59ebe3
to
988990c
Compare
This PR adds isolation to our sever-side request instrumentation, similarly to the request handler in
Sveltekit.
Note for reviewers: The changes look more drastic than they are. The gist is, we run the previous instrumentation in a new async context if there's no ongoing span. Otherwise we just call the instrumentation.