Skip to content

Conversation

@ahmedetefy
Copy link
Contributor

@ahmedetefy ahmedetefy commented Mar 10, 2021

This PR adds:

  • Capturing request mode sessions/ Session Aggregates in Node.js/Express etc... through using the requestHandler middleware
  • Using a SessionFlusher on Client that bypasses the Backend for Request mode sessions/ SessionAggregates that flushes the aggregated payloads every 60s
  • When requestHandler middleware is used, it opts user into Session Aggregates mode and deletes Single Session on scope.
  • In the case of an error (uncaught error) bubbles up to the errorHandler middleware, the crashed count is incremented
  • In the case of handled exceptions, the errored count is incremented
  • In case of healthy request mode session, exited count is incremented
  • Calling captureEvent with an event that contains exceptions, will increment the errored count

Note: This PR re-enables autoSessionTracking by default #3511
Docs PR: getsentry/sentry-docs#3541

@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 20.73 KB (+0.41% 🔺)
@sentry/browser - Webpack 21.95 KB (+1.96% 🔺)
@sentry/react - Webpack 21.98 KB (+1.96% 🔺)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.12 KB (+0.33% 🔺)

@ahmedetefy ahmedetefy force-pushed the release-health branch 3 times, most recently from 0b578a1 to 6c1c72e Compare March 10, 2021 09:45
@ahmedetefy ahmedetefy changed the title Release health feat: Release health for Node Apr 8, 2021
@ahmedetefy ahmedetefy changed the title feat: Release health for Node feat(node.js): Release health for Node Apr 9, 2021
Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

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

Did a partial initial review. Sharing some comments.

@ahmedetefy ahmedetefy marked this pull request as ready for review April 13, 2021 09:51
@ahmedetefy ahmedetefy requested a review from kamilogorek as a code owner April 13, 2021 09:51
@ahmedetefy ahmedetefy requested a review from rhcarvalho April 13, 2021 09:52
@ahmedetefy ahmedetefy marked this pull request as draft April 14, 2021 09:15
@ahmedetefy ahmedetefy marked this pull request as ready for review April 14, 2021 14:10
Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

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

another pass

@ahmedetefy ahmedetefy marked this pull request as draft April 23, 2021 09:56
@rhcarvalho
Copy link
Contributor

When we ship this we should change the dev docs https://develop.sentry.dev/sdk/sessions/#session-aggregates-payload

Right now the API is marked experimental and limited to sentry.io usage only.

image

@ahmedetefy ahmedetefy force-pushed the release-health branch 10 times, most recently from 9641f64 to 5ad2112 Compare May 10, 2021 12:57
@ahmedetefy ahmedetefy requested review from HazAT and rhcarvalho May 11, 2021 09:25
@ahmedetefy ahmedetefy force-pushed the release-health branch 2 times, most recently from 2aef14c to 062ae6b Compare May 11, 2021 09:50
Copy link
Member

@HazAT HazAT left a comment

Choose a reason for hiding this comment

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

Small comments, but tests are still failing.
otherwise LGTM

Captures request mode sessions associated with a specific release, and sends them to the Sentry as part of the Release Health functionality.
@ahmedetefy ahmedetefy requested a review from HazAT May 11, 2021 10:30
protected async _send(sentryReq: SentryRequest, originalPayload?: Event | Session): Promise<Response> {
protected async _send(
sentryReq: SentryRequest,
originalPayload?: Event | Session | SessionAggregates,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do not need to send originalPayload of type SessionAggregates because that is only required for rate limiting

Copy link
Member

Choose a reason for hiding this comment

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

Typescript needs this or it will complain :/


class DummyTransport extends BaseDummyTransport {
sendSession(session) {
console.error('FAIL: Received Single Session which should have been deleted in favor of Session Aggregates!');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing this section means we no longer check if the application mode session was dropped in favor of SessionAggregates mode

Copy link
Member

Choose a reason for hiding this comment

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

There is only sendSession anymore and we do an assert to check for content, so if a single session reaches this it would fail.

/** Massages the entries in `pendingAggregates` and returns aggregated sessions */
public getSessionAggregates(): SessionAggregates {
const aggregates: AggregationCounts[] = Object.keys(this._pendingAggregates).map((key: string) => {
return this._pendingAggregates[parseInt(key)];
Copy link
Member

Choose a reason for hiding this comment

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

Are the keys not typed as numbers? Why is it a string here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Keys are always coerced to strings, despite being stored as numbers, so parseInt can be skipped here.

Copy link
Contributor

Choose a reason for hiding this comment

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

lol, typescript u dumb :3

@kamilogorek kamilogorek self-requested a review May 14, 2021 12:34
@HazAT HazAT merged commit e59bb03 into master May 17, 2021
@HazAT HazAT deleted the release-health branch May 17, 2021 06:20
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.

6 participants