@sentry/node 9.15.0 → 9.16.1
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/build/cjs/integrations/anr/index.js +1 -1
- package/build/cjs/integrations/context.js +1 -0
- package/build/cjs/integrations/context.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +130 -126
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/cjs/integrations/http/index.js +30 -24
- package/build/cjs/integrations/http/index.js.map +1 -1
- package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/build/cjs/integrations/tracing/express-v5/instrumentation.js +4 -2
- package/build/cjs/integrations/tracing/express-v5/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/index.js +2 -4
- package/build/cjs/integrations/tracing/index.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma.js +2 -7
- package/build/cjs/integrations/tracing/prisma.js.map +1 -1
- package/build/cjs/integrations/winston.js +2 -2
- package/build/cjs/integrations/winston.js.map +1 -1
- package/build/esm/integrations/anr/index.js +1 -1
- package/build/esm/integrations/anr/worker-script.js +2 -2
- package/build/esm/integrations/context.js +1 -0
- package/build/esm/integrations/context.js.map +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +131 -127
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/esm/integrations/http/index.js +30 -24
- package/build/esm/integrations/http/index.js.map +1 -1
- package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
- package/build/esm/integrations/local-variables/worker-script.js +2 -2
- package/build/esm/integrations/tracing/express-v5/instrumentation.js +4 -2
- package/build/esm/integrations/tracing/express-v5/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/index.js +2 -4
- package/build/esm/integrations/tracing/index.js.map +1 -1
- package/build/esm/integrations/tracing/prisma.js +2 -7
- package/build/esm/integrations/tracing/prisma.js.map +1 -1
- package/build/esm/integrations/winston.js +2 -2
- package/build/esm/integrations/winston.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/integrations/context.d.ts.map +1 -1
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +9 -13
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/http/index.d.ts +8 -0
- package/build/types/integrations/http/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/express-v5/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma.d.ts.map +1 -1
- package/build/types/integrations/winston.d.ts +3 -3
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +9 -13
- package/build/types-ts3.8/integrations/http/index.d.ts +11 -0
- package/build/types-ts3.8/integrations/winston.d.ts +3 -3
- package/package.json +4 -4
- package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js +0 -130
- package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +0 -1
- package/build/cjs/integrations/http/utils.js +0 -44
- package/build/cjs/integrations/http/utils.js.map +0 -1
- package/build/cjs/integrations/http/vendor/getRequestInfo.js +0 -130
- package/build/cjs/integrations/http/vendor/getRequestInfo.js.map +0 -1
- package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js +0 -128
- package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +0 -1
- package/build/esm/integrations/http/utils.js +0 -42
- package/build/esm/integrations/http/utils.js.map +0 -1
- package/build/esm/integrations/http/vendor/getRequestInfo.js +0 -128
- package/build/esm/integrations/http/vendor/getRequestInfo.js.map +0 -1
- package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +0 -17
- package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts.map +0 -1
- package/build/types/integrations/http/vendor/getRequestInfo.d.ts +0 -21
- package/build/types/integrations/http/vendor/getRequestInfo.d.ts.map +0 -1
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +0 -20
- package/build/types-ts3.8/integrations/http/vendor/getRequestInfo.d.ts +0 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
2
|
+
import * as http from 'node:http';
|
|
3
3
|
import { EventEmitter } from 'node:stream';
|
|
4
4
|
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
5
5
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
@@ -28,7 +28,7 @@ export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
|
|
|
28
28
|
* @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.
|
|
29
29
|
* @param request Contains the {@type RequestOptions} object used to make the outgoing request.
|
|
30
30
|
*/
|
|
31
|
-
ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;
|
|
31
|
+
ignoreOutgoingRequests?: (url: string, request: http.RequestOptions) => boolean;
|
|
32
32
|
/**
|
|
33
33
|
* Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.
|
|
34
34
|
* This can be useful for long running requests where the body is not needed and we want to avoid capturing it.
|
|
@@ -36,7 +36,7 @@ export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
|
|
|
36
36
|
* @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.
|
|
37
37
|
* @param request Contains the {@type RequestOptions} object used to make the outgoing request.
|
|
38
38
|
*/
|
|
39
|
-
ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;
|
|
39
|
+
ignoreIncomingRequestBody?: (url: string, request: http.RequestOptions) => boolean;
|
|
40
40
|
/**
|
|
41
41
|
* Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.
|
|
42
42
|
* Read more about Release Health: https://docs.sentry.io/product/releases/health/
|
|
@@ -71,20 +71,16 @@ export declare class SentryHttpInstrumentation extends InstrumentationBase<Sentr
|
|
|
71
71
|
InstrumentationNodeModuleDefinition,
|
|
72
72
|
InstrumentationNodeModuleDefinition
|
|
73
73
|
];
|
|
74
|
-
/** Get the instrumentation for the http module. */
|
|
75
|
-
private _getHttpInstrumentation;
|
|
76
|
-
/** Get the instrumentation for the https module. */
|
|
77
|
-
private _getHttpsInstrumentation;
|
|
78
74
|
/**
|
|
79
|
-
*
|
|
75
|
+
* This is triggered when an outgoing request finishes.
|
|
76
|
+
* It has access to the final request and response objects.
|
|
80
77
|
*/
|
|
81
|
-
private
|
|
78
|
+
private _onOutgoingRequestFinish;
|
|
82
79
|
/**
|
|
83
|
-
* Patch
|
|
80
|
+
* Patch a server.emit function to handle process isolation for incoming requests.
|
|
81
|
+
* This will only patch the emit function if it was not already patched.
|
|
84
82
|
*/
|
|
85
|
-
private
|
|
86
|
-
/** Path the outgoing get function for breadcrumbs. */
|
|
87
|
-
private _getPatchOutgoingGetFunction;
|
|
83
|
+
private _patchServerEmitOnce;
|
|
88
84
|
}
|
|
89
85
|
/**
|
|
90
86
|
* Starts a session and tracks it in the context of a given isolation scope.
|
|
@@ -54,6 +54,17 @@ interface HttpOptions {
|
|
|
54
54
|
* You can use it to filter on additional properties like method, headers, etc.
|
|
55
55
|
*/
|
|
56
56
|
ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Do not capture spans for incoming HTTP requests with the given status codes.
|
|
59
|
+
* By default, spans with 404 status code are ignored.
|
|
60
|
+
* Expects an array of status codes or a range of status codes, e.g. [[300,399], 404] would ignore 3xx and 404 status codes.
|
|
61
|
+
*
|
|
62
|
+
* @default `[404]`
|
|
63
|
+
*/
|
|
64
|
+
dropSpansForIncomingRequestStatusCodes?: (number | [
|
|
65
|
+
number,
|
|
66
|
+
number
|
|
67
|
+
])[];
|
|
57
68
|
/**
|
|
58
69
|
* Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.
|
|
59
70
|
* This can be useful for long running requests where the body is not needed and we want to avoid capturing it.
|
|
@@ -8,7 +8,7 @@ interface WinstonTransportOptions {
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
11
|
-
* const
|
|
11
|
+
* const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport, {
|
|
12
12
|
* // Only capture error and warn logs
|
|
13
13
|
* levels: ['error', 'warn'],
|
|
14
14
|
* });
|
|
@@ -32,10 +32,10 @@ interface WinstonTransportOptions {
|
|
|
32
32
|
* const winston = require('winston');
|
|
33
33
|
* const Transport = require('winston-transport');
|
|
34
34
|
*
|
|
35
|
-
* const
|
|
35
|
+
* const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport);
|
|
36
36
|
*
|
|
37
37
|
* const logger = winston.createLogger({
|
|
38
|
-
* transports: [
|
|
38
|
+
* transports: [new SentryWinstonTransport()],
|
|
39
39
|
* });
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/node",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.16.1",
|
|
4
4
|
"description": "Sentry Node SDK using OpenTelemetry for performance instrumentation",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
"@opentelemetry/resources": "^1.30.1",
|
|
96
96
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
97
97
|
"@opentelemetry/semantic-conventions": "^1.30.0",
|
|
98
|
-
"@prisma/instrumentation": "6.
|
|
99
|
-
"@sentry/core": "9.
|
|
100
|
-
"@sentry/opentelemetry": "9.
|
|
98
|
+
"@prisma/instrumentation": "6.7.0",
|
|
99
|
+
"@sentry/core": "9.16.1",
|
|
100
|
+
"@sentry/opentelemetry": "9.16.1",
|
|
101
101
|
"import-in-the-middle": "^1.13.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const core = require('@opentelemetry/core');
|
|
4
|
-
const instrumentation = require('@opentelemetry/instrumentation');
|
|
5
|
-
const core$1 = require('@sentry/core');
|
|
6
|
-
const debugBuild = require('../../debug-build.js');
|
|
7
|
-
const utils = require('./utils.js');
|
|
8
|
-
|
|
9
|
-
// The reason this "before OTEL" integration even exists is due to timing reasons. We need to be able to register a
|
|
10
|
-
// `res.on('close')` handler **after** OTEL registers its own handler (which it uses to end spans), so that we can do
|
|
11
|
-
// something (ie. flush) after OTEL has ended a span for a request. If you think about it like an onion:
|
|
12
|
-
//
|
|
13
|
-
// (Sentry after OTEL instrumentation
|
|
14
|
-
// (OTEL instrumentation
|
|
15
|
-
// (Sentry before OTEL instrumentation
|
|
16
|
-
// (orig HTTP request handler))))
|
|
17
|
-
//
|
|
18
|
-
// registering an instrumentation before OTEL allows us to do this for incoming requests.
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* A Sentry specific http instrumentation that is applied before the otel instrumentation.
|
|
22
|
-
*/
|
|
23
|
-
class SentryHttpInstrumentationBeforeOtel extends instrumentation.InstrumentationBase {
|
|
24
|
-
constructor() {
|
|
25
|
-
super('@sentry/instrumentation-http-before-otel', core.VERSION, {});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
29
|
-
init() {
|
|
30
|
-
return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** Get the instrumentation for the http module. */
|
|
34
|
-
_getHttpInstrumentation() {
|
|
35
|
-
return new instrumentation.InstrumentationNodeModuleDefinition('http', ['*'], (moduleExports) => {
|
|
36
|
-
// Patch incoming requests
|
|
37
|
-
utils.stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());
|
|
38
|
-
|
|
39
|
-
return moduleExports;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Get the instrumentation for the https module. */
|
|
44
|
-
_getHttpsInstrumentation() {
|
|
45
|
-
return new instrumentation.InstrumentationNodeModuleDefinition('https', ['*'], (moduleExports) => {
|
|
46
|
-
// Patch incoming requests
|
|
47
|
-
utils.stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());
|
|
48
|
-
|
|
49
|
-
return moduleExports;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Patch the incoming request function for request isolation.
|
|
55
|
-
*/
|
|
56
|
-
_getPatchIncomingRequestFunction()
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
return (
|
|
60
|
-
original,
|
|
61
|
-
) => {
|
|
62
|
-
return function incomingRequest( ...args) {
|
|
63
|
-
// Only traces request events
|
|
64
|
-
if (args[0] !== 'request') {
|
|
65
|
-
return original.apply(this, args);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const response = args[1] ;
|
|
69
|
-
|
|
70
|
-
patchResponseToFlushOnServerlessPlatforms(response);
|
|
71
|
-
|
|
72
|
-
return original.apply(this, args);
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function patchResponseToFlushOnServerlessPlatforms(res) {
|
|
79
|
-
// Freely extend this function with other platforms if necessary
|
|
80
|
-
if (process.env.VERCEL) {
|
|
81
|
-
// In some cases res.end does not seem to be defined leading to errors if passed to Proxy
|
|
82
|
-
// https://github.com/getsentry/sentry-javascript/issues/15759
|
|
83
|
-
if (typeof res.end === 'function') {
|
|
84
|
-
let markOnEndDone = () => undefined;
|
|
85
|
-
const onEndDonePromise = new Promise(res => {
|
|
86
|
-
markOnEndDone = res;
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
res.on('close', () => {
|
|
90
|
-
markOnEndDone();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
94
|
-
res.end = new Proxy(res.end, {
|
|
95
|
-
apply(target, thisArg, argArray) {
|
|
96
|
-
core$1.vercelWaitUntil(
|
|
97
|
-
new Promise(finishWaitUntil => {
|
|
98
|
-
// Define a timeout that unblocks the lambda just to be safe so we're not indefinitely keeping it alive, exploding server bills
|
|
99
|
-
const timeout = setTimeout(() => {
|
|
100
|
-
finishWaitUntil();
|
|
101
|
-
}, 2000);
|
|
102
|
-
|
|
103
|
-
onEndDonePromise
|
|
104
|
-
.then(() => {
|
|
105
|
-
debugBuild.DEBUG_BUILD && core$1.logger.log('Flushing events before Vercel Lambda freeze');
|
|
106
|
-
return core$1.flush(2000);
|
|
107
|
-
})
|
|
108
|
-
.then(
|
|
109
|
-
() => {
|
|
110
|
-
clearTimeout(timeout);
|
|
111
|
-
finishWaitUntil();
|
|
112
|
-
},
|
|
113
|
-
e => {
|
|
114
|
-
clearTimeout(timeout);
|
|
115
|
-
debugBuild.DEBUG_BUILD && core$1.logger.log('Error while flushing events for Vercel:\n', e);
|
|
116
|
-
finishWaitUntil();
|
|
117
|
-
},
|
|
118
|
-
);
|
|
119
|
-
}),
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
return target.apply(thisArg, argArray);
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
exports.SentryHttpInstrumentationBeforeOtel = SentryHttpInstrumentationBeforeOtel;
|
|
130
|
-
//# sourceMappingURL=SentryHttpInstrumentationBeforeOtel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SentryHttpInstrumentationBeforeOtel.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts"],"sourcesContent":["import type * as http from 'node:http';\nimport type * as https from 'node:https';\nimport { VERSION } from '@opentelemetry/core';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport { flush, logger, vercelWaitUntil } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { stealthWrap } from './utils';\n\ntype Http = typeof http;\ntype Https = typeof https;\n\n// The reason this \"before OTEL\" integration even exists is due to timing reasons. We need to be able to register a\n// `res.on('close')` handler **after** OTEL registers its own handler (which it uses to end spans), so that we can do\n// something (ie. flush) after OTEL has ended a span for a request. If you think about it like an onion:\n//\n// (Sentry after OTEL instrumentation\n// (OTEL instrumentation\n// (Sentry before OTEL instrumentation\n// (orig HTTP request handler))))\n//\n// registering an instrumentation before OTEL allows us to do this for incoming requests.\n\n/**\n * A Sentry specific http instrumentation that is applied before the otel instrumentation.\n */\nexport class SentryHttpInstrumentationBeforeOtel extends InstrumentationBase {\n public constructor() {\n super('@sentry/instrumentation-http-before-otel', VERSION, {});\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n /** Get the instrumentation for the http module. */\n private _getHttpInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition('http', ['*'], (moduleExports: Http): Http => {\n // Patch incoming requests\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n return moduleExports;\n });\n }\n\n /** Get the instrumentation for the https module. */\n private _getHttpsInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition('https', ['*'], (moduleExports: Https): Https => {\n // Patch incoming requests\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n return moduleExports;\n });\n }\n\n /**\n * Patch the incoming request function for request isolation.\n */\n private _getPatchIncomingRequestFunction(): (\n original: (event: string, ...args: unknown[]) => boolean,\n ) => (this: unknown, event: string, ...args: unknown[]) => boolean {\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, ...args: [event: string, ...args: unknown[]]): boolean {\n // Only traces request events\n if (args[0] !== 'request') {\n return original.apply(this, args);\n }\n\n const response = args[1] as http.OutgoingMessage;\n\n patchResponseToFlushOnServerlessPlatforms(response);\n\n return original.apply(this, args);\n };\n };\n }\n}\n\nfunction patchResponseToFlushOnServerlessPlatforms(res: http.OutgoingMessage): void {\n // Freely extend this function with other platforms if necessary\n if (process.env.VERCEL) {\n // In some cases res.end does not seem to be defined leading to errors if passed to Proxy\n // https://github.com/getsentry/sentry-javascript/issues/15759\n if (typeof res.end === 'function') {\n let markOnEndDone = (): void => undefined;\n const onEndDonePromise = new Promise<void>(res => {\n markOnEndDone = res;\n });\n\n res.on('close', () => {\n markOnEndDone();\n });\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n res.end = new Proxy(res.end, {\n apply(target, thisArg, argArray) {\n vercelWaitUntil(\n new Promise<void>(finishWaitUntil => {\n // Define a timeout that unblocks the lambda just to be safe so we're not indefinitely keeping it alive, exploding server bills\n const timeout = setTimeout(() => {\n finishWaitUntil();\n }, 2000);\n\n onEndDonePromise\n .then(() => {\n DEBUG_BUILD && logger.log('Flushing events before Vercel Lambda freeze');\n return flush(2000);\n })\n .then(\n () => {\n clearTimeout(timeout);\n finishWaitUntil();\n },\n e => {\n clearTimeout(timeout);\n DEBUG_BUILD && logger.log('Error while flushing events for Vercel:\\n', e);\n finishWaitUntil();\n },\n );\n }),\n );\n\n return target.apply(thisArg, argArray);\n },\n });\n }\n }\n}\n"],"names":["InstrumentationBase","VERSION","InstrumentationNodeModuleDefinition","stealthWrap","vercelWaitUntil","DEBUG_BUILD","logger","flush"],"mappings":";;;;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,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,aAAM,CAAC,GAAG,CAAC,2CAA2C,EAAE,CAAC,CAAC;AAC7F,oBAAoB,eAAe,EAAE;AACrC,mBAAmB;AACnB,iBAAiB;AACjB,aAAa,CAAC;AACd,WAAW;;AAEX,UAAU,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC;AAChD,SAAS;AACT,OAAO,CAAC;AACR;AACA;AACA;;;;"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This is a minimal version of `wrap` from shimmer:
|
|
5
|
-
* https://github.com/othiym23/shimmer/blob/master/index.js
|
|
6
|
-
*
|
|
7
|
-
* In contrast to the original implementation, this version does not allow to unwrap,
|
|
8
|
-
* and does not make it clear that the method is wrapped.
|
|
9
|
-
* This is necessary because we want to wrap the http module with our own code,
|
|
10
|
-
* while still allowing to use the HttpInstrumentation from OTEL.
|
|
11
|
-
*
|
|
12
|
-
* Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,
|
|
13
|
-
* because it only allows any module to be wrapped a single time.
|
|
14
|
-
*/
|
|
15
|
-
function stealthWrap(
|
|
16
|
-
nodule,
|
|
17
|
-
name,
|
|
18
|
-
wrapper,
|
|
19
|
-
) {
|
|
20
|
-
const original = nodule[name];
|
|
21
|
-
const wrapped = wrapper(original);
|
|
22
|
-
|
|
23
|
-
defineProperty(nodule, name, wrapped);
|
|
24
|
-
return wrapped;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Sets a property on an object, preserving its enumerability.
|
|
28
|
-
function defineProperty(
|
|
29
|
-
obj,
|
|
30
|
-
name,
|
|
31
|
-
value,
|
|
32
|
-
) {
|
|
33
|
-
const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);
|
|
34
|
-
|
|
35
|
-
Object.defineProperty(obj, name, {
|
|
36
|
-
configurable: true,
|
|
37
|
-
enumerable: enumerable,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: value,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
exports.stealthWrap = stealthWrap;
|
|
44
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/integrations/http/utils.ts"],"sourcesContent":["/**\n * This is a minimal version of `wrap` from shimmer:\n * https://github.com/othiym23/shimmer/blob/master/index.js\n *\n * In contrast to the original implementation, this version does not allow to unwrap,\n * and does not make it clear that the method is wrapped.\n * This is necessary because we want to wrap the http module with our own code,\n * while still allowing to use the HttpInstrumentation from OTEL.\n *\n * Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,\n * because it only allows any module to be wrapped a single time.\n */\nexport function stealthWrap<Nodule extends object, FieldName extends keyof Nodule>(\n nodule: Nodule,\n name: FieldName,\n wrapper: (original: Nodule[FieldName]) => Nodule[FieldName],\n): Nodule[FieldName] {\n const original = nodule[name];\n const wrapped = wrapper(original);\n\n defineProperty(nodule, name, wrapped);\n return wrapped;\n}\n\n// Sets a property on an object, preserving its enumerability.\nfunction defineProperty<Nodule extends object, FieldName extends keyof Nodule>(\n obj: Nodule,\n name: FieldName,\n value: Nodule[FieldName],\n): void {\n const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);\n\n Object.defineProperty(obj, name, {\n configurable: true,\n enumerable: enumerable,\n writable: true,\n value: value,\n });\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW;AAC3B,EAAE,MAAM;AACR,EAAE,IAAI;AACN,EAAE,OAAO;AACT,EAAqB;AACrB,EAAE,MAAM,QAAS,GAAE,MAAM,CAAC,IAAI,CAAC;AAC/B,EAAE,MAAM,OAAQ,GAAE,OAAO,CAAC,QAAQ,CAAC;;AAEnC,EAAE,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC;AACvC,EAAE,OAAO,OAAO;AAChB;;AAEA;AACA,SAAS,cAAc;AACvB,EAAE,GAAG;AACL,EAAE,IAAI;AACN,EAAE,KAAK;AACP,EAAQ;AACR,EAAE,MAAM,aAAa,CAAC,CAAC,GAAG,CAAC,IAAI,CAAE,IAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC;;AAEzF,EAAE,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE;AACnC,IAAI,YAAY,EAAE,IAAI;AACtB,IAAI,UAAU,EAAE,UAAU;AAC1B,IAAI,QAAQ,EAAE,IAAI;AAClB,IAAI,KAAK,EAAE,KAAK;AAChB,GAAG,CAAC;AACJ;;;;"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
3
|
-
const url = require('url');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Makes sure options is an url object
|
|
7
|
-
* return an object with default value and parsed options
|
|
8
|
-
* @param logger component logger
|
|
9
|
-
* @param options original options for the request
|
|
10
|
-
* @param [extraOptions] additional options for the request
|
|
11
|
-
*/
|
|
12
|
-
const getRequestInfo = (
|
|
13
|
-
logger,
|
|
14
|
-
options,
|
|
15
|
-
extraOptions,
|
|
16
|
-
|
|
17
|
-
) => {
|
|
18
|
-
let pathname;
|
|
19
|
-
let origin;
|
|
20
|
-
let optionsParsed;
|
|
21
|
-
let invalidUrl = false;
|
|
22
|
-
if (typeof options === 'string') {
|
|
23
|
-
try {
|
|
24
|
-
const convertedOptions = stringUrlToHttpOptions(options);
|
|
25
|
-
optionsParsed = convertedOptions;
|
|
26
|
-
pathname = convertedOptions.pathname || '/';
|
|
27
|
-
} catch (e) {
|
|
28
|
-
invalidUrl = true;
|
|
29
|
-
logger.verbose(
|
|
30
|
-
'Unable to parse URL provided to HTTP request, using fallback to determine path. Original error:',
|
|
31
|
-
e,
|
|
32
|
-
);
|
|
33
|
-
// for backward compatibility with how url.parse() behaved.
|
|
34
|
-
optionsParsed = {
|
|
35
|
-
path: options,
|
|
36
|
-
};
|
|
37
|
-
pathname = optionsParsed.path || '/';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
origin = `${optionsParsed.protocol || 'http:'}//${optionsParsed.host}`;
|
|
41
|
-
if (extraOptions !== undefined) {
|
|
42
|
-
Object.assign(optionsParsed, extraOptions);
|
|
43
|
-
}
|
|
44
|
-
} else if (options instanceof url.URL) {
|
|
45
|
-
optionsParsed = {
|
|
46
|
-
protocol: options.protocol,
|
|
47
|
-
hostname:
|
|
48
|
-
typeof options.hostname === 'string' && options.hostname.startsWith('[')
|
|
49
|
-
? options.hostname.slice(1, -1)
|
|
50
|
-
: options.hostname,
|
|
51
|
-
path: `${options.pathname || ''}${options.search || ''}`,
|
|
52
|
-
};
|
|
53
|
-
if (options.port !== '') {
|
|
54
|
-
optionsParsed.port = Number(options.port);
|
|
55
|
-
}
|
|
56
|
-
if (options.username || options.password) {
|
|
57
|
-
optionsParsed.auth = `${options.username}:${options.password}`;
|
|
58
|
-
}
|
|
59
|
-
pathname = options.pathname;
|
|
60
|
-
origin = options.origin;
|
|
61
|
-
if (extraOptions !== undefined) {
|
|
62
|
-
Object.assign(optionsParsed, extraOptions);
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
optionsParsed = Object.assign({ protocol: options.host ? 'http:' : undefined }, options);
|
|
66
|
-
|
|
67
|
-
const hostname =
|
|
68
|
-
optionsParsed.host ||
|
|
69
|
-
(optionsParsed.port != null ? `${optionsParsed.hostname}${optionsParsed.port}` : optionsParsed.hostname);
|
|
70
|
-
origin = `${optionsParsed.protocol || 'http:'}//${hostname}`;
|
|
71
|
-
|
|
72
|
-
pathname = (options ).pathname;
|
|
73
|
-
if (!pathname && optionsParsed.path) {
|
|
74
|
-
try {
|
|
75
|
-
const parsedUrl = new URL(optionsParsed.path, origin);
|
|
76
|
-
pathname = parsedUrl.pathname || '/';
|
|
77
|
-
} catch (e) {
|
|
78
|
-
pathname = '/';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// some packages return method in lowercase..
|
|
84
|
-
// ensure upperCase for consistency
|
|
85
|
-
const method = optionsParsed.method ? optionsParsed.method.toUpperCase() : 'GET';
|
|
86
|
-
|
|
87
|
-
return { origin, pathname, method, optionsParsed, invalidUrl };
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Mimics Node.js conversion of URL strings to RequestOptions expected by
|
|
92
|
-
* `http.request` and `https.request` APIs.
|
|
93
|
-
*
|
|
94
|
-
* See https://github.com/nodejs/node/blob/2505e217bba05fc581b572c685c5cf280a16c5a3/lib/internal/url.js#L1415-L1437
|
|
95
|
-
*
|
|
96
|
-
* @param stringUrl
|
|
97
|
-
* @throws TypeError if the URL is not valid.
|
|
98
|
-
*/
|
|
99
|
-
function stringUrlToHttpOptions(stringUrl) {
|
|
100
|
-
// This is heavily inspired by Node.js handling of the same situation, trying
|
|
101
|
-
// to follow it as closely as possible while keeping in mind that we only
|
|
102
|
-
// deal with string URLs, not URL objects.
|
|
103
|
-
const { hostname, pathname, port, username, password, search, protocol, hash, href, origin, host } = new URL(
|
|
104
|
-
stringUrl,
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
const options
|
|
108
|
-
|
|
109
|
-
= {
|
|
110
|
-
protocol: protocol,
|
|
111
|
-
hostname: hostname && hostname[0] === '[' ? hostname.slice(1, -1) : hostname,
|
|
112
|
-
hash: hash,
|
|
113
|
-
search: search,
|
|
114
|
-
pathname: pathname,
|
|
115
|
-
path: `${pathname || ''}${search || ''}`,
|
|
116
|
-
href: href,
|
|
117
|
-
origin: origin,
|
|
118
|
-
host: host,
|
|
119
|
-
};
|
|
120
|
-
if (port !== '') {
|
|
121
|
-
options.port = Number(port);
|
|
122
|
-
}
|
|
123
|
-
if (username || password) {
|
|
124
|
-
options.auth = `${decodeURIComponent(username)}:${decodeURIComponent(password)}`;
|
|
125
|
-
}
|
|
126
|
-
return options;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
exports.getRequestInfo = getRequestInfo;
|
|
130
|
-
//# sourceMappingURL=getRequestInfo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestInfo.js","sources":["../../../../../src/integrations/http/vendor/getRequestInfo.ts"],"sourcesContent":["/* eslint-disable complexity */\n\n/**\n * Vendored in from https://github.com/open-telemetry/opentelemetry-js/commit/87bd98edd24c98a5fbb9a56fed4b673b7f17a724\n */\n\n/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { RequestOptions } from 'node:http';\nimport type { DiagLogger } from '@opentelemetry/api';\nimport * as url from 'url';\n\n/**\n * Makes sure options is an url object\n * return an object with default value and parsed options\n * @param logger component logger\n * @param options original options for the request\n * @param [extraOptions] additional options for the request\n */\nexport const getRequestInfo = (\n logger: DiagLogger,\n options: url.URL | RequestOptions | string,\n extraOptions?: RequestOptions,\n): {\n origin: string;\n pathname: string;\n method: string;\n invalidUrl: boolean;\n optionsParsed: RequestOptions;\n} => {\n let pathname: string;\n let origin: string;\n let optionsParsed: RequestOptions;\n let invalidUrl = false;\n if (typeof options === 'string') {\n try {\n const convertedOptions = stringUrlToHttpOptions(options);\n optionsParsed = convertedOptions;\n pathname = convertedOptions.pathname || '/';\n } catch (e) {\n invalidUrl = true;\n logger.verbose(\n 'Unable to parse URL provided to HTTP request, using fallback to determine path. Original error:',\n e,\n );\n // for backward compatibility with how url.parse() behaved.\n optionsParsed = {\n path: options,\n };\n pathname = optionsParsed.path || '/';\n }\n\n origin = `${optionsParsed.protocol || 'http:'}//${optionsParsed.host}`;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else if (options instanceof url.URL) {\n optionsParsed = {\n protocol: options.protocol,\n hostname:\n typeof options.hostname === 'string' && options.hostname.startsWith('[')\n ? options.hostname.slice(1, -1)\n : options.hostname,\n path: `${options.pathname || ''}${options.search || ''}`,\n };\n if (options.port !== '') {\n optionsParsed.port = Number(options.port);\n }\n if (options.username || options.password) {\n optionsParsed.auth = `${options.username}:${options.password}`;\n }\n pathname = options.pathname;\n origin = options.origin;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else {\n optionsParsed = Object.assign({ protocol: options.host ? 'http:' : undefined }, options);\n\n const hostname =\n optionsParsed.host ||\n (optionsParsed.port != null ? `${optionsParsed.hostname}${optionsParsed.port}` : optionsParsed.hostname);\n origin = `${optionsParsed.protocol || 'http:'}//${hostname}`;\n\n pathname = (options as url.URL).pathname;\n if (!pathname && optionsParsed.path) {\n try {\n const parsedUrl = new URL(optionsParsed.path, origin);\n pathname = parsedUrl.pathname || '/';\n } catch (e) {\n pathname = '/';\n }\n }\n }\n\n // some packages return method in lowercase..\n // ensure upperCase for consistency\n const method = optionsParsed.method ? optionsParsed.method.toUpperCase() : 'GET';\n\n return { origin, pathname, method, optionsParsed, invalidUrl };\n};\n\n/**\n * Mimics Node.js conversion of URL strings to RequestOptions expected by\n * `http.request` and `https.request` APIs.\n *\n * See https://github.com/nodejs/node/blob/2505e217bba05fc581b572c685c5cf280a16c5a3/lib/internal/url.js#L1415-L1437\n *\n * @param stringUrl\n * @throws TypeError if the URL is not valid.\n */\nfunction stringUrlToHttpOptions(stringUrl: string): RequestOptions & { pathname: string } {\n // This is heavily inspired by Node.js handling of the same situation, trying\n // to follow it as closely as possible while keeping in mind that we only\n // deal with string URLs, not URL objects.\n const { hostname, pathname, port, username, password, search, protocol, hash, href, origin, host } = new URL(\n stringUrl,\n );\n\n const options: RequestOptions & {\n pathname: string;\n hash: string;\n search: string;\n href: string;\n origin: string;\n } = {\n protocol: protocol,\n hostname: hostname && hostname[0] === '[' ? hostname.slice(1, -1) : hostname,\n hash: hash,\n search: search,\n pathname: pathname,\n path: `${pathname || ''}${search || ''}`,\n href: href,\n origin: origin,\n host: host,\n };\n if (port !== '') {\n options.port = Number(port);\n }\n if (username || password) {\n options.auth = `${decodeURIComponent(username)}:${decodeURIComponent(password)}`;\n }\n return options;\n}\n"],"names":[],"mappings":";;;;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,iBAAiB;AAC9B,EAAE,MAAM;AACR,EAAE,OAAO;AACT,EAAE,YAAY;;AAOd,KAAK;AACL,EAAE,IAAI,QAAQ;AACd,EAAE,IAAI,MAAM;AACZ,EAAE,IAAI,aAAa;AACnB,EAAE,IAAI,UAAW,GAAE,KAAK;AACxB,EAAE,IAAI,OAAO,OAAQ,KAAI,QAAQ,EAAE;AACnC,IAAI,IAAI;AACR,MAAM,MAAM,gBAAiB,GAAE,sBAAsB,CAAC,OAAO,CAAC;AAC9D,MAAM,aAAA,GAAgB,gBAAgB;AACtC,MAAM,WAAW,gBAAgB,CAAC,QAAA,IAAY,GAAG;AACjD,KAAM,CAAA,OAAO,CAAC,EAAE;AAChB,MAAM,UAAA,GAAa,IAAI;AACvB,MAAM,MAAM,CAAC,OAAO;AACpB,QAAQ,iGAAiG;AACzG,QAAQ,CAAC;AACT,OAAO;AACP;AACA,MAAM,gBAAgB;AACtB,QAAQ,IAAI,EAAE,OAAO;AACrB,OAAO;AACP,MAAM,WAAW,aAAa,CAAC,IAAA,IAAQ,GAAG;AAC1C;;AAEA,IAAI,MAAA,GAAS,CAAC,EAAA,aAAA,CAAA,QAAA,IAAA,OAAA,CAAA,EAAA,EAAA,aAAA,C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A,IAAA,QAAA,CAAA,CAAA,CAAA,KAAA,GAAA,GAAA,QAAA,CAAA,KAAA,CAAA,CAAA,EAAA,EAAA,CAAA,GAAA,QAAA;AACA,IAAA,IAAA,EAAA,IAAA;AACA,IAAA,MAAA,EAAA,MAAA;AACA,IAAA,QAAA,EAAA,QAAA;AACA,IAAA,IAAA,EAAA,CAAA,EAAA,QAAA,IAAA,EAAA,CAAA,EAAA,MAAA,IAAA,EAAA,CAAA,CAAA;AACA,IAAA,IAAA,EAAA,IAAA;AACA,IAAA,MAAA,EAAA,MAAA;AACA,IAAA,IAAA,EAAA,IAAA;AACA,GAAA;AACA,EAAA,IAAA,IAAA,KAAA,EAAA,EAAA;AACA,IAAA,OAAA,CAAA,IAAA,GAAA,MAAA,CAAA,IAAA,CAAA;AACA;AACA,EAAA,IAAA,QAAA,IAAA,QAAA,EAAA;AACA,IAAA,OAAA,CAAA,IAAA,GAAA,CAAA,EAAA,kBAAA,CAAA,QAAA,CAAA,CAAA,CAAA,EAAA,kBAAA,CAAA,QAAA,CAAA,CAAA,CAAA;AACA;AACA,EAAA,OAAA,OAAA;AACA;;;;"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { VERSION } from '@opentelemetry/core';
|
|
2
|
-
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
3
|
-
import { vercelWaitUntil, logger, flush } from '@sentry/core';
|
|
4
|
-
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
5
|
-
import { stealthWrap } from './utils.js';
|
|
6
|
-
|
|
7
|
-
// The reason this "before OTEL" integration even exists is due to timing reasons. We need to be able to register a
|
|
8
|
-
// `res.on('close')` handler **after** OTEL registers its own handler (which it uses to end spans), so that we can do
|
|
9
|
-
// something (ie. flush) after OTEL has ended a span for a request. If you think about it like an onion:
|
|
10
|
-
//
|
|
11
|
-
// (Sentry after OTEL instrumentation
|
|
12
|
-
// (OTEL instrumentation
|
|
13
|
-
// (Sentry before OTEL instrumentation
|
|
14
|
-
// (orig HTTP request handler))))
|
|
15
|
-
//
|
|
16
|
-
// registering an instrumentation before OTEL allows us to do this for incoming requests.
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A Sentry specific http instrumentation that is applied before the otel instrumentation.
|
|
20
|
-
*/
|
|
21
|
-
class SentryHttpInstrumentationBeforeOtel extends InstrumentationBase {
|
|
22
|
-
constructor() {
|
|
23
|
-
super('@sentry/instrumentation-http-before-otel', VERSION, {});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
27
|
-
init() {
|
|
28
|
-
return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Get the instrumentation for the http module. */
|
|
32
|
-
_getHttpInstrumentation() {
|
|
33
|
-
return new InstrumentationNodeModuleDefinition('http', ['*'], (moduleExports) => {
|
|
34
|
-
// Patch incoming requests
|
|
35
|
-
stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());
|
|
36
|
-
|
|
37
|
-
return moduleExports;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Get the instrumentation for the https module. */
|
|
42
|
-
_getHttpsInstrumentation() {
|
|
43
|
-
return new InstrumentationNodeModuleDefinition('https', ['*'], (moduleExports) => {
|
|
44
|
-
// Patch incoming requests
|
|
45
|
-
stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());
|
|
46
|
-
|
|
47
|
-
return moduleExports;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Patch the incoming request function for request isolation.
|
|
53
|
-
*/
|
|
54
|
-
_getPatchIncomingRequestFunction()
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
return (
|
|
58
|
-
original,
|
|
59
|
-
) => {
|
|
60
|
-
return function incomingRequest( ...args) {
|
|
61
|
-
// Only traces request events
|
|
62
|
-
if (args[0] !== 'request') {
|
|
63
|
-
return original.apply(this, args);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const response = args[1] ;
|
|
67
|
-
|
|
68
|
-
patchResponseToFlushOnServerlessPlatforms(response);
|
|
69
|
-
|
|
70
|
-
return original.apply(this, args);
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function patchResponseToFlushOnServerlessPlatforms(res) {
|
|
77
|
-
// Freely extend this function with other platforms if necessary
|
|
78
|
-
if (process.env.VERCEL) {
|
|
79
|
-
// In some cases res.end does not seem to be defined leading to errors if passed to Proxy
|
|
80
|
-
// https://github.com/getsentry/sentry-javascript/issues/15759
|
|
81
|
-
if (typeof res.end === 'function') {
|
|
82
|
-
let markOnEndDone = () => undefined;
|
|
83
|
-
const onEndDonePromise = new Promise(res => {
|
|
84
|
-
markOnEndDone = res;
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
res.on('close', () => {
|
|
88
|
-
markOnEndDone();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
92
|
-
res.end = new Proxy(res.end, {
|
|
93
|
-
apply(target, thisArg, argArray) {
|
|
94
|
-
vercelWaitUntil(
|
|
95
|
-
new Promise(finishWaitUntil => {
|
|
96
|
-
// Define a timeout that unblocks the lambda just to be safe so we're not indefinitely keeping it alive, exploding server bills
|
|
97
|
-
const timeout = setTimeout(() => {
|
|
98
|
-
finishWaitUntil();
|
|
99
|
-
}, 2000);
|
|
100
|
-
|
|
101
|
-
onEndDonePromise
|
|
102
|
-
.then(() => {
|
|
103
|
-
DEBUG_BUILD && logger.log('Flushing events before Vercel Lambda freeze');
|
|
104
|
-
return flush(2000);
|
|
105
|
-
})
|
|
106
|
-
.then(
|
|
107
|
-
() => {
|
|
108
|
-
clearTimeout(timeout);
|
|
109
|
-
finishWaitUntil();
|
|
110
|
-
},
|
|
111
|
-
e => {
|
|
112
|
-
clearTimeout(timeout);
|
|
113
|
-
DEBUG_BUILD && logger.log('Error while flushing events for Vercel:\n', e);
|
|
114
|
-
finishWaitUntil();
|
|
115
|
-
},
|
|
116
|
-
);
|
|
117
|
-
}),
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
return target.apply(thisArg, argArray);
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export { SentryHttpInstrumentationBeforeOtel };
|
|
128
|
-
//# sourceMappingURL=SentryHttpInstrumentationBeforeOtel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SentryHttpInstrumentationBeforeOtel.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts"],"sourcesContent":["import type * as http from 'node:http';\nimport type * as https from 'node:https';\nimport { VERSION } from '@opentelemetry/core';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport { flush, logger, vercelWaitUntil } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { stealthWrap } from './utils';\n\ntype Http = typeof http;\ntype Https = typeof https;\n\n// The reason this \"before OTEL\" integration even exists is due to timing reasons. We need to be able to register a\n// `res.on('close')` handler **after** OTEL registers its own handler (which it uses to end spans), so that we can do\n// something (ie. flush) after OTEL has ended a span for a request. If you think about it like an onion:\n//\n// (Sentry after OTEL instrumentation\n// (OTEL instrumentation\n// (Sentry before OTEL instrumentation\n// (orig HTTP request handler))))\n//\n// registering an instrumentation before OTEL allows us to do this for incoming requests.\n\n/**\n * A Sentry specific http instrumentation that is applied before the otel instrumentation.\n */\nexport class SentryHttpInstrumentationBeforeOtel extends InstrumentationBase {\n public constructor() {\n super('@sentry/instrumentation-http-before-otel', VERSION, {});\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n /** Get the instrumentation for the http module. */\n private _getHttpInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition('http', ['*'], (moduleExports: Http): Http => {\n // Patch incoming requests\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n return moduleExports;\n });\n }\n\n /** Get the instrumentation for the https module. */\n private _getHttpsInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition('https', ['*'], (moduleExports: Https): Https => {\n // Patch incoming requests\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n return moduleExports;\n });\n }\n\n /**\n * Patch the incoming request function for request isolation.\n */\n private _getPatchIncomingRequestFunction(): (\n original: (event: string, ...args: unknown[]) => boolean,\n ) => (this: unknown, event: string, ...args: unknown[]) => boolean {\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, ...args: [event: string, ...args: unknown[]]): boolean {\n // Only traces request events\n if (args[0] !== 'request') {\n return original.apply(this, args);\n }\n\n const response = args[1] as http.OutgoingMessage;\n\n patchResponseToFlushOnServerlessPlatforms(response);\n\n return original.apply(this, args);\n };\n };\n }\n}\n\nfunction patchResponseToFlushOnServerlessPlatforms(res: http.OutgoingMessage): void {\n // Freely extend this function with other platforms if necessary\n if (process.env.VERCEL) {\n // In some cases res.end does not seem to be defined leading to errors if passed to Proxy\n // https://github.com/getsentry/sentry-javascript/issues/15759\n if (typeof res.end === 'function') {\n let markOnEndDone = (): void => undefined;\n const onEndDonePromise = new Promise<void>(res => {\n markOnEndDone = res;\n });\n\n res.on('close', () => {\n markOnEndDone();\n });\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n res.end = new Proxy(res.end, {\n apply(target, thisArg, argArray) {\n vercelWaitUntil(\n new Promise<void>(finishWaitUntil => {\n // Define a timeout that unblocks the lambda just to be safe so we're not indefinitely keeping it alive, exploding server bills\n const timeout = setTimeout(() => {\n finishWaitUntil();\n }, 2000);\n\n onEndDonePromise\n .then(() => {\n DEBUG_BUILD && logger.log('Flushing events before Vercel Lambda freeze');\n return flush(2000);\n })\n .then(\n () => {\n clearTimeout(timeout);\n finishWaitUntil();\n },\n e => {\n clearTimeout(timeout);\n DEBUG_BUILD && logger.log('Error while flushing events for Vercel:\\n', e);\n finishWaitUntil();\n },\n );\n }),\n );\n\n return target.apply(thisArg, argArray);\n },\n });\n }\n }\n}\n"],"names":[],"mappings":";;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAM,mCAAoC,SAAQ,mBAAoB,CAAA;AAC7E,GAAS,WAAW,GAAG;AACvB,IAAI,KAAK,CAAC,0CAA0C,EAAE,OAAO,EAAE,EAAE,CAAC;AAClE;;AAEA;AACA,GAAS,IAAI,GAA+E;AAC5F,IAAI,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,IAAI,CAAC,uBAAuB,EAAE,CAAC;AAC5E;;AAEA;AACA,GAAU,uBAAuB,GAAwC;AACzE,IAAI,OAAO,IAAI,mCAAmC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,aAAa,KAAiB;AACjG;AACA,MAAM,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC;;AAElG,MAAM,OAAO,aAAa;AAC1B,KAAK,CAAC;AACN;;AAEA;AACA,GAAU,wBAAwB,GAAwC;AAC1E,IAAI,OAAO,IAAI,mCAAmC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,aAAa,KAAmB;AACpG;AACA,MAAM,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,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AQ,GAAE,UAAU,CAAC,MAAM;AAC/C,gBAAgB,eAAe,EAAE;AACjC,eAAe,EAAE,IAAI,CAAC;;AAEtB,cAAc;AACd,iBAAiB,IAAI,CAAC,MAAM;AAC5B,kBAAkB,eAAe,MAAM,CAAC,GAAG,CAAC,6CAA6C,CAAC;AAC1F,kBAAkB,OAAO,KAAK,CAAC,IAAI,CAAC;AACpC,iBAAiB;AACjB,iBAAiB,IAAI;AACrB,kBAAkB,MAAM;AACxB,oBAAoB,YAAY,CAAC,OAAO,CAAC;AACzC,oBAAoB,eAAe,EAAE;AACrC,mBAAmB;AACnB,kBAAkB,KAAK;AACvB,oBAAoB,YAAY,CAAC,OAAO,CAAC;AACzC,oBAAoB,WAAA,IAAe,MAAM,CAAC,GAAG,CAAC,2CAA2C,EAAE,CAAC,CAAC;AAC7F,oBAAoB,eAAe,EAAE;AACrC,mBAAmB;AACnB,iBAAiB;AACjB,aAAa,CAAC;AACd,WAAW;;AAEX,UAAU,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC;AAChD,SAAS;AACT,OAAO,CAAC;AACR;AACA;AACA;;;;"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a minimal version of `wrap` from shimmer:
|
|
3
|
-
* https://github.com/othiym23/shimmer/blob/master/index.js
|
|
4
|
-
*
|
|
5
|
-
* In contrast to the original implementation, this version does not allow to unwrap,
|
|
6
|
-
* and does not make it clear that the method is wrapped.
|
|
7
|
-
* This is necessary because we want to wrap the http module with our own code,
|
|
8
|
-
* while still allowing to use the HttpInstrumentation from OTEL.
|
|
9
|
-
*
|
|
10
|
-
* Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,
|
|
11
|
-
* because it only allows any module to be wrapped a single time.
|
|
12
|
-
*/
|
|
13
|
-
function stealthWrap(
|
|
14
|
-
nodule,
|
|
15
|
-
name,
|
|
16
|
-
wrapper,
|
|
17
|
-
) {
|
|
18
|
-
const original = nodule[name];
|
|
19
|
-
const wrapped = wrapper(original);
|
|
20
|
-
|
|
21
|
-
defineProperty(nodule, name, wrapped);
|
|
22
|
-
return wrapped;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Sets a property on an object, preserving its enumerability.
|
|
26
|
-
function defineProperty(
|
|
27
|
-
obj,
|
|
28
|
-
name,
|
|
29
|
-
value,
|
|
30
|
-
) {
|
|
31
|
-
const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);
|
|
32
|
-
|
|
33
|
-
Object.defineProperty(obj, name, {
|
|
34
|
-
configurable: true,
|
|
35
|
-
enumerable: enumerable,
|
|
36
|
-
writable: true,
|
|
37
|
-
value: value,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { stealthWrap };
|
|
42
|
-
//# sourceMappingURL=utils.js.map
|