From 35e176ba5d27069fa8853eb905f75809568469d3 Mon Sep 17 00:00:00 2001 From: Ahmed Etefy Date: Fri, 7 May 2021 11:38:57 +0200 Subject: [PATCH 1/3] feat(node): Add docs for server side release health --- .../auto-session-tracking/javascript.mdx | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/includes/configuration/auto-session-tracking/javascript.mdx b/src/includes/configuration/auto-session-tracking/javascript.mdx index 27ddf0683e377f..1f904079dc873c 100644 --- a/src/includes/configuration/auto-session-tracking/javascript.mdx +++ b/src/includes/configuration/auto-session-tracking/javascript.mdx @@ -1,8 +1,39 @@ -We create a session for every page load. For single-page applications, we will create a new session for every navigation change (History API). +### Browser-side + +We create a session for every page load. For single-page applications, we will create a new session for every navigation change (History API). + +We mark the session as crashed if an _unhandled error_ or _unhandled promise rejection_ bubbled up to the global handler. + +We mark the session as an error if the SDK captures an event that contains an exception (this includes manually captured errors). + +By default, the JavaScript SDKs are sending sessions, to disable this toggle the flag `autoSessionTracking` to `false`: + +```javascript +Sentry.init({ + autoSessionTracking: false // default: true +}); +``` + +### Server-side + +Release health on the server side is tracked in two different modes: Single Sessions (that represent a node process e.g. cli application) and Session Aggregates (that represents requests). + +In Single Sessions mode, the SDK creates a session for every node process. Session is started on `init` of the SDK, and ended the last thing before the process is exited. + +In Session Aggregates mode, sessions will be recorded differently in the sense that sessions will represent the lifetime of requests instead. For the SDK to be able to capture request mode sessions, the `requestHandler` of the [express middleware](/platforms/node/guides/express) has to be enabled. + +```javascript +// The request handler must be the first middleware on the app +app.use(Sentry.Handlers.requestHandler()); +``` + +Detection of which mode Release Health will operate in is done automatically by the SDK. By default, the SDK runs in Single Sessions mode, but if the `requestHandler` express middleware is enabled, Release Health mode is automatically toggled to Session Aggregates mode. + +It is important to note that if a web server application process is being run for example, but the `requestHandler` express middleware is not enabled, Session Aggregates mode will not be enabled and sessions will represent the health of the web server application process. We mark the session as crashed if an _unhandled error_ or _unhandled promise rejection_ bubbled up to the global handler. -We mark the session as an error if the SDK captures an event that contains an exception (this includes manually captured errors). +We mark the session as an error if the SDK captures an event that contains an exception (this includes manually captured errors). By default, the JavaScript SDKs are sending sessions, to disable this toggle the flag `autoSessionTracking` to `false`: From b7766ea3a9f43870f1d3df523eda518ea2c26a03 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 11 May 2021 09:05:42 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Fiona <61481573+PeloWriter@users.noreply.github.com> Co-authored-by: iker barriocanal <32816711+iker-barriocanal@users.noreply.github.com> --- .../auto-session-tracking/javascript.mdx | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/includes/configuration/auto-session-tracking/javascript.mdx b/src/includes/configuration/auto-session-tracking/javascript.mdx index 1f904079dc873c..eb0e615bc97cd0 100644 --- a/src/includes/configuration/auto-session-tracking/javascript.mdx +++ b/src/includes/configuration/auto-session-tracking/javascript.mdx @@ -1,12 +1,12 @@ -### Browser-side +### Client-Side We create a session for every page load. For single-page applications, we will create a new session for every navigation change (History API). -We mark the session as crashed if an _unhandled error_ or _unhandled promise rejection_ bubbled up to the global handler. - -We mark the session as an error if the SDK captures an event that contains an exception (this includes manually captured errors). +We mark the session as: +- crashed if an _unhandled error_ or _unhandled promise rejection_ bubbled up to the global handler. +- an error if the SDK captures an event that contains an exception (this includes manually captured errors). -By default, the JavaScript SDKs are sending sessions, to disable this toggle the flag `autoSessionTracking` to `false`: +By default, the JavaScript SDKs are sending sessions. To disable sending sessions, set the `autoSessionTracking` flag to `false`: ```javascript Sentry.init({ @@ -14,26 +14,22 @@ Sentry.init({ }); ``` -### Server-side +### Server-Side -Release health on the server side is tracked in two different modes: Single Sessions (that represent a node process e.g. cli application) and Session Aggregates (that represents requests). - -In Single Sessions mode, the SDK creates a session for every node process. Session is started on `init` of the SDK, and ended the last thing before the process is exited. - -In Session Aggregates mode, sessions will be recorded differently in the sense that sessions will represent the lifetime of requests instead. For the SDK to be able to capture request mode sessions, the `requestHandler` of the [express middleware](/platforms/node/guides/express) has to be enabled. +Release health on the server side is tracked in two different modes: +- Single sessions that represent a node process; for example, a CLI application. In single sessions mode, the SDK creates a session for every node process. A session is started on `init` of the SDK, and ends when the process is exited. +- Session aggregates represent requests. In session aggregates mode, sessions will be recorded differently and will represent the lifetime of requests. For the SDK to be able to capture request mode sessions, you must enable the `requestHandler` of the [express middleware](/platforms/node/guides/express). ```javascript // The request handler must be the first middleware on the app app.use(Sentry.Handlers.requestHandler()); ``` -Detection of which mode Release Health will operate in is done automatically by the SDK. By default, the SDK runs in Single Sessions mode, but if the `requestHandler` express middleware is enabled, Release Health mode is automatically toggled to Session Aggregates mode. - -It is important to note that if a web server application process is being run for example, but the `requestHandler` express middleware is not enabled, Session Aggregates mode will not be enabled and sessions will represent the health of the web server application process. +The SDK automatically determines which mode Release Health will operate in. By default, the SDK runs in single sessions mode. However, if the `requestHandler` express middleware is enabled, Release Health is automatically toggled to session aggregates mode. If the `requestHandler` express middleware is not enabled, session aggregates mode will not be enabled and sessions will represent the health of the web server application process if, for example, a web server application is being run. We mark the session as crashed if an _unhandled error_ or _unhandled promise rejection_ bubbled up to the global handler. -We mark the session as an error if the SDK captures an event that contains an exception (this includes manually captured errors). +We mark the session as an error if the SDK captures an event that contains an exception (this includes manually captured exceptions). By default, the JavaScript SDKs are sending sessions, to disable this toggle the flag `autoSessionTracking` to `false`: From 62ca950813d71a05bdde3f21d918aa6cabe1a332 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Tue, 11 May 2021 09:08:13 +0200 Subject: [PATCH 3/3] feat: Use node section --- .../auto-session-tracking/javascript.mdx | 27 ------------------- .../auto-session-tracking/node.mdx | 22 +++++++++++++++ 2 files changed, 22 insertions(+), 27 deletions(-) create mode 100644 src/includes/configuration/auto-session-tracking/node.mdx diff --git a/src/includes/configuration/auto-session-tracking/javascript.mdx b/src/includes/configuration/auto-session-tracking/javascript.mdx index eb0e615bc97cd0..ce775c038560ff 100644 --- a/src/includes/configuration/auto-session-tracking/javascript.mdx +++ b/src/includes/configuration/auto-session-tracking/javascript.mdx @@ -1,5 +1,3 @@ -### Client-Side - We create a session for every page load. For single-page applications, we will create a new session for every navigation change (History API). We mark the session as: @@ -13,28 +11,3 @@ Sentry.init({ autoSessionTracking: false // default: true }); ``` - -### Server-Side - -Release health on the server side is tracked in two different modes: -- Single sessions that represent a node process; for example, a CLI application. In single sessions mode, the SDK creates a session for every node process. A session is started on `init` of the SDK, and ends when the process is exited. -- Session aggregates represent requests. In session aggregates mode, sessions will be recorded differently and will represent the lifetime of requests. For the SDK to be able to capture request mode sessions, you must enable the `requestHandler` of the [express middleware](/platforms/node/guides/express). - -```javascript -// The request handler must be the first middleware on the app -app.use(Sentry.Handlers.requestHandler()); -``` - -The SDK automatically determines which mode Release Health will operate in. By default, the SDK runs in single sessions mode. However, if the `requestHandler` express middleware is enabled, Release Health is automatically toggled to session aggregates mode. If the `requestHandler` express middleware is not enabled, session aggregates mode will not be enabled and sessions will represent the health of the web server application process if, for example, a web server application is being run. - -We mark the session as crashed if an _unhandled error_ or _unhandled promise rejection_ bubbled up to the global handler. - -We mark the session as an error if the SDK captures an event that contains an exception (this includes manually captured exceptions). - -By default, the JavaScript SDKs are sending sessions, to disable this toggle the flag `autoSessionTracking` to `false`: - -```javascript -Sentry.init({ - autoSessionTracking: false // default: true -}); -``` diff --git a/src/includes/configuration/auto-session-tracking/node.mdx b/src/includes/configuration/auto-session-tracking/node.mdx new file mode 100644 index 00000000000000..b5a36cab9f280a --- /dev/null +++ b/src/includes/configuration/auto-session-tracking/node.mdx @@ -0,0 +1,22 @@ +Release health on the server side is tracked in two different modes: +- Single sessions that represent a node process; for example, a CLI application. In single sessions mode, the SDK creates a session for every node process. A session is started on `init` of the SDK, and ends when the process is exited. +- Session aggregates represent requests. In session aggregates mode, sessions will be recorded differently and will represent the lifetime of requests. For the SDK to be able to capture request mode sessions, you must enable the `requestHandler` of the [express middleware](/platforms/node/guides/express). + +```javascript +// The request handler must be the first middleware on the app +app.use(Sentry.Handlers.requestHandler()); +``` + +The SDK automatically determines which mode Release Health will operate in. By default, the SDK runs in single sessions mode. However, if the `requestHandler` express middleware is enabled, Release Health is automatically toggled to session aggregates mode. If the `requestHandler` express middleware is not enabled, session aggregates mode will not be enabled and sessions will represent the health of the web server application process if, for example, a web server application is being run. + +We mark the session as crashed if an _unhandled error_ reached our `errorHandler` middleware. + +We mark the session as an error if the SDK captures an event that contains an exception (this includes manually captured exceptions). + +By default, the JavaScript SDKs are sending sessions, to disable this toggle the flag `autoSessionTracking` to `false`: + +```javascript +Sentry.init({ + autoSessionTracking: false // default: true +}); +```