@sentry/node 10.50.0 → 10.52.0
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/index.js +4 -4
- package/build/cjs/integrations/http.js +18 -145
- package/build/cjs/integrations/http.js.map +1 -1
- package/build/cjs/integrations/tracing/index.js +21 -22
- package/build/cjs/integrations/tracing/index.js.map +1 -1
- package/build/cjs/integrations/tracing/langgraph/instrumentation.js +70 -25
- package/build/cjs/integrations/tracing/langgraph/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma.js +6 -2
- package/build/cjs/integrations/tracing/prisma.js.map +1 -1
- package/build/cjs/integrations/tracing/{redis.js → redis/index.js} +18 -10
- package/build/cjs/integrations/tracing/redis/index.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/redis-dc-subscriber.js +186 -0
- package/build/cjs/integrations/tracing/redis/redis-dc-subscriber.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js +255 -0
- package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/vendored/redis-common.js +74 -0
- package/build/cjs/integrations/tracing/redis/vendored/redis-common.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js +685 -0
- package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -0
- package/build/cjs/integrations/tracing/redis/vendored/semconv.js +47 -0
- package/build/cjs/integrations/tracing/redis/vendored/semconv.js.map +1 -0
- package/build/cjs/utils/redisCache.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/integrations/http.js +21 -146
- package/build/esm/integrations/http.js.map +1 -1
- package/build/esm/integrations/tracing/index.js +2 -3
- package/build/esm/integrations/tracing/index.js.map +1 -1
- package/build/esm/integrations/tracing/langgraph/instrumentation.js +71 -26
- package/build/esm/integrations/tracing/langgraph/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/prisma.js +6 -2
- package/build/esm/integrations/tracing/prisma.js.map +1 -1
- package/build/esm/integrations/tracing/{redis.js → redis/index.js} +17 -9
- package/build/esm/integrations/tracing/redis/index.js.map +1 -0
- package/build/esm/integrations/tracing/redis/redis-dc-subscriber.js +184 -0
- package/build/esm/integrations/tracing/redis/redis-dc-subscriber.js.map +1 -0
- package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js +253 -0
- package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/redis/vendored/redis-common.js +72 -0
- package/build/esm/integrations/tracing/redis/vendored/redis-common.js.map +1 -0
- package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js +683 -0
- package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -0
- package/build/esm/integrations/tracing/redis/vendored/semconv.js +39 -0
- package/build/esm/integrations/tracing/redis/vendored/semconv.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/utils/redisCache.js.map +1 -1
- package/build/types/integrations/http.d.ts +8 -15
- package/build/types/integrations/http.d.ts.map +1 -1
- package/build/types/integrations/tracing/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/langgraph/instrumentation.d.ts +1 -1
- package/build/types/integrations/tracing/langgraph/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma.d.ts.map +1 -1
- package/build/types/integrations/tracing/{redis.d.ts → redis/index.d.ts} +3 -3
- package/build/types/integrations/tracing/redis/index.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/redis-dc-subscriber.d.ts +17 -0
- package/build/types/integrations/tracing/redis/redis-dc-subscriber.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts +15 -0
- package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/redis-common.d.ts +6 -0
- package/build/types/integrations/tracing/redis/vendored/redis-common.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts +16 -0
- package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/semconv.d.ts +8 -0
- package/build/types/integrations/tracing/redis/vendored/semconv.d.ts.map +1 -0
- package/build/types/integrations/tracing/redis/vendored/types.d.ts +58 -0
- package/build/types/integrations/tracing/redis/vendored/types.d.ts.map +1 -0
- package/build/types/utils/redisCache.d.ts +1 -1
- package/build/types/utils/redisCache.d.ts.map +1 -1
- package/build/types-ts3.8/integrations/http.d.ts +8 -15
- package/build/types-ts3.8/integrations/tracing/langgraph/instrumentation.d.ts +1 -1
- package/build/types-ts3.8/integrations/tracing/{redis.d.ts → redis/index.d.ts} +3 -3
- package/build/types-ts3.8/integrations/tracing/redis/redis-dc-subscriber.d.ts +17 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts +15 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/redis-common.d.ts +6 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/redis-instrumentation.d.ts +16 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/semconv.d.ts +8 -0
- package/build/types-ts3.8/integrations/tracing/redis/vendored/types.d.ts +58 -0
- package/build/types-ts3.8/utils/redisCache.d.ts +1 -1
- package/package.json +4 -6
- package/build/cjs/integrations/tracing/redis.js.map +0 -1
- package/build/esm/integrations/tracing/redis.js.map +0 -1
- package/build/types/integrations/tracing/redis.d.ts.map +0 -1
package/build/cjs/index.js
CHANGED
|
@@ -12,7 +12,7 @@ const mongo = require('./integrations/tracing/mongo.js');
|
|
|
12
12
|
const mongoose = require('./integrations/tracing/mongoose.js');
|
|
13
13
|
const mysql = require('./integrations/tracing/mysql.js');
|
|
14
14
|
const mysql2 = require('./integrations/tracing/mysql2.js');
|
|
15
|
-
const
|
|
15
|
+
const index$b = require('./integrations/tracing/redis/index.js');
|
|
16
16
|
const postgres = require('./integrations/tracing/postgres.js');
|
|
17
17
|
const postgresjs = require('./integrations/tracing/postgresjs.js');
|
|
18
18
|
const prisma = require('./integrations/tracing/prisma.js');
|
|
@@ -25,7 +25,7 @@ const tedious = require('./integrations/tracing/tedious.js');
|
|
|
25
25
|
const genericPool = require('./integrations/tracing/genericPool.js');
|
|
26
26
|
const dataloader = require('./integrations/tracing/dataloader.js');
|
|
27
27
|
const amqplib = require('./integrations/tracing/amqplib.js');
|
|
28
|
-
const index$
|
|
28
|
+
const index$c = require('./integrations/tracing/vercelai/index.js');
|
|
29
29
|
const index$a = require('./integrations/tracing/openai/index.js');
|
|
30
30
|
const index = require('./integrations/tracing/anthropic-ai/index.js');
|
|
31
31
|
const index$4 = require('./integrations/tracing/google-genai/index.js');
|
|
@@ -60,7 +60,7 @@ exports.mongoIntegration = mongo.mongoIntegration;
|
|
|
60
60
|
exports.mongooseIntegration = mongoose.mongooseIntegration;
|
|
61
61
|
exports.mysqlIntegration = mysql.mysqlIntegration;
|
|
62
62
|
exports.mysql2Integration = mysql2.mysql2Integration;
|
|
63
|
-
exports.redisIntegration =
|
|
63
|
+
exports.redisIntegration = index$b.redisIntegration;
|
|
64
64
|
exports.postgresIntegration = postgres.postgresIntegration;
|
|
65
65
|
exports.postgresJsIntegration = postgresjs.postgresJsIntegration;
|
|
66
66
|
exports.prismaIntegration = prisma.prismaIntegration;
|
|
@@ -77,7 +77,7 @@ exports.tediousIntegration = tedious.tediousIntegration;
|
|
|
77
77
|
exports.genericPoolIntegration = genericPool.genericPoolIntegration;
|
|
78
78
|
exports.dataloaderIntegration = dataloader.dataloaderIntegration;
|
|
79
79
|
exports.amqplibIntegration = amqplib.amqplibIntegration;
|
|
80
|
-
exports.vercelAIIntegration = index$
|
|
80
|
+
exports.vercelAIIntegration = index$c.vercelAIIntegration;
|
|
81
81
|
exports.openAIIntegration = index$a.openAIIntegration;
|
|
82
82
|
exports.anthropicAIIntegration = index.anthropicAIIntegration;
|
|
83
83
|
exports.googleGenAIIntegration = index$4.googleGenAIIntegration;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const api = require('@opentelemetry/api');
|
|
4
|
-
const instrumentationHttp = require('@opentelemetry/instrumentation-http');
|
|
5
3
|
const core = require('@sentry/core');
|
|
6
4
|
const nodeCore = require('@sentry/node-core');
|
|
7
5
|
|
|
8
6
|
const INTEGRATION_NAME = 'Http';
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// The `http.client.request.created` diagnostics channel, needed for trace propagation,
|
|
13
|
-
// was added in Node 22.12.0 (backported from 23.2.0). Earlier 22.x versions don't have it.
|
|
14
|
-
const FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL =
|
|
15
|
-
(nodeCore.NODE_VERSION.major === 22 && nodeCore.NODE_VERSION.minor >= 12) ||
|
|
16
|
-
(nodeCore.NODE_VERSION.major === 23 && nodeCore.NODE_VERSION.minor >= 2) ||
|
|
17
|
-
nodeCore.NODE_VERSION.major >= 24;
|
|
8
|
+
// TODO(v11): Consolidate all the various HTTP integration options into one,
|
|
9
|
+
// and deprecate the duplicated and aliased options.
|
|
18
10
|
|
|
19
11
|
const instrumentSentryHttp = nodeCore.generateInstrumentOnce(
|
|
20
12
|
`${INTEGRATION_NAME}.sentry`,
|
|
@@ -23,65 +15,6 @@ const instrumentSentryHttp = nodeCore.generateInstrumentOnce(
|
|
|
23
15
|
},
|
|
24
16
|
);
|
|
25
17
|
|
|
26
|
-
const instrumentOtelHttp = nodeCore.generateInstrumentOnce(INTEGRATION_NAME, config => {
|
|
27
|
-
const instrumentation = new instrumentationHttp.HttpInstrumentation({
|
|
28
|
-
...config,
|
|
29
|
-
// This is hard-coded and can never be overridden by the user
|
|
30
|
-
disableIncomingRequestInstrumentation: true,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// We want to update the logger namespace so we can better identify what is happening here
|
|
34
|
-
try {
|
|
35
|
-
instrumentation['_diag'] = api.diag.createComponentLogger({
|
|
36
|
-
namespace: INSTRUMENTATION_NAME,
|
|
37
|
-
});
|
|
38
|
-
// @ts-expect-error We are writing a read-only property here...
|
|
39
|
-
instrumentation.instrumentationName = INSTRUMENTATION_NAME;
|
|
40
|
-
} catch {
|
|
41
|
-
// ignore errors here...
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// The OTel HttpInstrumentation (>=0.213.0) has a guard (`_httpPatched`/`_httpsPatched`)
|
|
45
|
-
// that prevents patching `http`/`https` when loaded by both CJS `require()` and ESM `import`.
|
|
46
|
-
// In environments like AWS Lambda, the runtime loads `http` via CJS first (for the Runtime API),
|
|
47
|
-
// and then the user's ESM handler imports `node:http`. The guard blocks ESM patching after CJS,
|
|
48
|
-
// which breaks HTTP spans for ESM handlers. We disable this guard to allow both to be patched.
|
|
49
|
-
// TODO(andrei): Remove once https://github.com/open-telemetry/opentelemetry-js/issues/6489 is fixed.
|
|
50
|
-
try {
|
|
51
|
-
const noopDescriptor = { get: () => false, set: () => {} };
|
|
52
|
-
Object.defineProperty(instrumentation, '_httpPatched', noopDescriptor);
|
|
53
|
-
Object.defineProperty(instrumentation, '_httpsPatched', noopDescriptor);
|
|
54
|
-
} catch {
|
|
55
|
-
// ignore errors here...
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return instrumentation;
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
/** Exported only for tests. */
|
|
62
|
-
function _shouldUseOtelHttpInstrumentation(
|
|
63
|
-
options,
|
|
64
|
-
clientOptions = {},
|
|
65
|
-
) {
|
|
66
|
-
// If `spans` is passed in, it takes precedence
|
|
67
|
-
// Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true` or spans are not enabled
|
|
68
|
-
if (typeof options.spans === 'boolean') {
|
|
69
|
-
return options.spans;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (clientOptions.skipOpenTelemetrySetup) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// IMPORTANT: We only disable span instrumentation when spans are not enabled _and_ we are on a Node version
|
|
77
|
-
// that fully supports the necessary diagnostics channels for trace propagation
|
|
78
|
-
if (!core.hasSpansEnabled(clientOptions) && FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
18
|
/**
|
|
86
19
|
* The http integration instruments Node's internal http and https modules.
|
|
87
20
|
* It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.
|
|
@@ -89,6 +22,7 @@ function _shouldUseOtelHttpInstrumentation(
|
|
|
89
22
|
const httpIntegration = core.defineIntegration((options = {}) => {
|
|
90
23
|
const spans = options.spans ?? true;
|
|
91
24
|
const disableIncomingRequestSpans = options.disableIncomingRequestSpans;
|
|
25
|
+
const enableServerSpans = spans && !disableIncomingRequestSpans;
|
|
92
26
|
|
|
93
27
|
const serverOptions = {
|
|
94
28
|
sessions: options.trackIncomingRequestsAsSessions,
|
|
@@ -103,13 +37,11 @@ const httpIntegration = core.defineIntegration((options = {}) => {
|
|
|
103
37
|
ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes,
|
|
104
38
|
instrumentation: options.instrumentation,
|
|
105
39
|
onSpanCreated: options.incomingRequestSpanHook,
|
|
106
|
-
}
|
|
40
|
+
};
|
|
107
41
|
|
|
108
42
|
const server = nodeCore.httpServerIntegration(serverOptions);
|
|
109
43
|
const serverSpans = nodeCore.httpServerSpansIntegration(serverSpansOptions);
|
|
110
44
|
|
|
111
|
-
const enableServerSpans = spans && !disableIncomingRequestSpans;
|
|
112
|
-
|
|
113
45
|
return {
|
|
114
46
|
name: INTEGRATION_NAME,
|
|
115
47
|
setup(client) {
|
|
@@ -120,105 +52,46 @@ const httpIntegration = core.defineIntegration((options = {}) => {
|
|
|
120
52
|
}
|
|
121
53
|
},
|
|
122
54
|
setupOnce() {
|
|
123
|
-
const clientOptions = (core.getClient()?.getOptions() || {}) ;
|
|
124
|
-
const useOtelHttpInstrumentation = _shouldUseOtelHttpInstrumentation(options, clientOptions);
|
|
125
|
-
|
|
126
55
|
server.setupOnce();
|
|
127
56
|
|
|
128
57
|
const sentryHttpInstrumentationOptions = {
|
|
129
58
|
breadcrumbs: options.breadcrumbs,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
: FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL || !useOtelHttpInstrumentation,
|
|
134
|
-
createSpansForOutgoingRequests: FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL,
|
|
135
|
-
spans: options.spans,
|
|
59
|
+
spans,
|
|
60
|
+
propagateTraceInOutgoingRequests: options.tracePropagation ?? true,
|
|
61
|
+
createSpansForOutgoingRequests: spans,
|
|
136
62
|
ignoreOutgoingRequests: options.ignoreOutgoingRequests,
|
|
137
63
|
outgoingRequestHook: (span, request) => {
|
|
138
64
|
// Sanitize data URLs to prevent long base64 strings in span attributes
|
|
139
|
-
const url =
|
|
65
|
+
const url = core.getRequestUrlFromClientRequest(request);
|
|
140
66
|
if (url.startsWith('data:')) {
|
|
141
67
|
const sanitizedUrl = core.stripDataUrlContent(url);
|
|
68
|
+
// TODO(v11): Update these to the Sentry semantic attributes.
|
|
69
|
+
// https://getsentry.github.io/sentry-conventions/attributes/
|
|
142
70
|
span.setAttribute('http.url', sanitizedUrl);
|
|
143
71
|
span.setAttribute(core.SEMANTIC_ATTRIBUTE_URL_FULL, sanitizedUrl);
|
|
144
72
|
span.updateName(`${request.method || 'GET'} ${sanitizedUrl}`);
|
|
145
73
|
}
|
|
146
|
-
|
|
147
74
|
options.instrumentation?.requestHook?.(span, request);
|
|
148
75
|
},
|
|
149
76
|
outgoingResponseHook: options.instrumentation?.responseHook,
|
|
150
77
|
outgoingRequestApplyCustomAttributes: options.instrumentation?.applyCustomAttributesOnSpan,
|
|
151
|
-
}
|
|
78
|
+
};
|
|
152
79
|
|
|
153
|
-
// This is Sentry-specific instrumentation for outgoing request
|
|
80
|
+
// This is Sentry-specific instrumentation for outgoing request
|
|
81
|
+
// breadcrumbs & trace propagation. It uses the diagnostic channels on
|
|
82
|
+
// node versions that support it, falling back to monkey-patching when
|
|
83
|
+
// needed.
|
|
154
84
|
instrumentSentryHttp(sentryHttpInstrumentationOptions);
|
|
155
|
-
|
|
156
|
-
// This is the "regular" OTEL instrumentation that emits outgoing request spans
|
|
157
|
-
if (useOtelHttpInstrumentation) {
|
|
158
|
-
const instrumentationConfig = getConfigWithDefaults(options);
|
|
159
|
-
instrumentOtelHttp(instrumentationConfig);
|
|
160
|
-
}
|
|
161
85
|
},
|
|
162
86
|
processEvent(event) {
|
|
163
|
-
//
|
|
164
|
-
// The reason being that e.g. the remix integration disables span
|
|
87
|
+
// Always run this, even if spans are disabled
|
|
88
|
+
// The reason being that e.g. the remix integration disables span
|
|
89
|
+
// creation here but still wants to use the ignore status codes option
|
|
165
90
|
return serverSpans.processEvent(event);
|
|
166
91
|
},
|
|
167
92
|
};
|
|
168
93
|
});
|
|
169
94
|
|
|
170
|
-
function getConfigWithDefaults(options = {}) {
|
|
171
|
-
const instrumentationConfig = {
|
|
172
|
-
// This is handled by the SentryHttpInstrumentation on Node 22+
|
|
173
|
-
disableOutgoingRequestInstrumentation: FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL,
|
|
174
|
-
|
|
175
|
-
ignoreOutgoingRequestHook: request => {
|
|
176
|
-
const url = nodeCore.getRequestUrl(request);
|
|
177
|
-
|
|
178
|
-
if (!url) {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;
|
|
183
|
-
if (_ignoreOutgoingRequests?.(url, request)) {
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return false;
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
requireParentforOutgoingSpans: false,
|
|
191
|
-
requestHook: (span, req) => {
|
|
192
|
-
nodeCore.addOriginToSpan(span, 'auto.http.otel.http');
|
|
193
|
-
|
|
194
|
-
// Sanitize data URLs to prevent long base64 strings in span attributes
|
|
195
|
-
const url = nodeCore.getRequestUrl(req );
|
|
196
|
-
if (url.startsWith('data:')) {
|
|
197
|
-
const sanitizedUrl = core.stripDataUrlContent(url);
|
|
198
|
-
span.setAttribute('http.url', sanitizedUrl);
|
|
199
|
-
span.setAttribute(core.SEMANTIC_ATTRIBUTE_URL_FULL, sanitizedUrl);
|
|
200
|
-
span.updateName(`${(req ).method || 'GET'} ${sanitizedUrl}`);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
options.instrumentation?.requestHook?.(span, req);
|
|
204
|
-
},
|
|
205
|
-
responseHook: (span, res) => {
|
|
206
|
-
options.instrumentation?.responseHook?.(span, res);
|
|
207
|
-
},
|
|
208
|
-
applyCustomAttributesOnSpan: (
|
|
209
|
-
span,
|
|
210
|
-
request,
|
|
211
|
-
response,
|
|
212
|
-
) => {
|
|
213
|
-
options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);
|
|
214
|
-
},
|
|
215
|
-
} ;
|
|
216
|
-
|
|
217
|
-
return instrumentationConfig;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
exports._shouldUseOtelHttpInstrumentation = _shouldUseOtelHttpInstrumentation;
|
|
221
95
|
exports.httpIntegration = httpIntegration;
|
|
222
|
-
exports.instrumentOtelHttp = instrumentOtelHttp;
|
|
223
96
|
exports.instrumentSentryHttp = instrumentSentryHttp;
|
|
224
97
|
//# sourceMappingURL=http.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sources":["../../../src/integrations/http.ts"],"sourcesContent":["import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';\nimport { diag } from '@opentelemetry/api';\nimport type { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport type { Span } from '@sentry/core';\nimport {\n defineIntegration,\n getClient,\n hasSpansEnabled,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n stripDataUrlContent,\n} from '@sentry/core';\nimport type { HTTPModuleRequestIncomingMessage, NodeClient, SentryHttpInstrumentationOptions } from '@sentry/node-core';\nimport {\n addOriginToSpan,\n generateInstrumentOnce,\n getRequestUrl,\n httpServerIntegration,\n httpServerSpansIntegration,\n NODE_VERSION,\n SentryHttpInstrumentation,\n} from '@sentry/node-core';\nimport type { NodeClientOptions } from '../types';\n\nconst INTEGRATION_NAME = 'Http';\n\nconst INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';\n\n// The `http.client.request.created` diagnostics channel, needed for trace propagation,\n// was added in Node 22.12.0 (backported from 23.2.0). Earlier 22.x versions don't have it.\nconst FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL =\n (NODE_VERSION.major === 22 && NODE_VERSION.minor >= 12) ||\n (NODE_VERSION.major === 23 && NODE_VERSION.minor >= 2) ||\n NODE_VERSION.major >= 24;\n\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * 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.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Whether to inject trace propagation headers (sentry-trace, baggage, traceparent) into outgoing HTTP requests.\n *\n * When set to `false`, Sentry will not inject any trace propagation headers, but will still create breadcrumbs\n * (if `breadcrumbs` is enabled). This is useful when `skipOpenTelemetrySetup: true` is configured and you want\n * to avoid duplicate trace headers being injected by both Sentry and OpenTelemetry's HttpInstrumentation.\n *\n * @default `true`\n */\n tracePropagation?: boolean;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP 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 * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;\n\n /**\n * A hook that can be used to mutate the span for incoming requests.\n * This is triggered after the span is created, but before it is recorded.\n */\n incomingRequestSpanHook?: (span: Span, request: IncomingMessage, response: ServerResponse) => void;\n\n /**\n * Whether to automatically ignore common static asset requests like favicon.ico, robots.txt, etc.\n * This helps reduce noise in your transactions.\n *\n * @default `true`\n */\n ignoreStaticAssets?: boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests with the given status codes.\n * By default, spans with some 3xx and 4xx status codes are ignored (see @default).\n * Expects an array of status codes or a range of status codes, e.g. [[300,399], 404] would ignore 3xx and 404 status codes.\n *\n * @default `[[401, 404], [301, 303], [305, 399]]`\n */\n dropSpansForIncomingRequestStatusCodes?: (number | [number, number])[];\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed and we want to avoid capturing it.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the incoming request.\n * @param request Contains the {@type RequestOptions} object used to make the incoming request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Controls the maximum size of incoming HTTP request bodies attached to events.\n *\n * Available options:\n * - 'none': No request bodies will be attached\n * - 'small': Request bodies up to 1,000 bytes will be attached\n * - 'medium': Request bodies up to 10,000 bytes will be attached (default)\n * - 'always': Request bodies will always be attached\n *\n * Note that even with 'always' setting, bodies exceeding 1MB will never be attached\n * for performance and security reasons.\n *\n * @default 'medium'\n */\n maxIncomingRequestBodySize?: 'none' | 'small' | 'medium' | 'always';\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;\n responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => void;\n };\n}\n\nexport const instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(\n `${INTEGRATION_NAME}.sentry`,\n options => {\n return new SentryHttpInstrumentation(options);\n },\n);\n\nexport const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConfig>(INTEGRATION_NAME, config => {\n const instrumentation = new HttpInstrumentation({\n ...config,\n // This is hard-coded and can never be overridden by the user\n disableIncomingRequestInstrumentation: true,\n });\n\n // We want to update the logger namespace so we can better identify what is happening here\n try {\n instrumentation['_diag'] = diag.createComponentLogger({\n namespace: INSTRUMENTATION_NAME,\n });\n // @ts-expect-error We are writing a read-only property here...\n instrumentation.instrumentationName = INSTRUMENTATION_NAME;\n } catch {\n // ignore errors here...\n }\n\n // The OTel HttpInstrumentation (>=0.213.0) has a guard (`_httpPatched`/`_httpsPatched`)\n // that prevents patching `http`/`https` when loaded by both CJS `require()` and ESM `import`.\n // In environments like AWS Lambda, the runtime loads `http` via CJS first (for the Runtime API),\n // and then the user's ESM handler imports `node:http`. The guard blocks ESM patching after CJS,\n // which breaks HTTP spans for ESM handlers. We disable this guard to allow both to be patched.\n // TODO(andrei): Remove once https://github.com/open-telemetry/opentelemetry-js/issues/6489 is fixed.\n try {\n const noopDescriptor = { get: () => false, set: () => {} };\n Object.defineProperty(instrumentation, '_httpPatched', noopDescriptor);\n Object.defineProperty(instrumentation, '_httpsPatched', noopDescriptor);\n } catch {\n // ignore errors here...\n }\n\n return instrumentation;\n});\n\n/** Exported only for tests. */\nexport function _shouldUseOtelHttpInstrumentation(\n options: HttpOptions,\n clientOptions: Partial<NodeClientOptions> = {},\n): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true` or spans are not enabled\n if (typeof options.spans === 'boolean') {\n return options.spans;\n }\n\n if (clientOptions.skipOpenTelemetrySetup) {\n return false;\n }\n\n // IMPORTANT: We only disable span instrumentation when spans are not enabled _and_ we are on a Node version\n // that fully supports the necessary diagnostics channels for trace propagation\n if (!hasSpansEnabled(clientOptions) && FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL) {\n return false;\n }\n\n return true;\n}\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n const spans = options.spans ?? true;\n const disableIncomingRequestSpans = options.disableIncomingRequestSpans;\n\n const serverOptions = {\n sessions: options.trackIncomingRequestsAsSessions,\n sessionFlushingDelayMS: options.sessionFlushingDelayMS,\n ignoreRequestBody: options.ignoreIncomingRequestBody,\n maxRequestBodySize: options.maxIncomingRequestBodySize,\n } satisfies Parameters<typeof httpServerIntegration>[0];\n\n const serverSpansOptions = {\n ignoreIncomingRequests: options.ignoreIncomingRequests,\n ignoreStaticAssets: options.ignoreStaticAssets,\n ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes,\n instrumentation: options.instrumentation,\n onSpanCreated: options.incomingRequestSpanHook,\n } satisfies Parameters<typeof httpServerSpansIntegration>[0];\n\n const server = httpServerIntegration(serverOptions);\n const serverSpans = httpServerSpansIntegration(serverSpansOptions);\n\n const enableServerSpans = spans && !disableIncomingRequestSpans;\n\n return {\n name: INTEGRATION_NAME,\n setup(client: NodeClient) {\n const clientOptions = client.getOptions();\n\n if (enableServerSpans && hasSpansEnabled(clientOptions)) {\n serverSpans.setup(client);\n }\n },\n setupOnce() {\n const clientOptions = (getClient<NodeClient>()?.getOptions() || {}) satisfies Partial<NodeClientOptions>;\n const useOtelHttpInstrumentation = _shouldUseOtelHttpInstrumentation(options, clientOptions);\n\n server.setupOnce();\n\n const sentryHttpInstrumentationOptions = {\n breadcrumbs: options.breadcrumbs,\n propagateTraceInOutgoingRequests:\n typeof options.tracePropagation === 'boolean'\n ? options.tracePropagation\n : FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL || !useOtelHttpInstrumentation,\n createSpansForOutgoingRequests: FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL,\n spans: options.spans,\n ignoreOutgoingRequests: options.ignoreOutgoingRequests,\n outgoingRequestHook: (span: Span, request: ClientRequest) => {\n // Sanitize data URLs to prevent long base64 strings in span attributes\n const url = getRequestUrl(request);\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n span.setAttribute('http.url', sanitizedUrl);\n span.setAttribute(SEMANTIC_ATTRIBUTE_URL_FULL, sanitizedUrl);\n span.updateName(`${request.method || 'GET'} ${sanitizedUrl}`);\n }\n\n options.instrumentation?.requestHook?.(span, request);\n },\n outgoingResponseHook: options.instrumentation?.responseHook,\n outgoingRequestApplyCustomAttributes: options.instrumentation?.applyCustomAttributesOnSpan,\n } satisfies SentryHttpInstrumentationOptions;\n\n // This is Sentry-specific instrumentation for outgoing request breadcrumbs & trace propagation\n instrumentSentryHttp(sentryHttpInstrumentationOptions);\n\n // This is the \"regular\" OTEL instrumentation that emits outgoing request spans\n if (useOtelHttpInstrumentation) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n },\n processEvent(event) {\n // Note: We always run this, even if spans are disabled\n // The reason being that e.g. the remix integration disables span creation here but still wants to use the ignore status codes option\n return serverSpans.processEvent(event);\n },\n };\n});\n\nfunction getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrumentationConfig {\n const instrumentationConfig = {\n // This is handled by the SentryHttpInstrumentation on Node 22+\n disableOutgoingRequestInstrumentation: FULLY_SUPPORTS_HTTP_DIAGNOSTICS_CHANNEL,\n\n ignoreOutgoingRequestHook: request => {\n const url = getRequestUrl(request);\n\n if (!url) {\n return false;\n }\n\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n if (_ignoreOutgoingRequests?.(url, request)) {\n return true;\n }\n\n return false;\n },\n\n requireParentforOutgoingSpans: false,\n requestHook: (span, req) => {\n addOriginToSpan(span, 'auto.http.otel.http');\n\n // Sanitize data URLs to prevent long base64 strings in span attributes\n const url = getRequestUrl(req as ClientRequest);\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n span.setAttribute('http.url', sanitizedUrl);\n span.setAttribute(SEMANTIC_ATTRIBUTE_URL_FULL, sanitizedUrl);\n span.updateName(`${(req as ClientRequest).method || 'GET'} ${sanitizedUrl}`);\n }\n\n options.instrumentation?.requestHook?.(span, req);\n },\n responseHook: (span, res) => {\n options.instrumentation?.responseHook?.(span, res);\n },\n applyCustomAttributesOnSpan: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => {\n options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);\n },\n } satisfies HttpInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":["NODE_VERSION","generateInstrumentOnce","SentryHttpInstrumentation","HttpInstrumentation","diag","hasSpansEnabled","defineIntegration","httpServerIntegration","httpServerSpansIntegration","getClient","getRequestUrl","stripDataUrlContent","SEMANTIC_ATTRIBUTE_URL_FULL","addOriginToSpan"],"mappings":";;;;;;;AAwBA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B,MAAM,oBAAA,GAAuB,oDAAoD;;AAEjF;AACA;AACA,MAAM,uCAAA;AACN,EAAE,CAACA,qBAAY,CAAC,KAAA,KAAU,EAAA,IAAMA,qBAAY,CAAC,KAAA,IAAS,EAAE;AACxD,GAAGA,qBAAY,CAAC,KAAA,KAAU,EAAA,IAAMA,qBAAY,CAAC,KAAA,IAAS,CAAC,CAAA;AACvD,EAAEA,qBAAY,CAAC,KAAA,IAAS,EAAE;;AAwInB,MAAM,oBAAA,GAAuBC,+BAAsB;AAC1D,EAAE,CAAC,EAAA,gBAAA,CAAA,OAAA,CAAA;AACA,EAAA,OAAA,IAAA;AACA,IAAA,OAAA,IAAAC,kCAAA,CAAA,OAAA,CAAA;AACA,EAAA,CAAA;AACA;;AAEA,MAAA,kBAAA,GAAAD,+BAAA,CAAA,gBAAA,EAAA,MAAA,IAAA;AACA,EAAA,MAAA,eAAA,GAAA,IAAAE,uCAAA,CAAA;AACA,IAAA,GAAA,MAAA;AACA;AACA,IAAA,qCAAA,EAAA,IAAA;AACA,GAAA,CAAA;;AAEA;AACA,EAAA,IAAA;AACA,IAAA,eAAA,CAAA,OAAA,CAAA,GAAAC,QAAA,CAAA,qBAAA,CAAA;AACA,MAAA,SAAA,EAAA,oBAAA;AACA,KAAA,C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A,EAAA,2BAAA,GAAA,IAAA,EAAA,OAAA,EAAA,QAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;;AAEA,EAAA,OAAA,qBAAA;AACA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"http.js","sources":["../../../src/integrations/http.ts"],"sourcesContent":["import type { RequestOptions } from 'node:http';\nimport type { HttpClientRequest, HttpIncomingMessage, HttpServerResponse, Span } from '@sentry/core';\nimport {\n defineIntegration,\n hasSpansEnabled,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n stripDataUrlContent,\n getRequestUrlFromClientRequest,\n} from '@sentry/core';\nimport type {\n NodeClient,\n SentryHttpInstrumentationOptions,\n HttpServerIntegrationOptions,\n HttpServerSpansIntegrationOptions,\n} from '@sentry/node-core';\nimport {\n generateInstrumentOnce,\n httpServerIntegration,\n httpServerSpansIntegration,\n SentryHttpInstrumentation,\n} from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Http';\n\n// TODO(v11): Consolidate all the various HTTP integration options into one,\n// and deprecate the duplicated and aliased options.\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * 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.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Whether to inject trace propagation headers (sentry-trace, baggage, traceparent) into outgoing HTTP requests.\n *\n * When set to `false`, Sentry will not inject any trace propagation headers, but will still create breadcrumbs\n * (if `breadcrumbs` is enabled). This is useful when `skipOpenTelemetrySetup: true` is configured and you want\n * to avoid duplicate trace headers being injected by both Sentry and OpenTelemetry's HttpInstrumentation.\n *\n * @default `true`\n */\n tracePropagation?: boolean;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP 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 * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: HttpIncomingMessage) => boolean;\n\n /**\n * A hook that can be used to mutate the span for incoming requests.\n * This is triggered after the span is created, but before it is recorded.\n */\n incomingRequestSpanHook?: (span: Span, request: HttpIncomingMessage, response: HttpServerResponse) => void;\n\n /**\n * Whether to automatically ignore common static asset requests like favicon.ico, robots.txt, etc.\n * This helps reduce noise in your transactions.\n *\n * @default `true`\n */\n ignoreStaticAssets?: boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests with the given status codes.\n * By default, spans with some 3xx and 4xx status codes are ignored (see @default).\n * Expects an array of status codes or a range of status codes, e.g. [[300,399], 404] would ignore 3xx and 404 status codes.\n *\n * @default `[[401, 404], [301, 303], [305, 399]]`\n */\n dropSpansForIncomingRequestStatusCodes?: (number | [number, number])[];\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed and we want to avoid capturing it.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the incoming request.\n * @param request Contains the {@type RequestOptions} object used to make the incoming request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Controls the maximum size of incoming HTTP request bodies attached to events.\n *\n * Available options:\n * - 'none': No request bodies will be attached\n * - 'small': Request bodies up to 1,000 bytes will be attached\n * - 'medium': Request bodies up to 10,000 bytes will be attached (default)\n * - 'always': Request bodies will always be attached\n *\n * Note that even with 'always' setting, bodies exceeding 1MB will never be attached\n * for performance and security reasons.\n *\n * @default 'medium'\n */\n maxIncomingRequestBodySize?: 'none' | 'small' | 'medium' | 'always';\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: HttpIncomingMessage | HttpClientRequest) => void;\n responseHook?: (span: Span, response: HttpIncomingMessage | HttpServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: HttpIncomingMessage | HttpClientRequest,\n response: HttpIncomingMessage | HttpServerResponse,\n ) => void;\n };\n}\n\nexport const instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(\n `${INTEGRATION_NAME}.sentry`,\n options => {\n return new SentryHttpInstrumentation(options);\n },\n);\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n const spans = options.spans ?? true;\n const disableIncomingRequestSpans = options.disableIncomingRequestSpans;\n const enableServerSpans = spans && !disableIncomingRequestSpans;\n\n const serverOptions = {\n sessions: options.trackIncomingRequestsAsSessions,\n sessionFlushingDelayMS: options.sessionFlushingDelayMS,\n ignoreRequestBody: options.ignoreIncomingRequestBody,\n maxRequestBodySize: options.maxIncomingRequestBodySize,\n } satisfies HttpServerIntegrationOptions;\n\n const serverSpansOptions: HttpServerSpansIntegrationOptions = {\n ignoreIncomingRequests: options.ignoreIncomingRequests,\n ignoreStaticAssets: options.ignoreStaticAssets,\n ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes,\n instrumentation: options.instrumentation,\n onSpanCreated: options.incomingRequestSpanHook,\n };\n\n const server = httpServerIntegration(serverOptions);\n const serverSpans = httpServerSpansIntegration(serverSpansOptions);\n\n return {\n name: INTEGRATION_NAME,\n setup(client: NodeClient) {\n const clientOptions = client.getOptions();\n\n if (enableServerSpans && hasSpansEnabled(clientOptions)) {\n serverSpans.setup(client);\n }\n },\n setupOnce() {\n server.setupOnce();\n\n const sentryHttpInstrumentationOptions: SentryHttpInstrumentationOptions = {\n breadcrumbs: options.breadcrumbs,\n spans,\n propagateTraceInOutgoingRequests: options.tracePropagation ?? true,\n createSpansForOutgoingRequests: spans,\n ignoreOutgoingRequests: options.ignoreOutgoingRequests,\n outgoingRequestHook: (span: Span, request: HttpClientRequest) => {\n // Sanitize data URLs to prevent long base64 strings in span attributes\n const url = getRequestUrlFromClientRequest(request);\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n // TODO(v11): Update these to the Sentry semantic attributes.\n // https://getsentry.github.io/sentry-conventions/attributes/\n span.setAttribute('http.url', sanitizedUrl);\n span.setAttribute(SEMANTIC_ATTRIBUTE_URL_FULL, sanitizedUrl);\n span.updateName(`${request.method || 'GET'} ${sanitizedUrl}`);\n }\n options.instrumentation?.requestHook?.(span, request);\n },\n outgoingResponseHook: options.instrumentation?.responseHook,\n outgoingRequestApplyCustomAttributes: options.instrumentation?.applyCustomAttributesOnSpan,\n };\n\n // This is Sentry-specific instrumentation for outgoing request\n // breadcrumbs & trace propagation. It uses the diagnostic channels on\n // node versions that support it, falling back to monkey-patching when\n // needed.\n instrumentSentryHttp(sentryHttpInstrumentationOptions);\n },\n processEvent(event) {\n // Always run this, even if spans are disabled\n // The reason being that e.g. the remix integration disables span\n // creation here but still wants to use the ignore status codes option\n return serverSpans.processEvent(event);\n },\n };\n});\n"],"names":["generateInstrumentOnce","SentryHttpInstrumentation","defineIntegration","httpServerIntegration","httpServerSpansIntegration","hasSpansEnabled","getRequestUrlFromClientRequest","stripDataUrlContent","SEMANTIC_ATTRIBUTE_URL_FULL"],"mappings":";;;;;AAsBA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B;AACA;;AAuIO,MAAM,oBAAA,GAAuBA,+BAAsB;AAC1D,EAAE,CAAC,EAAA,gBAAA,CAAA,OAAA,CAAA;AACA,EAAA,OAAA,IAAA;AACA,IAAA,OAAA,IAAAC,kCAAA,CAAA,OAAA,CAAA;AACA,EAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAA,eAAA,GAAAC,sBAAA,CAAA,CAAA,OAAA,GAAA,EAAA,KAAA;AACA,EAAA,MAAA,KAAA,GAAA,OAAA,CAAA,KAAA,IAAA,IAAA;AACA,EAAA,MAAA,2BAAA,GAAA,OAAA,CAAA,2BAAA;AACA,EAAA,MAAA,iBAAA,GAAA,KAAA,IAAA,CAAA,2BAAA;;AAEA,EAAA,MAAA,aAAA,GAAA;AACA,IAAA,QAAA,EAAA,OAAA,CAAA,+BAAA;AACA,IAAA,sBAAA,EAAA,OAAA,CAAA,sBAAA;AACA,IAAA,iBAAA,EAAA,OAAA,CAAA,yBAAA;AACA,IAAA,kBAAA,EAAA,OAAA,CAAA,0BAAA;AACA,GAAA;;AAEA,EAAA,MAAA,kBAAA,GAAA;AACA,IAAA,sBAAA,EAAA,OAAA,CAAA,sBAAA;AACA,IAAA,kBAAA,EAAA,OAAA,CAAA,kBAAA;AACA,IAAA,iBAAA,EAAA,OAAA,CAAA,sCAAA;AACA,IAAA,eAAA,EAAA,OAAA,CAAA,eAAA;AACA,I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EAAA,WAAA,GAAA,IAAA,EAAA,OAAA,CAAA;AACA,QAAA,CAAA;AACA,QAAA,oBAAA,EAAA,OAAA,CAAA,eAAA,EAAA,YAAA;AACA,QAAA,oCAAA,EAAA,OAAA,CAAA,eAAA,EAAA,2BAAA;AACA,OAAA;;AAEA;AACA;AACA;AACA;AACA,MAAA,oBAAA,CAAA,gCAAA,CAAA;AACA,IAAA,CAAA;AACA,IAAA,YAAA,CAAA,KAAA,EAAA;AACA;AACA;AACA;AACA,MAAA,OAAA,WAAA,CAAA,YAAA,CAAA,KAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA;;;;;"}
|
|
@@ -2,32 +2,32 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const http = require('../http.js');
|
|
4
4
|
const amqplib = require('./amqplib.js');
|
|
5
|
-
const index$
|
|
5
|
+
const index$7 = require('./anthropic-ai/index.js');
|
|
6
6
|
const connect = require('./connect.js');
|
|
7
7
|
const express = require('./express.js');
|
|
8
8
|
const index = require('./fastify/index.js');
|
|
9
9
|
const firebase = require('./firebase/firebase.js');
|
|
10
10
|
const genericPool = require('./genericPool.js');
|
|
11
|
-
const index$
|
|
11
|
+
const index$8 = require('./google-genai/index.js');
|
|
12
12
|
const graphql = require('./graphql.js');
|
|
13
13
|
const index$1 = require('./hapi/index.js');
|
|
14
14
|
const index$2 = require('./hono/index.js');
|
|
15
15
|
const kafka = require('./kafka.js');
|
|
16
16
|
const koa = require('./koa.js');
|
|
17
|
-
const index$
|
|
18
|
-
const index$
|
|
17
|
+
const index$4 = require('./langchain/index.js');
|
|
18
|
+
const index$9 = require('./langgraph/index.js');
|
|
19
19
|
const lrumemoizer = require('./lrumemoizer.js');
|
|
20
20
|
const mongo = require('./mongo.js');
|
|
21
21
|
const mongoose = require('./mongoose.js');
|
|
22
22
|
const mysql = require('./mysql.js');
|
|
23
23
|
const mysql2 = require('./mysql2.js');
|
|
24
|
-
const index$
|
|
24
|
+
const index$6 = require('./openai/index.js');
|
|
25
25
|
const postgres = require('./postgres.js');
|
|
26
26
|
const postgresjs = require('./postgresjs.js');
|
|
27
27
|
const prisma = require('./prisma.js');
|
|
28
|
-
const
|
|
28
|
+
const index$3 = require('./redis/index.js');
|
|
29
29
|
const tedious = require('./tedious.js');
|
|
30
|
-
const index$
|
|
30
|
+
const index$5 = require('./vercelai/index.js');
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.
|
|
@@ -42,7 +42,7 @@ function getAutoPerformanceIntegrations() {
|
|
|
42
42
|
mongoose.mongooseIntegration(),
|
|
43
43
|
mysql.mysqlIntegration(),
|
|
44
44
|
mysql2.mysql2Integration(),
|
|
45
|
-
|
|
45
|
+
index$3.redisIntegration(),
|
|
46
46
|
postgres.postgresIntegration(),
|
|
47
47
|
prisma.prismaIntegration(),
|
|
48
48
|
index$1.hapiIntegration(),
|
|
@@ -55,12 +55,12 @@ function getAutoPerformanceIntegrations() {
|
|
|
55
55
|
lrumemoizer.lruMemoizerIntegration(),
|
|
56
56
|
// AI providers
|
|
57
57
|
// LangChain must come first to disable AI provider integrations before they instrument
|
|
58
|
-
index$
|
|
59
|
-
index$
|
|
60
|
-
index$
|
|
61
|
-
index$
|
|
62
|
-
index$
|
|
63
|
-
index$
|
|
58
|
+
index$4.langChainIntegration(),
|
|
59
|
+
index$9.langGraphIntegration(),
|
|
60
|
+
index$5.vercelAIIntegration(),
|
|
61
|
+
index$6.openAIIntegration(),
|
|
62
|
+
index$7.anthropicAIIntegration(),
|
|
63
|
+
index$8.googleGenAIIntegration(),
|
|
64
64
|
postgresjs.postgresJsIntegration(),
|
|
65
65
|
firebase.firebaseIntegration(),
|
|
66
66
|
];
|
|
@@ -73,7 +73,6 @@ function getAutoPerformanceIntegrations() {
|
|
|
73
73
|
function getOpenTelemetryInstrumentationToPreload() {
|
|
74
74
|
return [
|
|
75
75
|
http.instrumentSentryHttp,
|
|
76
|
-
http.instrumentOtelHttp,
|
|
77
76
|
express.instrumentExpress,
|
|
78
77
|
connect.instrumentConnect,
|
|
79
78
|
index.instrumentFastify,
|
|
@@ -90,18 +89,18 @@ function getOpenTelemetryInstrumentationToPreload() {
|
|
|
90
89
|
postgres.instrumentPostgres,
|
|
91
90
|
index$1.instrumentHapi,
|
|
92
91
|
graphql.instrumentGraphql,
|
|
93
|
-
|
|
92
|
+
index$3.instrumentRedis,
|
|
94
93
|
tedious.instrumentTedious,
|
|
95
94
|
genericPool.instrumentGenericPool,
|
|
96
95
|
amqplib.instrumentAmqplib,
|
|
97
|
-
index$
|
|
98
|
-
index$
|
|
99
|
-
index$
|
|
96
|
+
index$4.instrumentLangChain,
|
|
97
|
+
index$5.instrumentVercelAi,
|
|
98
|
+
index$6.instrumentOpenAi,
|
|
100
99
|
postgresjs.instrumentPostgresJs,
|
|
101
100
|
firebase.instrumentFirebase,
|
|
102
|
-
index$
|
|
103
|
-
index$
|
|
104
|
-
index$
|
|
101
|
+
index$7.instrumentAnthropicAi,
|
|
102
|
+
index$8.instrumentGoogleGenAI,
|
|
103
|
+
index$9.instrumentLangGraph,
|
|
105
104
|
];
|
|
106
105
|
}
|
|
107
106
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { instrumentSentryHttp } from '../http';\nimport { amqplibIntegration, instrumentAmqplib } from './amqplib';\nimport { anthropicAIIntegration, instrumentAnthropicAi } from './anthropic-ai';\nimport { connectIntegration, instrumentConnect } from './connect';\nimport { expressIntegration, instrumentExpress } from './express';\nimport { fastifyIntegration, instrumentFastify, instrumentFastifyV3 } from './fastify';\nimport { firebaseIntegration, instrumentFirebase } from './firebase';\nimport { genericPoolIntegration, instrumentGenericPool } from './genericPool';\nimport { googleGenAIIntegration, instrumentGoogleGenAI } from './google-genai';\nimport { graphqlIntegration, instrumentGraphql } from './graphql';\nimport { hapiIntegration, instrumentHapi } from './hapi';\nimport { honoIntegration, instrumentHono } from './hono';\nimport { instrumentKafka, kafkaIntegration } from './kafka';\nimport { instrumentKoa, koaIntegration } from './koa';\nimport { instrumentLangChain, langChainIntegration } from './langchain';\nimport { instrumentLangGraph, langGraphIntegration } from './langgraph';\nimport { instrumentLruMemoizer, lruMemoizerIntegration } from './lrumemoizer';\nimport { instrumentMongo, mongoIntegration } from './mongo';\nimport { instrumentMongoose, mongooseIntegration } from './mongoose';\nimport { instrumentMysql, mysqlIntegration } from './mysql';\nimport { instrumentMysql2, mysql2Integration } from './mysql2';\nimport { instrumentOpenAi, openAIIntegration } from './openai';\nimport { instrumentPostgres, postgresIntegration } from './postgres';\nimport { instrumentPostgresJs, postgresJsIntegration } from './postgresjs';\nimport { prismaIntegration } from './prisma';\nimport { instrumentRedis, redisIntegration } from './redis';\nimport { instrumentTedious, tediousIntegration } from './tedious';\nimport { instrumentVercelAi, vercelAIIntegration } from './vercelai';\n\n/**\n * With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.\n */\nexport function getAutoPerformanceIntegrations(): Integration[] {\n return [\n expressIntegration(),\n fastifyIntegration(),\n graphqlIntegration(),\n honoIntegration(),\n mongoIntegration(),\n mongooseIntegration(),\n mysqlIntegration(),\n mysql2Integration(),\n redisIntegration(),\n postgresIntegration(),\n prismaIntegration(),\n hapiIntegration(),\n koaIntegration(),\n connectIntegration(),\n tediousIntegration(),\n genericPoolIntegration(),\n kafkaIntegration(),\n amqplibIntegration(),\n lruMemoizerIntegration(),\n // AI providers\n // LangChain must come first to disable AI provider integrations before they instrument\n langChainIntegration(),\n langGraphIntegration(),\n vercelAIIntegration(),\n openAIIntegration(),\n anthropicAIIntegration(),\n googleGenAIIntegration(),\n postgresJsIntegration(),\n firebaseIntegration(),\n ];\n}\n\n/**\n * Get a list of methods to instrument OTEL, when preload instrumentation.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getOpenTelemetryInstrumentationToPreload(): (((options?: any) => void) & { id: string })[] {\n return [\n instrumentSentryHttp,\n instrumentExpress,\n instrumentConnect,\n instrumentFastify,\n instrumentFastifyV3,\n instrumentHapi,\n instrumentHono,\n instrumentKafka,\n instrumentKoa,\n instrumentLruMemoizer,\n instrumentMongo,\n instrumentMongoose,\n instrumentMysql,\n instrumentMysql2,\n instrumentPostgres,\n instrumentHapi,\n instrumentGraphql,\n instrumentRedis,\n instrumentTedious,\n instrumentGenericPool,\n instrumentAmqplib,\n instrumentLangChain,\n instrumentVercelAi,\n instrumentOpenAi,\n instrumentPostgresJs,\n instrumentFirebase,\n instrumentAnthropicAi,\n instrumentGoogleGenAI,\n instrumentLangGraph,\n ];\n}\n"],"names":["expressIntegration","fastifyIntegration","graphqlIntegration","honoIntegration","mongoIntegration","mongooseIntegration","mysqlIntegration","mysql2Integration","redisIntegration","postgresIntegration","prismaIntegration","hapiIntegration","koaIntegration","connectIntegration","tediousIntegration","genericPoolIntegration","kafkaIntegration","amqplibIntegration","lruMemoizerIntegration","langChainIntegration","langGraphIntegration","vercelAIIntegration","openAIIntegration","anthropicAIIntegration","googleGenAIIntegration","postgresJsIntegration","firebaseIntegration","instrumentSentryHttp","instrumentExpress","instrumentConnect","instrumentFastify","instrumentFastifyV3","instrumentHapi","instrumentHono","instrumentKafka","instrumentKoa","instrumentLruMemoizer","instrumentMongo","instrumentMongoose","instrumentMysql","instrumentMysql2","instrumentPostgres","instrumentGraphql","instrumentRedis","instrumentTedious","instrumentGenericPool","instrumentAmqplib","instrumentLangChain","instrumentVercelAi","instrumentOpenAi","instrumentPostgresJs","instrumentFirebase","instrumentAnthropicAi","instrumentGoogleGenAI","instrumentLangGraph"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA;AACA;AACA;AACO,SAA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BAAiB;AACrB,IAAIC,uBAAe;AACnB,IAAIC,yBAAiB;AACrB,IAAIC,iCAAqB;AACzB,IAAIC,yBAAiB;AACrB,IAAIC,2BAAmB;AACvB,IAAIC,0BAAkB;AACtB,IAAIC,wBAAgB;AACpB,IAAIC,+BAAoB;AACxB,IAAIC,2BAAkB;AACtB,IAAIC,6BAAqB;AACzB,IAAIC,6BAAqB;AACzB,IAAIC,2BAAmB;AACvB,GAAG;AACH;;;;;"}
|
|
@@ -17,39 +17,84 @@ class SentryLangGraphInstrumentation extends instrumentation.InstrumentationBase
|
|
|
17
17
|
* Initializes the instrumentation by defining the modules to be patched.
|
|
18
18
|
*/
|
|
19
19
|
init() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
return [
|
|
21
|
+
new instrumentation.InstrumentationNodeModuleDefinition(
|
|
22
|
+
'@langchain/langgraph',
|
|
23
|
+
supportedVersions,
|
|
24
|
+
this._patch.bind(this),
|
|
25
|
+
exports$1 => exports$1,
|
|
26
|
+
[
|
|
27
|
+
new instrumentation.InstrumentationNodeModuleFile(
|
|
28
|
+
/**
|
|
29
|
+
* In CJS, LangGraph packages re-export from dist/index.cjs files.
|
|
30
|
+
* Patching only the root module sometimes misses the real implementation or
|
|
31
|
+
* gets overwritten when that file is loaded. We add a file-level patch so that
|
|
32
|
+
* _patch runs again on the concrete implementation
|
|
33
|
+
*/
|
|
34
|
+
'@langchain/langgraph/dist/index.cjs',
|
|
35
|
+
supportedVersions,
|
|
36
|
+
this._patch.bind(this),
|
|
37
|
+
exports$1 => exports$1,
|
|
38
|
+
),
|
|
39
|
+
new instrumentation.InstrumentationNodeModuleFile(
|
|
40
|
+
/**
|
|
41
|
+
* In CJS, the prebuilt submodule re-exports from dist/prebuilt/index.cjs.
|
|
42
|
+
* We add a file-level patch under the main module so that CJS require()
|
|
43
|
+
* of @langchain/langgraph/prebuilt gets patched.
|
|
44
|
+
*/
|
|
45
|
+
'@langchain/langgraph/dist/prebuilt/index.cjs',
|
|
46
|
+
supportedVersions,
|
|
47
|
+
this._patch.bind(this),
|
|
48
|
+
exports$1 => exports$1,
|
|
49
|
+
),
|
|
50
|
+
],
|
|
51
|
+
),
|
|
52
|
+
new instrumentation.InstrumentationNodeModuleDefinition(
|
|
53
|
+
'@langchain/langgraph/prebuilt',
|
|
54
|
+
supportedVersions,
|
|
55
|
+
this._patch.bind(this),
|
|
56
|
+
exports$1 => exports$1,
|
|
57
|
+
[
|
|
58
|
+
new instrumentation.InstrumentationNodeModuleFile(
|
|
59
|
+
/**
|
|
60
|
+
* In CJS, the prebuilt submodule re-exports from dist/prebuilt/index.cjs.
|
|
61
|
+
* We add file-level patches so _patch runs on the concrete implementation.
|
|
62
|
+
*/
|
|
63
|
+
'@langchain/langgraph/dist/prebuilt/index.cjs',
|
|
64
|
+
supportedVersions,
|
|
65
|
+
this._patch.bind(this),
|
|
66
|
+
exports$1 => exports$1,
|
|
67
|
+
),
|
|
68
|
+
],
|
|
69
|
+
),
|
|
70
|
+
];
|
|
41
71
|
}
|
|
42
72
|
|
|
43
73
|
/**
|
|
44
74
|
* Core patch logic applying instrumentation to the LangGraph module.
|
|
45
75
|
*/
|
|
46
76
|
_patch(exports$1) {
|
|
77
|
+
const client = core.getClient();
|
|
78
|
+
const options = {
|
|
79
|
+
...this.getConfig(),
|
|
80
|
+
recordInputs: this.getConfig().recordInputs ?? client?.getOptions().sendDefaultPii,
|
|
81
|
+
recordOutputs: this.getConfig().recordOutputs ?? client?.getOptions().sendDefaultPii,
|
|
82
|
+
};
|
|
83
|
+
|
|
47
84
|
// Patch StateGraph.compile to instrument both compile() and invoke()
|
|
48
85
|
if (exports$1.StateGraph && typeof exports$1.StateGraph === 'function') {
|
|
49
|
-
core.instrumentLangGraph(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
86
|
+
core.instrumentLangGraph(exports$1.StateGraph.prototype , options);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Patch createReactAgent to instrument agent creation and invocation
|
|
90
|
+
if (exports$1.createReactAgent && typeof exports$1.createReactAgent === 'function') {
|
|
91
|
+
const originalCreateReactAgent = exports$1.createReactAgent;
|
|
92
|
+
Object.defineProperty(exports$1, 'createReactAgent', {
|
|
93
|
+
value: core.instrumentCreateReactAgent(originalCreateReactAgent , options),
|
|
94
|
+
writable: true,
|
|
95
|
+
enumerable: true,
|
|
96
|
+
configurable: true,
|
|
97
|
+
});
|
|
53
98
|
}
|
|
54
99
|
|
|
55
100
|
return exports$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/langgraph/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n} from '@opentelemetry/instrumentation';\nimport type { LangGraphOptions } from '@sentry/core';\nimport { instrumentLangGraph, SDK_VERSION } from '@sentry/core';\n\nconst supportedVersions = ['>=0.0.0 <2.0.0'];\n\ntype LangGraphInstrumentationOptions = InstrumentationConfig & LangGraphOptions;\n\n/**\n * Represents the patched shape of the LangGraph module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n StateGraph?: abstract new (...args: unknown[]) => unknown;\n}\n\n/**\n * Sentry LangGraph instrumentation using OpenTelemetry.\n */\nexport class SentryLangGraphInstrumentation extends InstrumentationBase<LangGraphInstrumentationOptions> {\n public constructor(config: LangGraphInstrumentationOptions = {}) {\n super('@sentry/instrumentation-langgraph', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n */\n public init(): InstrumentationModuleDefinition {\n
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/langgraph/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n} from '@opentelemetry/instrumentation';\nimport type { CompiledGraph, LangGraphOptions } from '@sentry/core';\nimport { getClient, instrumentCreateReactAgent, instrumentLangGraph, SDK_VERSION } from '@sentry/core';\n\nconst supportedVersions = ['>=0.0.0 <2.0.0'];\n\ntype LangGraphInstrumentationOptions = InstrumentationConfig & LangGraphOptions;\n\n/**\n * Represents the patched shape of the LangGraph module export.\n */\ninterface PatchedModuleExports {\n [key: string]: unknown;\n StateGraph?: abstract new (...args: unknown[]) => unknown;\n createReactAgent?: (...args: unknown[]) => CompiledGraph;\n}\n\n/**\n * Sentry LangGraph instrumentation using OpenTelemetry.\n */\nexport class SentryLangGraphInstrumentation extends InstrumentationBase<LangGraphInstrumentationOptions> {\n public constructor(config: LangGraphInstrumentationOptions = {}) {\n super('@sentry/instrumentation-langgraph', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n */\n public init(): InstrumentationModuleDefinition[] {\n return [\n new InstrumentationNodeModuleDefinition(\n '@langchain/langgraph',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n [\n new InstrumentationNodeModuleFile(\n /**\n * In CJS, LangGraph packages re-export from dist/index.cjs files.\n * Patching only the root module sometimes misses the real implementation or\n * gets overwritten when that file is loaded. We add a file-level patch so that\n * _patch runs again on the concrete implementation\n */\n '@langchain/langgraph/dist/index.cjs',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n new InstrumentationNodeModuleFile(\n /**\n * In CJS, the prebuilt submodule re-exports from dist/prebuilt/index.cjs.\n * We add a file-level patch under the main module so that CJS require()\n * of @langchain/langgraph/prebuilt gets patched.\n */\n '@langchain/langgraph/dist/prebuilt/index.cjs',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n ],\n ),\n new InstrumentationNodeModuleDefinition(\n '@langchain/langgraph/prebuilt',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n [\n new InstrumentationNodeModuleFile(\n /**\n * In CJS, the prebuilt submodule re-exports from dist/prebuilt/index.cjs.\n * We add file-level patches so _patch runs on the concrete implementation.\n */\n '@langchain/langgraph/dist/prebuilt/index.cjs',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n ],\n ),\n ];\n }\n\n /**\n * Core patch logic applying instrumentation to the LangGraph module.\n */\n private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {\n const client = getClient();\n const options = {\n ...this.getConfig(),\n recordInputs: this.getConfig().recordInputs ?? client?.getOptions().sendDefaultPii,\n recordOutputs: this.getConfig().recordOutputs ?? client?.getOptions().sendDefaultPii,\n };\n\n // Patch StateGraph.compile to instrument both compile() and invoke()\n if (exports.StateGraph && typeof exports.StateGraph === 'function') {\n instrumentLangGraph(exports.StateGraph.prototype as { compile: (...args: unknown[]) => unknown }, options);\n }\n\n // Patch createReactAgent to instrument agent creation and invocation\n if (exports.createReactAgent && typeof exports.createReactAgent === 'function') {\n const originalCreateReactAgent = exports.createReactAgent;\n Object.defineProperty(exports, 'createReactAgent', {\n value: instrumentCreateReactAgent(originalCreateReactAgent as (...args: unknown[]) => CompiledGraph, options),\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n\n return exports;\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","exports","InstrumentationNodeModuleFile","getClient","instrumentLangGraph","instrumentCreateReactAgent"],"mappings":";;;;;AAUA,MAAM,iBAAA,GAAoB,CAAC,gBAAgB,CAAC;;AAa5C;AACA;AACA;AACO,MAAM,8BAAA,SAAuCA,mCAAmB,CAAkC;AACzG,GAAS,WAAW,CAAC,MAAM,GAAoC,EAAE,EAAE;AACnE,IAAI,KAAK,CA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