@sentry/node 8.0.0-alpha.1 → 8.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -93
- package/cjs/index.js +3665 -77
- package/cjs/index.js.map +1 -1
- package/esm/index.js +3614 -31
- package/esm/index.js.map +1 -1
- package/esm/integrations/anr/worker-script.js +2 -2
- package/esm/package.json +1 -0
- package/package.json +21 -6
- package/types/index.d.ts +6 -5
- package/types/index.d.ts.map +1 -1
- package/types/integrations/anr/index.d.ts.map +1 -1
- package/types/integrations/anr/worker-script.d.ts +1 -1
- package/types/integrations/anr/worker-script.d.ts.map +1 -1
- package/types/integrations/http.d.ts +4 -0
- package/types/integrations/http.d.ts.map +1 -1
- package/types/integrations/local-variables/common.d.ts +1 -0
- package/types/integrations/local-variables/common.d.ts.map +1 -1
- package/types/integrations/local-variables/local-variables-sync.d.ts +1 -0
- package/types/integrations/local-variables/local-variables-sync.d.ts.map +1 -1
- package/types/integrations/tracing/fastify.d.ts +9 -0
- package/types/integrations/tracing/fastify.d.ts.map +1 -1
- package/types/integrations/tracing/hapi/index.d.ts.map +1 -1
- package/types/integrations/tracing/prisma.d.ts.map +1 -1
- package/types/proxy/helpers.d.ts +2 -2
- package/types/proxy/helpers.d.ts.map +1 -1
- package/types/proxy/index.d.ts.map +1 -1
- package/types/sdk/hub.d.ts.map +1 -1
- package/types/sdk/init.d.ts.map +1 -1
- package/types/transports/http-module.d.ts +2 -2
- package/types/transports/http-module.d.ts.map +1 -1
- package/types/types.d.ts +12 -4
- package/types/types.d.ts.map +1 -1
- package/types-ts3.8/index.d.ts +6 -5
- package/types-ts3.8/integrations/anr/worker-script.d.ts +1 -1
- package/types-ts3.8/integrations/http.d.ts +4 -0
- package/types-ts3.8/integrations/local-variables/common.d.ts +1 -0
- package/types-ts3.8/integrations/local-variables/local-variables-sync.d.ts +1 -0
- package/types-ts3.8/integrations/tracing/fastify.d.ts +9 -0
- package/types-ts3.8/proxy/helpers.d.ts +2 -2
- package/types-ts3.8/transports/http-module.d.ts +2 -2
- package/types-ts3.8/types.d.ts +12 -4
- package/cjs/cron/common.js +0 -56
- package/cjs/cron/common.js.map +0 -1
- package/cjs/cron/cron.js +0 -102
- package/cjs/cron/cron.js.map +0 -1
- package/cjs/cron/index.js +0 -15
- package/cjs/cron/index.js.map +0 -1
- package/cjs/cron/node-cron.js +0 -61
- package/cjs/cron/node-cron.js.map +0 -1
- package/cjs/cron/node-schedule.js +0 -57
- package/cjs/cron/node-schedule.js.map +0 -1
- package/cjs/debug-build.js +0 -11
- package/cjs/debug-build.js.map +0 -1
- package/cjs/integrations/anr/index.js +0 -145
- package/cjs/integrations/anr/index.js.map +0 -1
- package/cjs/integrations/anr/worker-script.js +0 -2
- package/cjs/integrations/anr/worker-script.js.map +0 -1
- package/cjs/integrations/console.js +0 -40
- package/cjs/integrations/console.js.map +0 -1
- package/cjs/integrations/context.js +0 -435
- package/cjs/integrations/context.js.map +0 -1
- package/cjs/integrations/contextlines.js +0 -137
- package/cjs/integrations/contextlines.js.map +0 -1
- package/cjs/integrations/http.js +0 -137
- package/cjs/integrations/http.js.map +0 -1
- package/cjs/integrations/local-variables/common.js +0 -87
- package/cjs/integrations/local-variables/common.js.map +0 -1
- package/cjs/integrations/local-variables/index.js +0 -8
- package/cjs/integrations/local-variables/index.js.map +0 -1
- package/cjs/integrations/local-variables/local-variables-sync.js +0 -400
- package/cjs/integrations/local-variables/local-variables-sync.js.map +0 -1
- package/cjs/integrations/modules.js +0 -99
- package/cjs/integrations/modules.js.map +0 -1
- package/cjs/integrations/node-fetch.js +0 -82
- package/cjs/integrations/node-fetch.js.map +0 -1
- package/cjs/integrations/onuncaughtexception.js +0 -137
- package/cjs/integrations/onuncaughtexception.js.map +0 -1
- package/cjs/integrations/onunhandledrejection.js +0 -90
- package/cjs/integrations/onunhandledrejection.js.map +0 -1
- package/cjs/integrations/spotlight.js +0 -109
- package/cjs/integrations/spotlight.js.map +0 -1
- package/cjs/integrations/tracing/express.js +0 -103
- package/cjs/integrations/tracing/express.js.map +0 -1
- package/cjs/integrations/tracing/fastify.js +0 -33
- package/cjs/integrations/tracing/fastify.js.map +0 -1
- package/cjs/integrations/tracing/graphql.js +0 -34
- package/cjs/integrations/tracing/graphql.js.map +0 -1
- package/cjs/integrations/tracing/hapi/index.js +0 -81
- package/cjs/integrations/tracing/hapi/index.js.map +0 -1
- package/cjs/integrations/tracing/index.js +0 -37
- package/cjs/integrations/tracing/index.js.map +0 -1
- package/cjs/integrations/tracing/koa.js +0 -21
- package/cjs/integrations/tracing/koa.js.map +0 -1
- package/cjs/integrations/tracing/mongo.js +0 -33
- package/cjs/integrations/tracing/mongo.js.map +0 -1
- package/cjs/integrations/tracing/mongoose.js +0 -33
- package/cjs/integrations/tracing/mongoose.js.map +0 -1
- package/cjs/integrations/tracing/mysql.js +0 -26
- package/cjs/integrations/tracing/mysql.js.map +0 -1
- package/cjs/integrations/tracing/mysql2.js +0 -33
- package/cjs/integrations/tracing/mysql2.js.map +0 -1
- package/cjs/integrations/tracing/nest.js +0 -26
- package/cjs/integrations/tracing/nest.js.map +0 -1
- package/cjs/integrations/tracing/postgres.js +0 -34
- package/cjs/integrations/tracing/postgres.js.map +0 -1
- package/cjs/integrations/tracing/prisma.js +0 -33
- package/cjs/integrations/tracing/prisma.js.map +0 -1
- package/cjs/nodeVersion.js +0 -12
- package/cjs/nodeVersion.js.map +0 -1
- package/cjs/otel/contextManager.js +0 -16
- package/cjs/otel/contextManager.js.map +0 -1
- package/cjs/proxy/base.js +0 -126
- package/cjs/proxy/base.js.map +0 -1
- package/cjs/proxy/index.js +0 -209
- package/cjs/proxy/index.js.map +0 -1
- package/cjs/proxy/parse-proxy-response.js +0 -104
- package/cjs/proxy/parse-proxy-response.js.map +0 -1
- package/cjs/sdk/api.js +0 -74
- package/cjs/sdk/api.js.map +0 -1
- package/cjs/sdk/client.js +0 -57
- package/cjs/sdk/client.js.map +0 -1
- package/cjs/sdk/hub.js +0 -104
- package/cjs/sdk/hub.js.map +0 -1
- package/cjs/sdk/init.js +0 -224
- package/cjs/sdk/init.js.map +0 -1
- package/cjs/sdk/initOtel.js +0 -70
- package/cjs/sdk/initOtel.js.map +0 -1
- package/cjs/sdk/scope.js +0 -18
- package/cjs/sdk/scope.js.map +0 -1
- package/cjs/transports/http.js +0 -160
- package/cjs/transports/http.js.map +0 -1
- package/cjs/utils/addOriginToSpan.js +0 -11
- package/cjs/utils/addOriginToSpan.js.map +0 -1
- package/cjs/utils/errorhandling.js +0 -44
- package/cjs/utils/errorhandling.js.map +0 -1
- package/cjs/utils/getRequestUrl.js +0 -18
- package/cjs/utils/getRequestUrl.js.map +0 -1
- package/cjs/utils/module.js +0 -62
- package/cjs/utils/module.js.map +0 -1
- package/esm/cron/common.js +0 -54
- package/esm/cron/common.js.map +0 -1
- package/esm/cron/cron.js +0 -100
- package/esm/cron/cron.js.map +0 -1
- package/esm/cron/index.js +0 -13
- package/esm/cron/index.js.map +0 -1
- package/esm/cron/node-cron.js +0 -56
- package/esm/cron/node-cron.js.map +0 -1
- package/esm/cron/node-schedule.js +0 -55
- package/esm/cron/node-schedule.js.map +0 -1
- package/esm/debug-build.js +0 -9
- package/esm/debug-build.js.map +0 -1
- package/esm/integrations/anr/index.js +0 -139
- package/esm/integrations/anr/index.js.map +0 -1
- package/esm/integrations/anr/worker-script.js.map +0 -1
- package/esm/integrations/console.js +0 -38
- package/esm/integrations/console.js.map +0 -1
- package/esm/integrations/context.js +0 -427
- package/esm/integrations/context.js.map +0 -1
- package/esm/integrations/contextlines.js +0 -131
- package/esm/integrations/contextlines.js.map +0 -1
- package/esm/integrations/http.js +0 -132
- package/esm/integrations/http.js.map +0 -1
- package/esm/integrations/local-variables/common.js +0 -81
- package/esm/integrations/local-variables/common.js.map +0 -1
- package/esm/integrations/local-variables/index.js +0 -6
- package/esm/integrations/local-variables/index.js.map +0 -1
- package/esm/integrations/local-variables/local-variables-sync.js +0 -394
- package/esm/integrations/local-variables/local-variables-sync.js.map +0 -1
- package/esm/integrations/modules.js +0 -97
- package/esm/integrations/modules.js.map +0 -1
- package/esm/integrations/node-fetch.js +0 -80
- package/esm/integrations/node-fetch.js.map +0 -1
- package/esm/integrations/onuncaughtexception.js +0 -134
- package/esm/integrations/onuncaughtexception.js.map +0 -1
- package/esm/integrations/onunhandledrejection.js +0 -87
- package/esm/integrations/onunhandledrejection.js.map +0 -1
- package/esm/integrations/spotlight.js +0 -106
- package/esm/integrations/spotlight.js.map +0 -1
- package/esm/integrations/tracing/express.js +0 -96
- package/esm/integrations/tracing/express.js.map +0 -1
- package/esm/integrations/tracing/fastify.js +0 -31
- package/esm/integrations/tracing/fastify.js.map +0 -1
- package/esm/integrations/tracing/graphql.js +0 -32
- package/esm/integrations/tracing/graphql.js.map +0 -1
- package/esm/integrations/tracing/hapi/index.js +0 -77
- package/esm/integrations/tracing/hapi/index.js.map +0 -1
- package/esm/integrations/tracing/index.js +0 -35
- package/esm/integrations/tracing/index.js.map +0 -1
- package/esm/integrations/tracing/koa.js +0 -19
- package/esm/integrations/tracing/koa.js.map +0 -1
- package/esm/integrations/tracing/mongo.js +0 -31
- package/esm/integrations/tracing/mongo.js.map +0 -1
- package/esm/integrations/tracing/mongoose.js +0 -31
- package/esm/integrations/tracing/mongoose.js.map +0 -1
- package/esm/integrations/tracing/mysql.js +0 -24
- package/esm/integrations/tracing/mysql.js.map +0 -1
- package/esm/integrations/tracing/mysql2.js +0 -31
- package/esm/integrations/tracing/mysql2.js.map +0 -1
- package/esm/integrations/tracing/nest.js +0 -24
- package/esm/integrations/tracing/nest.js.map +0 -1
- package/esm/integrations/tracing/postgres.js +0 -32
- package/esm/integrations/tracing/postgres.js.map +0 -1
- package/esm/integrations/tracing/prisma.js +0 -31
- package/esm/integrations/tracing/prisma.js.map +0 -1
- package/esm/nodeVersion.js +0 -9
- package/esm/nodeVersion.js.map +0 -1
- package/esm/otel/contextManager.js +0 -14
- package/esm/otel/contextManager.js.map +0 -1
- package/esm/proxy/base.js +0 -121
- package/esm/proxy/base.js.map +0 -1
- package/esm/proxy/index.js +0 -203
- package/esm/proxy/index.js.map +0 -1
- package/esm/proxy/parse-proxy-response.js +0 -102
- package/esm/proxy/parse-proxy-response.js.map +0 -1
- package/esm/sdk/api.js +0 -69
- package/esm/sdk/api.js.map +0 -1
- package/esm/sdk/client.js +0 -52
- package/esm/sdk/client.js.map +0 -1
- package/esm/sdk/hub.js +0 -102
- package/esm/sdk/hub.js.map +0 -1
- package/esm/sdk/init.js +0 -221
- package/esm/sdk/init.js.map +0 -1
- package/esm/sdk/initOtel.js +0 -67
- package/esm/sdk/initOtel.js.map +0 -1
- package/esm/sdk/scope.js +0 -16
- package/esm/sdk/scope.js.map +0 -1
- package/esm/transports/http.js +0 -155
- package/esm/transports/http.js.map +0 -1
- package/esm/utils/addOriginToSpan.js +0 -9
- package/esm/utils/addOriginToSpan.js.map +0 -1
- package/esm/utils/errorhandling.js +0 -42
- package/esm/utils/errorhandling.js.map +0 -1
- package/esm/utils/getRequestUrl.js +0 -16
- package/esm/utils/getRequestUrl.js.map +0 -1
- package/esm/utils/module.js +0 -60
- package/esm/utils/module.js.map +0 -1
- package/types/integrations/local-variables/local-variables-async.d.ts +0 -14
- package/types/integrations/local-variables/local-variables-async.d.ts.map +0 -1
- package/types-ts3.8/integrations/local-variables/local-variables-async.d.ts +0 -14
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { SpanKind } from '@opentelemetry/api';
|
|
2
|
-
import { registerInstrumentations } from '@opentelemetry/instrumentation';
|
|
3
|
-
import { defineIntegration, addBreadcrumb } from '@sentry/core';
|
|
4
|
-
import { getSpanKind, _INTERNAL } from '@sentry/opentelemetry';
|
|
5
|
-
import { NODE_MAJOR } from '../nodeVersion.js';
|
|
6
|
-
import { addOriginToSpan } from '../utils/addOriginToSpan.js';
|
|
7
|
-
|
|
8
|
-
const _nativeNodeFetchIntegration = ((options = {}) => {
|
|
9
|
-
const _breadcrumbs = typeof options.breadcrumbs === 'undefined' ? true : options.breadcrumbs;
|
|
10
|
-
const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;
|
|
11
|
-
|
|
12
|
-
function getInstrumentation() {
|
|
13
|
-
// Only add NodeFetch if Node >= 16, as previous versions do not support it
|
|
14
|
-
if (NODE_MAJOR < 16) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20
|
-
const { FetchInstrumentation } = require('opentelemetry-instrumentation-fetch-node');
|
|
21
|
-
return [
|
|
22
|
-
new FetchInstrumentation({
|
|
23
|
-
ignoreRequestHook: (request) => {
|
|
24
|
-
const url = request.origin;
|
|
25
|
-
return _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url);
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
onRequest: ({ span }) => {
|
|
29
|
-
_updateSpan(span);
|
|
30
|
-
|
|
31
|
-
if (_breadcrumbs) {
|
|
32
|
-
_addRequestBreadcrumb(span);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
}),
|
|
36
|
-
];
|
|
37
|
-
} catch (error) {
|
|
38
|
-
// Could not load instrumentation
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
name: 'NodeFetch',
|
|
44
|
-
setupOnce() {
|
|
45
|
-
const instrumentations = getInstrumentation();
|
|
46
|
-
|
|
47
|
-
if (instrumentations) {
|
|
48
|
-
registerInstrumentations({
|
|
49
|
-
instrumentations,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}) ;
|
|
55
|
-
|
|
56
|
-
const nativeNodeFetchIntegration = defineIntegration(_nativeNodeFetchIntegration);
|
|
57
|
-
|
|
58
|
-
/** Update the span with data we need. */
|
|
59
|
-
function _updateSpan(span) {
|
|
60
|
-
addOriginToSpan(span, 'auto.http.otel.node_fetch');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** Add a breadcrumb for outgoing requests. */
|
|
64
|
-
function _addRequestBreadcrumb(span) {
|
|
65
|
-
if (getSpanKind(span) !== SpanKind.CLIENT) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const data = _INTERNAL.getRequestSpanData(span);
|
|
70
|
-
addBreadcrumb({
|
|
71
|
-
category: 'http',
|
|
72
|
-
data: {
|
|
73
|
-
...data,
|
|
74
|
-
},
|
|
75
|
-
type: 'http',
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export { nativeNodeFetchIntegration };
|
|
80
|
-
//# sourceMappingURL=node-fetch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-fetch.js","sources":["../../../src/integrations/node-fetch.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport { SpanKind } from '@opentelemetry/api';\nimport type { Instrumentation } from '@opentelemetry/instrumentation';\nimport { registerInstrumentations } from '@opentelemetry/instrumentation';\nimport { addBreadcrumb, defineIntegration } from '@sentry/core';\nimport { _INTERNAL, getSpanKind } from '@sentry/opentelemetry';\nimport type { IntegrationFn } from '@sentry/types';\nimport { NODE_MAJOR } from '../nodeVersion';\n\nimport { addOriginToSpan } from '../utils/addOriginToSpan';\n\ninterface NodeFetchOptions {\n /**\n * Whether breadcrumbs should be recorded for requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing fetch requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n */\n ignoreOutgoingRequests?: (url: string) => boolean;\n}\n\nconst _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {\n const _breadcrumbs = typeof options.breadcrumbs === 'undefined' ? true : options.breadcrumbs;\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n\n function getInstrumentation(): [Instrumentation] | void {\n // Only add NodeFetch if Node >= 16, as previous versions do not support it\n if (NODE_MAJOR < 16) {\n return;\n }\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { FetchInstrumentation } = require('opentelemetry-instrumentation-fetch-node');\n return [\n new FetchInstrumentation({\n ignoreRequestHook: (request: { origin?: string }) => {\n const url = request.origin;\n return _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url);\n },\n\n onRequest: ({ span }: { span: Span }) => {\n _updateSpan(span);\n\n if (_breadcrumbs) {\n _addRequestBreadcrumb(span);\n }\n },\n }),\n ];\n } catch (error) {\n // Could not load instrumentation\n }\n }\n\n return {\n name: 'NodeFetch',\n setupOnce() {\n const instrumentations = getInstrumentation();\n\n if (instrumentations) {\n registerInstrumentations({\n instrumentations,\n });\n }\n },\n };\n}) satisfies IntegrationFn;\n\nexport const nativeNodeFetchIntegration = defineIntegration(_nativeNodeFetchIntegration);\n\n/** Update the span with data we need. */\nfunction _updateSpan(span: Span): void {\n addOriginToSpan(span, 'auto.http.otel.node_fetch');\n}\n\n/** Add a breadcrumb for outgoing requests. */\nfunction _addRequestBreadcrumb(span: Span): void {\n if (getSpanKind(span) !== SpanKind.CLIENT) {\n return;\n }\n\n const data = _INTERNAL.getRequestSpanData(span);\n addBreadcrumb({\n category: 'http',\n data: {\n ...data,\n },\n type: 'http',\n });\n}\n"],"names":[],"mappings":";;;;;;;AAyBA,MAAM,2BAAA,IAA+B,CAAC,OAAO,GAAqB,EAAE,KAAK;AACzE,EAAE,MAAM,YAAA,GAAe,OAAO,OAAO,CAAC,WAAA,KAAgB,WAAA,GAAc,IAAA,GAAO,OAAO,CAAC,WAAW,CAAA;AAC9F,EAAE,MAAM,uBAAA,GAA0B,OAAO,CAAC,sBAAsB,CAAA;AAChE;AACA,EAAE,SAAS,kBAAkB,GAA6B;AAC1D;AACA,IAAI,IAAI,UAAW,GAAE,EAAE,EAAE;AACzB,MAAM,OAAM;AACZ,KAAI;AACJ;AACA,IAAI,IAAI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E;AACF;AACA,EAAE,MAAM,OAAO,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA;AACjD,EAAE,aAAa,CAAC;AAChB,IAAI,QAAQ,EAAE,MAAM;AACpB,IAAI,IAAI,EAAE;AACV,MAAM,GAAG,IAAI;AACb,KAAK;AACL,IAAI,IAAI,EAAE,MAAM;AAChB,GAAG,CAAC,CAAA;AACJ;;;;"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { defineIntegration, getClient, captureException } from '@sentry/core';
|
|
2
|
-
import { logger } from '@sentry/utils';
|
|
3
|
-
import { DEBUG_BUILD } from '../debug-build.js';
|
|
4
|
-
import { logAndExitProcess } from '../utils/errorhandling.js';
|
|
5
|
-
|
|
6
|
-
const INTEGRATION_NAME = 'OnUncaughtException';
|
|
7
|
-
|
|
8
|
-
const _onUncaughtExceptionIntegration = ((options = {}) => {
|
|
9
|
-
const _options = {
|
|
10
|
-
exitEvenIfOtherHandlersAreRegistered: true,
|
|
11
|
-
...options,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
name: INTEGRATION_NAME,
|
|
16
|
-
setup(client) {
|
|
17
|
-
global.process.on('uncaughtException', makeErrorHandler(client, _options));
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
}) ;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Add a global exception handler.
|
|
24
|
-
*/
|
|
25
|
-
const onUncaughtExceptionIntegration = defineIntegration(_onUncaughtExceptionIntegration);
|
|
26
|
-
|
|
27
|
-
/** Exported only for tests */
|
|
28
|
-
function makeErrorHandler(client, options) {
|
|
29
|
-
const timeout = 2000;
|
|
30
|
-
let caughtFirstError = false;
|
|
31
|
-
let caughtSecondError = false;
|
|
32
|
-
let calledFatalError = false;
|
|
33
|
-
let firstError;
|
|
34
|
-
|
|
35
|
-
const clientOptions = client.getOptions();
|
|
36
|
-
|
|
37
|
-
return Object.assign(
|
|
38
|
-
(error) => {
|
|
39
|
-
let onFatalError = logAndExitProcess;
|
|
40
|
-
|
|
41
|
-
if (options.onFatalError) {
|
|
42
|
-
onFatalError = options.onFatalError;
|
|
43
|
-
} else if (clientOptions.onFatalError) {
|
|
44
|
-
onFatalError = clientOptions.onFatalError ;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Attaching a listener to `uncaughtException` will prevent the node process from exiting. We generally do not
|
|
48
|
-
// want to alter this behaviour so we check for other listeners that users may have attached themselves and adjust
|
|
49
|
-
// exit behaviour of the SDK accordingly:
|
|
50
|
-
// - If other listeners are attached, do not exit.
|
|
51
|
-
// - If the only listener attached is ours, exit.
|
|
52
|
-
const userProvidedListenersCount = (global.process.listeners('uncaughtException') ).filter(
|
|
53
|
-
listener => {
|
|
54
|
-
// There are 3 listeners we ignore:
|
|
55
|
-
return (
|
|
56
|
-
// as soon as we're using domains this listener is attached by node itself
|
|
57
|
-
listener.name !== 'domainUncaughtExceptionClear' &&
|
|
58
|
-
// the handler we register for tracing
|
|
59
|
-
listener.tag !== 'sentry_tracingErrorCallback' &&
|
|
60
|
-
// the handler we register in this integration
|
|
61
|
-
(listener )._errorHandler !== true
|
|
62
|
-
);
|
|
63
|
-
},
|
|
64
|
-
).length;
|
|
65
|
-
|
|
66
|
-
const processWouldExit = userProvidedListenersCount === 0;
|
|
67
|
-
const shouldApplyFatalHandlingLogic = options.exitEvenIfOtherHandlersAreRegistered || processWouldExit;
|
|
68
|
-
|
|
69
|
-
if (!caughtFirstError) {
|
|
70
|
-
// this is the first uncaught error and the ultimate reason for shutting down
|
|
71
|
-
// we want to do absolutely everything possible to ensure it gets captured
|
|
72
|
-
// also we want to make sure we don't go recursion crazy if more errors happen after this one
|
|
73
|
-
firstError = error;
|
|
74
|
-
caughtFirstError = true;
|
|
75
|
-
|
|
76
|
-
if (getClient() === client) {
|
|
77
|
-
captureException(error, {
|
|
78
|
-
originalException: error,
|
|
79
|
-
captureContext: {
|
|
80
|
-
level: 'fatal',
|
|
81
|
-
},
|
|
82
|
-
mechanism: {
|
|
83
|
-
handled: false,
|
|
84
|
-
type: 'onuncaughtexception',
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (!calledFatalError && shouldApplyFatalHandlingLogic) {
|
|
90
|
-
calledFatalError = true;
|
|
91
|
-
onFatalError(error);
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
if (shouldApplyFatalHandlingLogic) {
|
|
95
|
-
if (calledFatalError) {
|
|
96
|
-
// we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down
|
|
97
|
-
DEBUG_BUILD &&
|
|
98
|
-
logger.warn(
|
|
99
|
-
'uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown',
|
|
100
|
-
);
|
|
101
|
-
logAndExitProcess(error);
|
|
102
|
-
} else if (!caughtSecondError) {
|
|
103
|
-
// two cases for how we can hit this branch:
|
|
104
|
-
// - capturing of first error blew up and we just caught the exception from that
|
|
105
|
-
// - quit trying to capture, proceed with shutdown
|
|
106
|
-
// - a second independent error happened while waiting for first error to capture
|
|
107
|
-
// - want to avoid causing premature shutdown before first error capture finishes
|
|
108
|
-
// it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff
|
|
109
|
-
// so let's instead just delay a bit before we proceed with our action here
|
|
110
|
-
// in case 1, we just wait a bit unnecessarily but ultimately do the same thing
|
|
111
|
-
// in case 2, the delay hopefully made us wait long enough for the capture to finish
|
|
112
|
-
// two potential nonideal outcomes:
|
|
113
|
-
// nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError
|
|
114
|
-
// nonideal case 2: case 2 happens, 1st error is captured but slowly, timeout completes before capture and we treat second error as the sendErr of (nonexistent) failure from trying to capture first error
|
|
115
|
-
// note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)
|
|
116
|
-
// we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish
|
|
117
|
-
caughtSecondError = true;
|
|
118
|
-
setTimeout(() => {
|
|
119
|
-
if (!calledFatalError) {
|
|
120
|
-
// it was probably case 1, let's treat err as the sendErr and call onFatalError
|
|
121
|
-
calledFatalError = true;
|
|
122
|
-
onFatalError(firstError, error);
|
|
123
|
-
}
|
|
124
|
-
}, timeout); // capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
{ _errorHandler: true },
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export { makeErrorHandler, onUncaughtExceptionIntegration };
|
|
134
|
-
//# sourceMappingURL=onuncaughtexception.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onuncaughtexception.js","sources":["../../../src/integrations/onuncaughtexception.ts"],"sourcesContent":["import { captureException, defineIntegration } from '@sentry/core';\nimport { getClient } from '@sentry/core';\nimport type { IntegrationFn } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { NodeClient } from '../sdk/client';\nimport { logAndExitProcess } from '../utils/errorhandling';\n\ntype OnFatalErrorHandler = (firstError: Error, secondError?: Error) => void;\n\ntype TaggedListener = NodeJS.UncaughtExceptionListener & {\n tag?: string;\n};\n\n// CAREFUL: Please think twice before updating the way _options looks because the Next.js SDK depends on it in `index.server.ts`\ninterface OnUncaughtExceptionOptions {\n // TODO(v8): Evaluate whether we should switch the default behaviour here.\n // Also, we can evaluate using https://nodejs.org/api/process.html#event-uncaughtexceptionmonitor per default, and\n // falling back to current behaviour when that's not available.\n /**\n * Controls if the SDK should register a handler to exit the process on uncaught errors:\n * - `true`: The SDK will exit the process on all uncaught errors.\n * - `false`: The SDK will only exit the process when there are no other `uncaughtException` handlers attached.\n *\n * Default: `true`\n */\n exitEvenIfOtherHandlersAreRegistered: boolean;\n\n /**\n * This is called when an uncaught error would cause the process to exit.\n *\n * @param firstError Uncaught error causing the process to exit\n * @param secondError Will be set if the handler was called multiple times. This can happen either because\n * `onFatalError` itself threw, or because an independent error happened somewhere else while `onFatalError`\n * was running.\n */\n onFatalError?(this: void, firstError: Error, secondError?: Error): void;\n}\n\nconst INTEGRATION_NAME = 'OnUncaughtException';\n\nconst _onUncaughtExceptionIntegration = ((options: Partial<OnUncaughtExceptionOptions> = {}) => {\n const _options = {\n exitEvenIfOtherHandlersAreRegistered: true,\n ...options,\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client: NodeClient) {\n global.process.on('uncaughtException', makeErrorHandler(client, _options));\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add a global exception handler.\n */\nexport const onUncaughtExceptionIntegration = defineIntegration(_onUncaughtExceptionIntegration);\n\ntype ErrorHandler = { _errorHandler: boolean } & ((error: Error) => void);\n\n/** Exported only for tests */\nexport function makeErrorHandler(client: NodeClient, options: OnUncaughtExceptionOptions): ErrorHandler {\n const timeout = 2000;\n let caughtFirstError: boolean = false;\n let caughtSecondError: boolean = false;\n let calledFatalError: boolean = false;\n let firstError: Error;\n\n const clientOptions = client.getOptions();\n\n return Object.assign(\n (error: Error): void => {\n let onFatalError: OnFatalErrorHandler = logAndExitProcess;\n\n if (options.onFatalError) {\n onFatalError = options.onFatalError;\n } else if (clientOptions.onFatalError) {\n onFatalError = clientOptions.onFatalError as OnFatalErrorHandler;\n }\n\n // Attaching a listener to `uncaughtException` will prevent the node process from exiting. We generally do not\n // want to alter this behaviour so we check for other listeners that users may have attached themselves and adjust\n // exit behaviour of the SDK accordingly:\n // - If other listeners are attached, do not exit.\n // - If the only listener attached is ours, exit.\n const userProvidedListenersCount = (global.process.listeners('uncaughtException') as TaggedListener[]).filter(\n listener => {\n // There are 3 listeners we ignore:\n return (\n // as soon as we're using domains this listener is attached by node itself\n listener.name !== 'domainUncaughtExceptionClear' &&\n // the handler we register for tracing\n listener.tag !== 'sentry_tracingErrorCallback' &&\n // the handler we register in this integration\n (listener as ErrorHandler)._errorHandler !== true\n );\n },\n ).length;\n\n const processWouldExit = userProvidedListenersCount === 0;\n const shouldApplyFatalHandlingLogic = options.exitEvenIfOtherHandlersAreRegistered || processWouldExit;\n\n if (!caughtFirstError) {\n // this is the first uncaught error and the ultimate reason for shutting down\n // we want to do absolutely everything possible to ensure it gets captured\n // also we want to make sure we don't go recursion crazy if more errors happen after this one\n firstError = error;\n caughtFirstError = true;\n\n if (getClient() === client) {\n captureException(error, {\n originalException: error,\n captureContext: {\n level: 'fatal',\n },\n mechanism: {\n handled: false,\n type: 'onuncaughtexception',\n },\n });\n }\n\n if (!calledFatalError && shouldApplyFatalHandlingLogic) {\n calledFatalError = true;\n onFatalError(error);\n }\n } else {\n if (shouldApplyFatalHandlingLogic) {\n if (calledFatalError) {\n // we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down\n DEBUG_BUILD &&\n logger.warn(\n 'uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown',\n );\n logAndExitProcess(error);\n } else if (!caughtSecondError) {\n // two cases for how we can hit this branch:\n // - capturing of first error blew up and we just caught the exception from that\n // - quit trying to capture, proceed with shutdown\n // - a second independent error happened while waiting for first error to capture\n // - want to avoid causing premature shutdown before first error capture finishes\n // it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff\n // so let's instead just delay a bit before we proceed with our action here\n // in case 1, we just wait a bit unnecessarily but ultimately do the same thing\n // in case 2, the delay hopefully made us wait long enough for the capture to finish\n // two potential nonideal outcomes:\n // nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError\n // nonideal case 2: case 2 happens, 1st error is captured but slowly, timeout completes before capture and we treat second error as the sendErr of (nonexistent) failure from trying to capture first error\n // note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError)\n // we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish\n caughtSecondError = true;\n setTimeout(() => {\n if (!calledFatalError) {\n // it was probably case 1, let's treat err as the sendErr and call onFatalError\n calledFatalError = true;\n onFatalError(firstError, error);\n } else {\n // it was probably case 2, our first error finished capturing while we waited, cool, do nothing\n }\n }, timeout); // capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc\n }\n }\n }\n },\n { _errorHandler: true },\n );\n}\n"],"names":[],"mappings":";;;;;AAwCA,MAAM,gBAAA,GAAmB,qBAAqB,CAAA;AAC9C;AACA,MAAM,+BAAA,IAAmC,CAAC,OAAO,GAAwC,EAAE,KAAK;AAChG,EAAE,MAAM,WAAW;AACnB,IAAI,oCAAoC,EAAE,IAAI;AAC9C,IAAI,GAAG,OAAO;AACd,GAAG,CAAA;AACH;AACA,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAc;AAC9B,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;AAChF,KAAK;AACL,GAAG,CAAA;AACH,CAAC,CAAE,EAAA;AACH;AACA;AACA;AACA;MACa,8BAA+B,GAAE,iBAAiB,CAAC,+BAA+B,EAAC;;AAIhG;AACO,SAAS,gBAAgB,CAAC,MAAM,EAAc,OAAO,EAA4C;AACxG,EAAE,MAAM,OAAQ,GAAE,IAAI,CAAA;AACtB,EAAE,IAAI,gBAAgB,GAAY,KAAK,CAAA;AACvC,EAAE,IAAI,iBAAiB,GAAY,KAAK,CAAA;AACxC,EAAE,IAAI,gBAAgB,GAAY,KAAK,CAAA;AACvC,EAAE,IAAI,UAAU,CAAA;AAChB;AACA,EAAE,MAAM,aAAc,GAAE,MAAM,CAAC,UAAU,EAAE,CAAA;AAC3C;AACA,EAAE,OAAO,MAAM,CAAC,MAAM;AACtB,IAAI,CAAC,KAAK,KAAkB;AAC5B,MAAM,IAAI,YAAY,GAAwB,iBAAiB,CAAA;AAC/D;AACA,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE;AAChC,QAA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AY,CAAC,KAAK,CAAC,CAAA;AAC7B,SAAQ;AACR,aAAa;AACb,QAAQ,IAAI,6BAA6B,EAAE;AAC3C,UAAU,IAAI,gBAAgB,EAAE;AAChC;AACA,YAAY,WAAY;AACxB,cAAc,MAAM,CAAC,IAAI;AACzB,gBAAgB,gGAAgG;AAChH,eAAe,CAAA;AACf,YAAY,iBAAiB,CAAC,KAAK,CAAC,CAAA;AACpC,iBAAiB,IAAI,CAAC,iBAAiB,EAAE;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,iBAAA,GAAoB,IAAI,CAAA;AACpC,YAAY,UAAU,CAAC,MAAM;AAC7B,cAAc,IAAI,CAAC,gBAAgB,EAAE;AACrC;AACA,gBAAgB,gBAAA,GAAmB,IAAI,CAAA;AACvC,gBAAgB,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;AAC/C,eAEc;AACd,aAAa,EAAE,OAAO,CAAC,CAAA;AACvB,WAAU;AACV,SAAQ;AACR,OAAM;AACN,KAAK;AACL,IAAI,EAAE,aAAa,EAAE,IAAA,EAAM;AAC3B,GAAG,CAAA;AACH;;;;"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { defineIntegration, getClient, captureException } from '@sentry/core';
|
|
2
|
-
import { consoleSandbox } from '@sentry/utils';
|
|
3
|
-
import { logAndExitProcess } from '../utils/errorhandling.js';
|
|
4
|
-
|
|
5
|
-
const INTEGRATION_NAME = 'OnUnhandledRejection';
|
|
6
|
-
|
|
7
|
-
const _onUnhandledRejectionIntegration = ((options = {}) => {
|
|
8
|
-
const mode = options.mode || 'warn';
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
name: INTEGRATION_NAME,
|
|
12
|
-
setup(client) {
|
|
13
|
-
global.process.on('unhandledRejection', makeUnhandledPromiseHandler(client, { mode }));
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
}) ;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Add a global promise rejection handler.
|
|
20
|
-
*/
|
|
21
|
-
const onUnhandledRejectionIntegration = defineIntegration(_onUnhandledRejectionIntegration);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Send an exception with reason
|
|
25
|
-
* @param reason string
|
|
26
|
-
* @param promise promise
|
|
27
|
-
*
|
|
28
|
-
* Exported only for tests.
|
|
29
|
-
*/
|
|
30
|
-
function makeUnhandledPromiseHandler(
|
|
31
|
-
client,
|
|
32
|
-
options,
|
|
33
|
-
) {
|
|
34
|
-
return function sendUnhandledPromise(reason, promise) {
|
|
35
|
-
if (getClient() !== client) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
captureException(reason, {
|
|
40
|
-
originalException: promise,
|
|
41
|
-
captureContext: {
|
|
42
|
-
extra: { unhandledPromiseRejection: true },
|
|
43
|
-
},
|
|
44
|
-
mechanism: {
|
|
45
|
-
handled: false,
|
|
46
|
-
type: 'onunhandledrejection',
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
handleRejection(reason, options);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Handler for `mode` option
|
|
56
|
-
|
|
57
|
-
*/
|
|
58
|
-
function handleRejection(
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
-
reason,
|
|
61
|
-
options,
|
|
62
|
-
) {
|
|
63
|
-
// https://github.com/nodejs/node/blob/7cf6f9e964aa00772965391c23acda6d71972a9a/lib/internal/process/promises.js#L234-L240
|
|
64
|
-
const rejectionWarning =
|
|
65
|
-
'This error originated either by ' +
|
|
66
|
-
'throwing inside of an async function without a catch block, ' +
|
|
67
|
-
'or by rejecting a promise which was not handled with .catch().' +
|
|
68
|
-
' The promise rejected with the reason:';
|
|
69
|
-
|
|
70
|
-
/* eslint-disable no-console */
|
|
71
|
-
if (options.mode === 'warn') {
|
|
72
|
-
consoleSandbox(() => {
|
|
73
|
-
console.warn(rejectionWarning);
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
75
|
-
console.error(reason && reason.stack ? reason.stack : reason);
|
|
76
|
-
});
|
|
77
|
-
} else if (options.mode === 'strict') {
|
|
78
|
-
consoleSandbox(() => {
|
|
79
|
-
console.warn(rejectionWarning);
|
|
80
|
-
});
|
|
81
|
-
logAndExitProcess(reason);
|
|
82
|
-
}
|
|
83
|
-
/* eslint-enable no-console */
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export { makeUnhandledPromiseHandler, onUnhandledRejectionIntegration };
|
|
87
|
-
//# sourceMappingURL=onunhandledrejection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onunhandledrejection.js","sources":["../../../src/integrations/onunhandledrejection.ts"],"sourcesContent":["import { captureException, defineIntegration, getClient } from '@sentry/core';\nimport type { Client, IntegrationFn } from '@sentry/types';\nimport { consoleSandbox } from '@sentry/utils';\nimport { logAndExitProcess } from '../utils/errorhandling';\n\ntype UnhandledRejectionMode = 'none' | 'warn' | 'strict';\n\ninterface OnUnhandledRejectionOptions {\n /**\n * Option deciding what to do after capturing unhandledRejection,\n * that mimicks behavior of node's --unhandled-rejection flag.\n */\n mode: UnhandledRejectionMode;\n}\n\nconst INTEGRATION_NAME = 'OnUnhandledRejection';\n\nconst _onUnhandledRejectionIntegration = ((options: Partial<OnUnhandledRejectionOptions> = {}) => {\n const mode = options.mode || 'warn';\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n global.process.on('unhandledRejection', makeUnhandledPromiseHandler(client, { mode }));\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Add a global promise rejection handler.\n */\nexport const onUnhandledRejectionIntegration = defineIntegration(_onUnhandledRejectionIntegration);\n\n/**\n * Send an exception with reason\n * @param reason string\n * @param promise promise\n *\n * Exported only for tests.\n */\nexport function makeUnhandledPromiseHandler(\n client: Client,\n options: OnUnhandledRejectionOptions,\n): (reason: unknown, promise: unknown) => void {\n return function sendUnhandledPromise(reason: unknown, promise: unknown): void {\n if (getClient() !== client) {\n return;\n }\n\n captureException(reason, {\n originalException: promise,\n captureContext: {\n extra: { unhandledPromiseRejection: true },\n },\n mechanism: {\n handled: false,\n type: 'onunhandledrejection',\n },\n });\n\n handleRejection(reason, options);\n };\n}\n\n/**\n * Handler for `mode` option\n\n */\nfunction handleRejection(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n reason: any,\n options: OnUnhandledRejectionOptions,\n): void {\n // https://github.com/nodejs/node/blob/7cf6f9e964aa00772965391c23acda6d71972a9a/lib/internal/process/promises.js#L234-L240\n const rejectionWarning =\n 'This error originated either by ' +\n 'throwing inside of an async function without a catch block, ' +\n 'or by rejecting a promise which was not handled with .catch().' +\n ' The promise rejected with the reason:';\n\n /* eslint-disable no-console */\n if (options.mode === 'warn') {\n consoleSandbox(() => {\n console.warn(rejectionWarning);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n console.error(reason && reason.stack ? reason.stack : reason);\n });\n } else if (options.mode === 'strict') {\n consoleSandbox(() => {\n console.warn(rejectionWarning);\n });\n logAndExitProcess(reason);\n }\n /* eslint-enable no-console */\n}\n"],"names":[],"mappings":";;;;AAeA,MAAM,gBAAA,GAAmB,sBAAsB,CAAA;AAC/C;AACA,MAAM,gCAAA,IAAoC,CAAC,OAAO,GAAyC,EAAE,KAAK;AAClG,EAAE,MAAM,IAAK,GAAE,OAAO,CAAC,IAAA,IAAQ,MAAM,CAAA;AACrC;AACA,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,2BAA2B,CAAC,MAAM,EAAE,EAAE,IAAK,EAAC,CAAC,CAAC,CAAA;AAC5F,KAAK;AACL,GAAG,CAAA;AACH,CAAC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AO,CAAC,IAAA,KAAS,QAAQ,EAAE;AACxC,IAAI,cAAc,CAAC,MAAM;AACzB,MAAM,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;AACpC,KAAK,CAAC,CAAA;AACN,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAA;AAC7B,GAAE;AACF;AACA;;;;"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import * as http from 'http';
|
|
2
|
-
import { defineIntegration } from '@sentry/core';
|
|
3
|
-
import { logger, serializeEnvelope } from '@sentry/utils';
|
|
4
|
-
|
|
5
|
-
const INTEGRATION_NAME = 'Spotlight';
|
|
6
|
-
|
|
7
|
-
const _spotlightIntegration = ((options = {}) => {
|
|
8
|
-
const _options = {
|
|
9
|
-
sidecarUrl: options.sidecarUrl || 'http://localhost:8969/stream',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
name: INTEGRATION_NAME,
|
|
14
|
-
setup(client) {
|
|
15
|
-
if (typeof process === 'object' && process.env && process.env.NODE_ENV !== 'development') {
|
|
16
|
-
logger.warn("[Spotlight] It seems you're not in dev mode. Do you really want to have Spotlight enabled?");
|
|
17
|
-
}
|
|
18
|
-
connectToSpotlight(client, _options);
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
}) ;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Use this integration to send errors and transactions to Spotlight.
|
|
25
|
-
*
|
|
26
|
-
* Learn more about spotlight at https://spotlightjs.com
|
|
27
|
-
*
|
|
28
|
-
* Important: This integration only works with Node 18 or newer.
|
|
29
|
-
*/
|
|
30
|
-
const spotlightIntegration = defineIntegration(_spotlightIntegration);
|
|
31
|
-
|
|
32
|
-
function connectToSpotlight(client, options) {
|
|
33
|
-
const spotlightUrl = parseSidecarUrl(options.sidecarUrl);
|
|
34
|
-
if (!spotlightUrl) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let failedRequests = 0;
|
|
39
|
-
|
|
40
|
-
client.on('beforeEnvelope', (envelope) => {
|
|
41
|
-
if (failedRequests > 3) {
|
|
42
|
-
logger.warn('[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests');
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const serializedEnvelope = serializeEnvelope(envelope);
|
|
47
|
-
|
|
48
|
-
const request = getNativeHttpRequest();
|
|
49
|
-
const req = request(
|
|
50
|
-
{
|
|
51
|
-
method: 'POST',
|
|
52
|
-
path: spotlightUrl.pathname,
|
|
53
|
-
hostname: spotlightUrl.hostname,
|
|
54
|
-
port: spotlightUrl.port,
|
|
55
|
-
headers: {
|
|
56
|
-
'Content-Type': 'application/x-sentry-envelope',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
res => {
|
|
60
|
-
res.on('data', () => {
|
|
61
|
-
// Drain socket
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
res.on('end', () => {
|
|
65
|
-
// Drain socket
|
|
66
|
-
});
|
|
67
|
-
res.setEncoding('utf8');
|
|
68
|
-
},
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
req.on('error', () => {
|
|
72
|
-
failedRequests++;
|
|
73
|
-
logger.warn('[Spotlight] Failed to send envelope to Spotlight Sidecar');
|
|
74
|
-
});
|
|
75
|
-
req.write(serializedEnvelope);
|
|
76
|
-
req.end();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function parseSidecarUrl(url) {
|
|
81
|
-
try {
|
|
82
|
-
return new URL(`${url}`);
|
|
83
|
-
} catch (e) {
|
|
84
|
-
logger.warn(`[Spotlight] Invalid sidecar URL: ${url}`);
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* We want to get an unpatched http request implementation to avoid capturing our own calls.
|
|
91
|
-
*/
|
|
92
|
-
function getNativeHttpRequest() {
|
|
93
|
-
const { request } = http;
|
|
94
|
-
if (isWrapped(request)) {
|
|
95
|
-
return request.__sentry_original__;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return request;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function isWrapped(impl) {
|
|
102
|
-
return '__sentry_original__' in impl;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export { getNativeHttpRequest, spotlightIntegration };
|
|
106
|
-
//# sourceMappingURL=spotlight.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spotlight.js","sources":["../../../src/integrations/spotlight.ts"],"sourcesContent":["import * as http from 'http';\nimport { defineIntegration } from '@sentry/core';\nimport type { Client, Envelope, IntegrationFn } from '@sentry/types';\nimport { logger, serializeEnvelope } from '@sentry/utils';\n\ntype SpotlightConnectionOptions = {\n /**\n * Set this if the Spotlight Sidecar is not running on localhost:8969\n * By default, the Url is set to http://localhost:8969/stream\n */\n sidecarUrl?: string;\n};\n\nconst INTEGRATION_NAME = 'Spotlight';\n\nconst _spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {}) => {\n const _options = {\n sidecarUrl: options.sidecarUrl || 'http://localhost:8969/stream',\n };\n\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n if (typeof process === 'object' && process.env && process.env.NODE_ENV !== 'development') {\n logger.warn(\"[Spotlight] It seems you're not in dev mode. Do you really want to have Spotlight enabled?\");\n }\n connectToSpotlight(client, _options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Use this integration to send errors and transactions to Spotlight.\n *\n * Learn more about spotlight at https://spotlightjs.com\n *\n * Important: This integration only works with Node 18 or newer.\n */\nexport const spotlightIntegration = defineIntegration(_spotlightIntegration);\n\nfunction connectToSpotlight(client: Client, options: Required<SpotlightConnectionOptions>): void {\n const spotlightUrl = parseSidecarUrl(options.sidecarUrl);\n if (!spotlightUrl) {\n return;\n }\n\n let failedRequests = 0;\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (failedRequests > 3) {\n logger.warn('[Spotlight] Disabled Sentry -> Spotlight integration due to too many failed requests');\n return;\n }\n\n const serializedEnvelope = serializeEnvelope(envelope);\n\n const request = getNativeHttpRequest();\n const req = request(\n {\n method: 'POST',\n path: spotlightUrl.pathname,\n hostname: spotlightUrl.hostname,\n port: spotlightUrl.port,\n headers: {\n 'Content-Type': 'application/x-sentry-envelope',\n },\n },\n res => {\n res.on('data', () => {\n // Drain socket\n });\n\n res.on('end', () => {\n // Drain socket\n });\n res.setEncoding('utf8');\n },\n );\n\n req.on('error', () => {\n failedRequests++;\n logger.warn('[Spotlight] Failed to send envelope to Spotlight Sidecar');\n });\n req.write(serializedEnvelope);\n req.end();\n });\n}\n\nfunction parseSidecarUrl(url: string): URL | undefined {\n try {\n return new URL(`${url}`);\n } catch {\n logger.warn(`[Spotlight] Invalid sidecar URL: ${url}`);\n return undefined;\n }\n}\n\ntype HttpRequestImpl = typeof http.request;\ntype WrappedHttpRequest = HttpRequestImpl & { __sentry_original__: HttpRequestImpl };\n\n/**\n * We want to get an unpatched http request implementation to avoid capturing our own calls.\n */\nexport function getNativeHttpRequest(): HttpRequestImpl {\n const { request } = http;\n if (isWrapped(request)) {\n return request.__sentry_original__;\n }\n\n return request;\n}\n\nfunction isWrapped(impl: HttpRequestImpl): impl is WrappedHttpRequest {\n return '__sentry_original__' in impl;\n}\n"],"names":[],"mappings":";;;;AAaA,MAAM,gBAAA,GAAmB,WAAW,CAAA;AACpC;AACA,MAAM,qBAAA,IAAyB,CAAC,OAAO,GAAwC,EAAE,KAAK;AACtF,EAAE,MAAM,WAAW;AACnB,IAAI,UAAU,EAAE,OAAO,CAAC,UAAA,IAAc,8BAA8B;AACpE,GAAG,CAAA;AACH;AACA,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,IAAI,OAAO,YAAY,QAAA,IAAY,OAAO,CAAC,GAAI,IAAG,OAAO,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erInstrumentations } from '@opentelemetry/instrumentation';
|
|
3
|
-
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
|
|
4
|
-
import { defineIntegration, getClient, getIsolationScope, captureException } from '@sentry/core';
|
|
5
|
-
import { addOriginToSpan } from '../../utils/addOriginToSpan.js';
|
|
6
|
-
|
|
7
|
-
const _expressIntegration = (() => {
|
|
8
|
-
return {
|
|
9
|
-
name: 'Express',
|
|
10
|
-
setupOnce() {
|
|
11
|
-
registerInstrumentations({
|
|
12
|
-
instrumentations: [
|
|
13
|
-
new ExpressInstrumentation({
|
|
14
|
-
requestHook(span) {
|
|
15
|
-
addOriginToSpan(span, 'auto.http.otel.express');
|
|
16
|
-
},
|
|
17
|
-
}),
|
|
18
|
-
],
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}) ;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Express integration
|
|
26
|
-
*
|
|
27
|
-
* Capture tracing data for express.
|
|
28
|
-
* In order to capture exceptions, you have to call `setupExpressErrorHandler(app)` before any other middleware and after all controllers.
|
|
29
|
-
*/
|
|
30
|
-
const expressIntegration = defineIntegration(_expressIntegration);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* An Express-compatible error handler.
|
|
34
|
-
*/
|
|
35
|
-
function expressErrorHandler(options
|
|
36
|
-
|
|
37
|
-
) {
|
|
38
|
-
return function sentryErrorMiddleware(
|
|
39
|
-
error,
|
|
40
|
-
_req,
|
|
41
|
-
res,
|
|
42
|
-
next,
|
|
43
|
-
) {
|
|
44
|
-
const shouldHandleError = _optionalChain([options, 'optionalAccess', _ => _.shouldHandleError]) || defaultShouldHandleError;
|
|
45
|
-
|
|
46
|
-
if (shouldHandleError(error)) {
|
|
47
|
-
const client = getClient();
|
|
48
|
-
if (client && client.getOptions().autoSessionTracking) {
|
|
49
|
-
// Check if the `SessionFlusher` is instantiated on the client to go into this branch that marks the
|
|
50
|
-
// `requestSession.status` as `Crashed`, and this check is necessary because the `SessionFlusher` is only
|
|
51
|
-
// instantiated when the the`requestHandler` middleware is initialised, which indicates that we should be
|
|
52
|
-
// running in SessionAggregates mode
|
|
53
|
-
const isSessionAggregatesMode = client['_sessionFlusher'] !== undefined;
|
|
54
|
-
if (isSessionAggregatesMode) {
|
|
55
|
-
const requestSession = getIsolationScope().getRequestSession();
|
|
56
|
-
// If an error bubbles to the `errorHandler`, then this is an unhandled error, and should be reported as a
|
|
57
|
-
// Crashed session. The `_requestSession.status` is checked to ensure that this error is happening within
|
|
58
|
-
// the bounds of a request, and if so the status is updated
|
|
59
|
-
if (requestSession && requestSession.status !== undefined) {
|
|
60
|
-
requestSession.status = 'crashed';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const eventId = captureException(error, { mechanism: { type: 'middleware', handled: false } });
|
|
66
|
-
(res ).sentry = eventId;
|
|
67
|
-
next(error);
|
|
68
|
-
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
next(error);
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Setup an error handler for Express.
|
|
78
|
-
* The error handler must be before any other middleware and after all controllers.
|
|
79
|
-
*/
|
|
80
|
-
function setupExpressErrorHandler(app) {
|
|
81
|
-
app.use(expressErrorHandler());
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function getStatusCodeFromResponse(error) {
|
|
85
|
-
const statusCode = error.status || error.statusCode || error.status_code || (error.output && error.output.statusCode);
|
|
86
|
-
return statusCode ? parseInt(statusCode , 10) : 500;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** Returns true if response code is internal server error */
|
|
90
|
-
function defaultShouldHandleError(error) {
|
|
91
|
-
const status = getStatusCodeFromResponse(error);
|
|
92
|
-
return status >= 500;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { expressErrorHandler, expressIntegration, setupExpressErrorHandler };
|
|
96
|
-
//# sourceMappingURL=express.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sources":["../../../../src/integrations/tracing/express.ts"],"sourcesContent":["import type * as http from 'http';\nimport { registerInstrumentations } from '@opentelemetry/instrumentation';\nimport { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';\nimport { defineIntegration } from '@sentry/core';\nimport { captureException, getClient, getIsolationScope } from '@sentry/core';\nimport type { IntegrationFn } from '@sentry/types';\n\nimport type { NodeClient } from '../../sdk/client';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\n\nconst _expressIntegration = (() => {\n return {\n name: 'Express',\n setupOnce() {\n registerInstrumentations({\n instrumentations: [\n new ExpressInstrumentation({\n requestHook(span) {\n addOriginToSpan(span, 'auto.http.otel.express');\n },\n }),\n ],\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Express integration\n *\n * Capture tracing data for express.\n * In order to capture exceptions, you have to call `setupExpressErrorHandler(app)` before any other middleware and after all controllers.\n */\nexport const expressIntegration = defineIntegration(_expressIntegration);\n\ninterface MiddlewareError extends Error {\n status?: number | string;\n statusCode?: number | string;\n status_code?: number | string;\n output?: {\n statusCode?: number | string;\n };\n}\n\ntype ExpressMiddleware = (\n error: MiddlewareError,\n req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n) => void;\n\n/**\n * An Express-compatible error handler.\n */\nexport function expressErrorHandler(options?: {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n * @param error Captured middleware error\n */\n shouldHandleError?(this: void, error: MiddlewareError): boolean;\n}): ExpressMiddleware {\n return function sentryErrorMiddleware(\n error: MiddlewareError,\n _req: http.IncomingMessage,\n res: http.ServerResponse,\n next: (error: MiddlewareError) => void,\n ): void {\n const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;\n\n if (shouldHandleError(error)) {\n const client = getClient<NodeClient>();\n if (client && client.getOptions().autoSessionTracking) {\n // Check if the `SessionFlusher` is instantiated on the client to go into this branch that marks the\n // `requestSession.status` as `Crashed`, and this check is necessary because the `SessionFlusher` is only\n // instantiated when the the`requestHandler` middleware is initialised, which indicates that we should be\n // running in SessionAggregates mode\n const isSessionAggregatesMode = client['_sessionFlusher'] !== undefined;\n if (isSessionAggregatesMode) {\n const requestSession = getIsolationScope().getRequestSession();\n // If an error bubbles to the `errorHandler`, then this is an unhandled error, and should be reported as a\n // Crashed session. The `_requestSession.status` is checked to ensure that this error is happening within\n // the bounds of a request, and if so the status is updated\n if (requestSession && requestSession.status !== undefined) {\n requestSession.status = 'crashed';\n }\n }\n }\n\n const eventId = captureException(error, { mechanism: { type: 'middleware', handled: false } });\n (res as { sentry?: string }).sentry = eventId;\n next(error);\n\n return;\n }\n\n next(error);\n };\n}\n\n/**\n * Setup an error handler for Express.\n * The error handler must be before any other middleware and after all controllers.\n */\nexport function setupExpressErrorHandler(app: { use: (middleware: ExpressMiddleware) => unknown }): void {\n app.use(expressErrorHandler());\n}\n\nfunction getStatusCodeFromResponse(error: MiddlewareError): number {\n const statusCode = error.status || error.statusCode || error.status_code || (error.output && error.output.statusCode);\n return statusCode ? parseInt(statusCode as string, 10) : 500;\n}\n\n/** Returns true if response code is internal server error */\nfunction defaultShouldHandleError(error: MiddlewareError): boolean {\n const status = getStatusCodeFromResponse(error);\n return status >= 500;\n}\n"],"names":[],"mappings":";;;;;;AAUA,CAAM,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAuB,CAAM,EAAA,CAAA,EAAA;EACjC,CAAO,CAAA,CAAA,CAAA,CAAA,EAAA;IACL,CAAA,CAAA,CAAA,CAAI,EAAE,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;IACf,SAAS,CAAG,EAAA;MACV,wBAAwB,CAAC;QACvB,gBAAgB,EAAE;U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;EAC/C,CAAO,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAU,CAAA,EAAA,CAAA,CAAA,CAAG;AACtB;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { registerInstrumentations } from '@opentelemetry/instrumentation';
|
|
2
|
-
import { FastifyInstrumentation } from '@opentelemetry/instrumentation-fastify';
|
|
3
|
-
import { defineIntegration } from '@sentry/core';
|
|
4
|
-
import { addOriginToSpan } from '../../utils/addOriginToSpan.js';
|
|
5
|
-
|
|
6
|
-
const _fastifyIntegration = (() => {
|
|
7
|
-
return {
|
|
8
|
-
name: 'Fastify',
|
|
9
|
-
setupOnce() {
|
|
10
|
-
registerInstrumentations({
|
|
11
|
-
instrumentations: [
|
|
12
|
-
new FastifyInstrumentation({
|
|
13
|
-
requestHook(span) {
|
|
14
|
-
addOriginToSpan(span, 'auto.http.otel.fastify');
|
|
15
|
-
},
|
|
16
|
-
}),
|
|
17
|
-
],
|
|
18
|
-
});
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
}) ;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Express integration
|
|
25
|
-
*
|
|
26
|
-
* Capture tracing data for fastify.
|
|
27
|
-
*/
|
|
28
|
-
const fastifyIntegration = defineIntegration(_fastifyIntegration);
|
|
29
|
-
|
|
30
|
-
export { fastifyIntegration };
|
|
31
|
-
//# sourceMappingURL=fastify.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.js","sources":["../../../../src/integrations/tracing/fastify.ts"],"sourcesContent":["import { registerInstrumentations } from '@opentelemetry/instrumentation';\nimport { FastifyInstrumentation } from '@opentelemetry/instrumentation-fastify';\nimport { defineIntegration } from '@sentry/core';\nimport type { IntegrationFn } from '@sentry/types';\n\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\n\nconst _fastifyIntegration = (() => {\n return {\n name: 'Fastify',\n setupOnce() {\n registerInstrumentations({\n instrumentations: [\n new FastifyInstrumentation({\n requestHook(span) {\n addOriginToSpan(span, 'auto.http.otel.fastify');\n },\n }),\n ],\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Express integration\n *\n * Capture tracing data for fastify.\n */\nexport const fastifyIntegration = defineIntegration(_fastifyIntegration);\n"],"names":[],"mappings":";;;;;AAOA,MAAM,mBAAoB,IAAG,MAAM;AACnC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,SAAS;AACnB,IAAI,SAAS,GAAG;AAChB,MAAM,wBAAwB,CAAC;AAC/B,QAAQ,gBAAgB,EAAE;AAC1B,UAAU,IAAI,sBAAsB,CAAC;AACrC,YAAY,WAAW,CAAC,IAAI,EAAE;AAC9B,cAAc,eAAe,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAA;AAC7D,aAAa;AACb,WAAW,CAAC;AACZ,SAAS;AACT,OAAO,CAAC,CAAA;AACR,KAAK;AACL,GAAG,CAAA;AACH,CAAC,CAAE,EAAA;AACH;AACA;AACA;AACA;AACA;AACA;MACa,kBAAmB,GAAE,iBAAiB,CAAC,mBAAmB;;;;"}
|