-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(node)!: Collect request sessions via HTTP instrumentation #14658
Conversation
In order for us to have size-limit comparison etc, we need to ensure CI runs on v8 & v9 branches too.
In order for us to have size-limit comparison etc, we need to ensure CI runs on v8 & v9 branches too.
With this PR, the default value for the `spans` option in the `httpIntegration` is changed to `false`, if `skipOpenTelemetrySetup: true` is configured. This is what you'd expect as a user, you do not want Sentry to register any OTEL instrumentation and emit any spans in this scenario. Closes #14675
size-limit report 📦
|
❌ 1 Tests Failed:
View the top 1 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
In order for us to have size-limit comparison etc, we need to ensure CI runs on v8 & v9 branches too.
With this PR, the default value for the `spans` option in the `httpIntegration` is changed to `false`, if `skipOpenTelemetrySetup: true` is configured. This is what you'd expect as a user, you do not want Sentry to register any OTEL instrumentation and emit any spans in this scenario. Closes #14675
if (isHandledException) { | ||
// A request session can go from "errored" -> "crashed" but not "crashed" -> "errored". | ||
// Crashed (unhandled exception) is worse than errored (handled exception). | ||
if (requestSession.status !== 'crashed') { | ||
requestSession.status = 'errored'; | ||
} | ||
} else { | ||
requestSession.status = 'crashed'; | ||
} |
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.
if (isHandledException) { | |
// A request session can go from "errored" -> "crashed" but not "crashed" -> "errored". | |
// Crashed (unhandled exception) is worse than errored (handled exception). | |
if (requestSession.status !== 'crashed') { | |
requestSession.status = 'errored'; | |
} | |
} else { | |
requestSession.status = 'crashed'; | |
} | |
// A request session can go from "errored" -> "crashed" but not "crashed" -> "errored". | |
// Crashed (unhandled exception) is worse than errored (handled exception). | |
if (isHandledException && requestSession.status !== 'crashed') { | |
requestSession.status = 'errored'; | |
} else if (!isHandledException) { | |
requestSession.status = 'crashed'; | |
} |
|
||
const existingClientAggregate = clientToRequestSessionAggregatesMap.get(client); | ||
const bucket = existingClientAggregate?.[dateBucketKey] || { exited: 0, crashed: 0, errored: 0 }; | ||
bucket[({ ok: 'exited', crashed: 'crashed', errored: 'errored' } as const)[requestSession.status]]++; |
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.
l: we could put exited
crashed
and errored
into a type
crashed: value.crashed, | ||
}), | ||
); | ||
client.sendSession({ aggregates: aggregatePayload }); |
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.
Does this need to be catched?
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 question. As of now, it cannot be caught because we leave the underlying promises dangling in the base client :/ It should be fine though since we do it only after all the cleanup has been done and it is in a non-main-program-flow place (i.e. res.on()
) so it won't crash.
Ref #14658
This is a very cool PR 😎👉👉 that
autoSessionTracking
implementation from the Node SDKhttpIntegration
to create sessions for incoming requestsRequestSession
APIs from Scope etc. and hoists it intosdkProcessingMetadata
ServerRuntimeClient
SessionFlusher
Sorry for big PR.