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(node)!: Collect request sessions via HTTP instrumentation #14658

Merged
merged 48 commits into from
Dec 19, 2024

Conversation

lforst
Copy link
Member

@lforst lforst commented Dec 11, 2024

Ref #14658

This is a very cool PR 😎👉👉 that

  • Removes the autoSessionTracking implementation from the Node SDK
  • Adds options to the httpIntegration to create sessions for incoming requests
  • Removes all the RequestSession APIs from Scope etc. and hoists it into sdkProcessingMetadata
  • Cleans up the logic for marking "Request Sessions" as crashed/errored in the ServerRuntimeClient
  • Deletes the now unused SessionFlusher
  • Removes essentially duplicate code from the express instrumentation that was taking care of updating sessions.

Sorry for big PR.

lforst and others added 8 commits December 11, 2024 17:48
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
Copy link
Contributor

github-actions bot commented Dec 13, 2024

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.13 KB +0.05% +10 B 🔺
@sentry/browser - with treeshaking flags 21.81 KB -0.01% -2 B 🔽
@sentry/browser (incl. Tracing) 35.62 KB -0.01% -3 B 🔽
@sentry/browser (incl. Tracing, Replay) 72.89 KB +0.02% +11 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.29 KB -0.01% -3 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 77.3 KB +0.02% +12 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 89.69 KB +0.01% +7 B 🔺
@sentry/browser (incl. Feedback) 39.88 KB +0.03% +9 B 🔺
@sentry/browser (incl. sendFeedback) 27.74 KB +0.02% +4 B 🔺
@sentry/browser (incl. FeedbackAsync) 32.5 KB +0.02% +4 B 🔺
@sentry/react 25.86 KB +0.06% +14 B 🔺
@sentry/react (incl. Tracing) 38.48 KB -0.05% -17 B 🔽
@sentry/vue 27.36 KB -0.02% -4 B 🔽
@sentry/vue (incl. Tracing) 37.5 KB -0.01% -3 B 🔽
@sentry/svelte 23.3 KB +0.05% +11 B 🔺
CDN Bundle 24.21 KB -0.07% -16 B 🔽
CDN Bundle (incl. Tracing) 35.76 KB -0.04% -14 B 🔽
CDN Bundle (incl. Tracing, Replay) 70.87 KB -0.03% -16 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 76.17 KB -0.03% -20 B 🔽
CDN Bundle - uncompressed 71.09 KB -0.07% -48 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 106.61 KB -0.04% -43 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 220.67 KB -0.02% -43 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 233.88 KB -0.02% -47 B 🔽
@sentry/nextjs (client) 38.76 KB +0.03% +8 B 🔺
@sentry/sveltekit (client) 36.17 KB -0.02% -4 B 🔽
@sentry/node 157.95 KB -0.02% -28 B 🔽
@sentry/node - without tracing 98.84 KB -0.1% -100 B 🔽
@sentry/aws-serverless 126.57 KB -0.06% -68 B 🔽

View base workflow run

Copy link

codecov bot commented Dec 13, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
556 1 555 296
View the top 1 failed tests by shortest run time
public-api/debug/test.ts logs debug messages correctly
Stack Traces | 0.215s run time
test.ts:7:11 logs debug messages correctly

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

mydea and others added 7 commits December 13, 2024 13:37
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
@lforst lforst changed the base branch from v9 to develop December 13, 2024 15:54
@lforst lforst marked this pull request as ready for review December 16, 2024 15:29
@lforst lforst requested review from mydea, Lms24 and chargome December 16, 2024 15:40
Comment on lines 215 to 223
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';
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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]]++;
Copy link
Member

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 });
Copy link
Member

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?

Copy link
Member Author

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.

@lforst lforst merged commit 117a3b4 into develop Dec 19, 2024
151 checks passed
@lforst lforst deleted the lforst-server-sessions branch December 19, 2024 09:32
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