@sentry/node
Version:
Sentry Node SDK using OpenTelemetry for performance instrumentation
35 lines (34 loc) • 1.31 kB
JavaScript
import { closeSession, defineIntegration, endSession, getIsolationScope, startSession } from "@sentry/core";
// src/integrations/processSession.ts
const INTEGRATION_NAME = "ProcessSession";
/**
* Records a Session for the current process to track release health.
*
* Once the process starts serving requests that are tracked as request sessions, release health is
* reported through session aggregates instead, and the process session is discarded.
* This integration exists so that we capture some form of session health data even when the process is not serving requests.
*/
const processSessionIntegration = defineIntegration(() => {
return {
name: INTEGRATION_NAME,
setup(client) {
startSession();
const processIsolationScope = getIsolationScope();
process.on("beforeExit", () => {
if (getIsolationScope().getSession()?.status === "ok") endSession();
});
const unsubscribe = client.on("startRequestSession", () => {
unsubscribe();
const session = processIsolationScope.getSession();
if (!session) return;
if (!session.init && session.status === "ok") {
closeSession(session);
client.captureSession(session);
}
processIsolationScope.setSession();
});
}
};
});
export { processSessionIntegration };
//# sourceMappingURL=processSession.js.map