@depup/sentry__node 10.47.0-depup.1 → 10.48.0-depup.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/README.md +5 -3
- package/build/cjs/index.js +5 -1
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/tracing/express.js +50 -141
- package/build/cjs/integrations/tracing/express.js.map +1 -1
- package/build/cjs/integrations/tracing/langchain/index.js +4 -3
- package/build/cjs/integrations/tracing/langchain/index.js.map +1 -1
- package/build/cjs/integrations/tracing/langchain/instrumentation.js +37 -3
- package/build/cjs/integrations/tracing/langchain/instrumentation.js.map +1 -1
- package/build/esm/index.js +3 -3
- package/build/esm/integrations/tracing/express.js +51 -142
- package/build/esm/integrations/tracing/express.js.map +1 -1
- package/build/esm/integrations/tracing/langchain/index.js +4 -3
- package/build/esm/integrations/tracing/langchain/index.js.map +1 -1
- package/build/esm/integrations/tracing/langchain/instrumentation.js +38 -4
- package/build/esm/integrations/tracing/langchain/instrumentation.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/express.d.ts +13 -68
- package/build/types/integrations/tracing/express.d.ts.map +1 -1
- package/build/types/integrations/tracing/langchain/index.d.ts +4 -3
- package/build/types/integrations/tracing/langchain/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/langchain/instrumentation.d.ts +10 -1
- package/build/types/integrations/tracing/langchain/instrumentation.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +2 -2
- package/build/types-ts3.8/integrations/tracing/express.d.ts +13 -68
- package/build/types-ts3.8/integrations/tracing/langchain/index.d.ts +4 -3
- package/build/types-ts3.8/integrations/tracing/langchain/instrumentation.d.ts +10 -1
- package/changes.json +10 -2
- package/package.json +17 -10
|
@@ -1,161 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { context } from '@opentelemetry/api';
|
|
3
|
+
import { getRPCMetadata, RPCType } from '@opentelemetry/core';
|
|
4
|
+
import { generateInstrumentOnce, ensureIsWrapped } from '@sentry/node-core';
|
|
5
|
+
import { SDK_VERSION, patchExpressModule, debug, defineIntegration, setupExpressErrorHandler as setupExpressErrorHandler$1 } from '@sentry/core';
|
|
6
|
+
export { expressErrorHandler } from '@sentry/core';
|
|
4
7
|
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
5
8
|
|
|
6
9
|
const INTEGRATION_NAME = 'Express';
|
|
10
|
+
const SUPPORTED_VERSIONS = ['>=4.0.0 <6'];
|
|
7
11
|
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (type) {
|
|
16
|
-
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `${type}.express`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Also update the name, we don't need to "middleware - " prefix
|
|
20
|
-
const name = attributes['express.name'];
|
|
21
|
-
if (typeof name === 'string') {
|
|
22
|
-
span.updateName(name);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function spanNameHook(info, defaultName) {
|
|
27
|
-
if (getIsolationScope() === getDefaultIsolationScope()) {
|
|
28
|
-
DEBUG_BUILD && debug.warn('Isolation scope is still default isolation scope - skipping setting transactionName');
|
|
29
|
-
return defaultName;
|
|
30
|
-
}
|
|
31
|
-
if (info.layerType === 'request_handler') {
|
|
32
|
-
// type cast b/c Otel unfortunately types info.request as any :(
|
|
33
|
-
const req = info.request ;
|
|
34
|
-
const method = req.method ? req.method.toUpperCase() : 'GET';
|
|
35
|
-
getIsolationScope().setTransactionName(`${method} ${info.route}`);
|
|
36
|
-
}
|
|
37
|
-
return defaultName;
|
|
12
|
+
function setupExpressErrorHandler(
|
|
13
|
+
//oxlint-disable-next-line no-explicit-any
|
|
14
|
+
app,
|
|
15
|
+
options,
|
|
16
|
+
) {
|
|
17
|
+
setupExpressErrorHandler$1(app, options);
|
|
18
|
+
ensureIsWrapped(app.use, 'express');
|
|
38
19
|
}
|
|
39
20
|
|
|
40
21
|
const instrumentExpress = generateInstrumentOnce(
|
|
41
22
|
INTEGRATION_NAME,
|
|
42
|
-
() =>
|
|
43
|
-
new ExpressInstrumentation({
|
|
44
|
-
requestHook: span => requestHook(span),
|
|
45
|
-
spanNameHook: (info, defaultName) => spanNameHook(info, defaultName),
|
|
46
|
-
}),
|
|
23
|
+
(options) => new ExpressInstrumentation(options),
|
|
47
24
|
);
|
|
48
25
|
|
|
49
|
-
|
|
26
|
+
class ExpressInstrumentation extends InstrumentationBase {
|
|
27
|
+
constructor(config = {}) {
|
|
28
|
+
super('sentry-express', SDK_VERSION, config);
|
|
29
|
+
}
|
|
30
|
+
init() {
|
|
31
|
+
const module = new InstrumentationNodeModuleDefinition(
|
|
32
|
+
'express',
|
|
33
|
+
SUPPORTED_VERSIONS,
|
|
34
|
+
express => {
|
|
35
|
+
try {
|
|
36
|
+
patchExpressModule({
|
|
37
|
+
...this.getConfig(),
|
|
38
|
+
express,
|
|
39
|
+
onRouteResolved(route) {
|
|
40
|
+
const rpcMetadata = getRPCMetadata(context.active());
|
|
41
|
+
if (route && rpcMetadata?.type === RPCType.HTTP) {
|
|
42
|
+
rpcMetadata.route = route;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
} catch (e) {
|
|
47
|
+
DEBUG_BUILD && debug.error('Failed to patch express module:', e);
|
|
48
|
+
}
|
|
49
|
+
return express;
|
|
50
|
+
},
|
|
51
|
+
// we do not ever actually unpatch in our SDKs
|
|
52
|
+
express => express,
|
|
53
|
+
);
|
|
54
|
+
return module;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const _expressInstrumentation = ((options) => {
|
|
50
59
|
return {
|
|
51
60
|
name: INTEGRATION_NAME,
|
|
52
61
|
setupOnce() {
|
|
53
|
-
instrumentExpress();
|
|
62
|
+
instrumentExpress(options);
|
|
54
63
|
},
|
|
55
64
|
};
|
|
56
65
|
}) ;
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
* Adds Sentry tracing instrumentation for [Express](https://expressjs.com/).
|
|
60
|
-
*
|
|
61
|
-
* If you also want to capture errors, you need to call `setupExpressErrorHandler(app)` after you set up your Express server.
|
|
62
|
-
*
|
|
63
|
-
* For more information, see the [express documentation](https://docs.sentry.io/platforms/javascript/guides/express/).
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```javascript
|
|
67
|
-
* const Sentry = require('@sentry/node');
|
|
68
|
-
*
|
|
69
|
-
* Sentry.init({
|
|
70
|
-
* integrations: [Sentry.expressIntegration()],
|
|
71
|
-
* })
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
const expressIntegration = defineIntegration(_expressIntegration);
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* An Express-compatible error handler.
|
|
78
|
-
*/
|
|
79
|
-
function expressErrorHandler(options) {
|
|
80
|
-
return function sentryErrorMiddleware(
|
|
81
|
-
error,
|
|
82
|
-
request,
|
|
83
|
-
res,
|
|
84
|
-
next,
|
|
85
|
-
) {
|
|
86
|
-
const normalizedRequest = httpRequestToRequestData(request);
|
|
87
|
-
// Ensure we use the express-enhanced request here, instead of the plain HTTP one
|
|
88
|
-
// When an error happens, the `expressRequestHandler` middleware does not run, so we set it here too
|
|
89
|
-
getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });
|
|
90
|
-
|
|
91
|
-
const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;
|
|
92
|
-
|
|
93
|
-
if (shouldHandleError(error)) {
|
|
94
|
-
const eventId = captureException(error, { mechanism: { type: 'auto.middleware.express', handled: false } });
|
|
95
|
-
(res ).sentry = eventId;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
next(error);
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function expressRequestHandler() {
|
|
103
|
-
return function sentryRequestMiddleware(
|
|
104
|
-
request,
|
|
105
|
-
_res,
|
|
106
|
-
next,
|
|
107
|
-
) {
|
|
108
|
-
const normalizedRequest = httpRequestToRequestData(request);
|
|
109
|
-
// Ensure we use the express-enhanced request here, instead of the plain HTTP one
|
|
110
|
-
getIsolationScope().setSDKProcessingMetadata({ normalizedRequest });
|
|
111
|
-
|
|
112
|
-
next();
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Add an Express error handler to capture errors to Sentry.
|
|
118
|
-
*
|
|
119
|
-
* The error handler must be before any other middleware and after all controllers.
|
|
120
|
-
*
|
|
121
|
-
* @param app The Express instances
|
|
122
|
-
* @param options {ExpressHandlerOptions} Configuration options for the handler
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```javascript
|
|
126
|
-
* const Sentry = require('@sentry/node');
|
|
127
|
-
* const express = require("express");
|
|
128
|
-
*
|
|
129
|
-
* const app = express();
|
|
130
|
-
*
|
|
131
|
-
* // Add your routes, etc.
|
|
132
|
-
*
|
|
133
|
-
* // Add this after all routes,
|
|
134
|
-
* // but before any and other error-handling middlewares are defined
|
|
135
|
-
* Sentry.setupExpressErrorHandler(app);
|
|
136
|
-
*
|
|
137
|
-
* app.listen(3000);
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
function setupExpressErrorHandler(
|
|
141
|
-
app,
|
|
142
|
-
options,
|
|
143
|
-
) {
|
|
144
|
-
app.use(expressRequestHandler());
|
|
145
|
-
app.use(expressErrorHandler(options));
|
|
146
|
-
ensureIsWrapped(app.use, 'express');
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function getStatusCodeFromResponse(error) {
|
|
150
|
-
const statusCode = error.status || error.statusCode || error.status_code || error.output?.statusCode;
|
|
151
|
-
return statusCode ? parseInt(statusCode , 10) : 500;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/** Returns true if response code is internal server error */
|
|
155
|
-
function defaultShouldHandleError(error) {
|
|
156
|
-
const status = getStatusCodeFromResponse(error);
|
|
157
|
-
return status >= 500;
|
|
158
|
-
}
|
|
67
|
+
const expressIntegration = defineIntegration(_expressInstrumentation);
|
|
159
68
|
|
|
160
|
-
export {
|
|
69
|
+
export { ExpressInstrumentation, expressIntegration, instrumentExpress, setupExpressErrorHandler };
|
|
161
70
|
//# sourceMappingURL=express.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sources":["../../../../src/integrations/tracing/express.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"express.js","sources":["../../../../src/integrations/tracing/express.ts"],"sourcesContent":["// Automatic istrumentation for Express using OTel\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport { context } from '@opentelemetry/api';\nimport { getRPCMetadata, RPCType } from '@opentelemetry/core';\n\nimport { ensureIsWrapped, generateInstrumentOnce } from '@sentry/node-core';\nimport {\n type ExpressIntegrationOptions,\n type IntegrationFn,\n debug,\n patchExpressModule,\n SDK_VERSION,\n defineIntegration,\n setupExpressErrorHandler as coreSetupExpressErrorHandler,\n type ExpressHandlerOptions,\n} from '@sentry/core';\nexport { expressErrorHandler } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\n\nconst INTEGRATION_NAME = 'Express';\nconst SUPPORTED_VERSIONS = ['>=4.0.0 <6'];\n\nexport function setupExpressErrorHandler(\n //oxlint-disable-next-line no-explicit-any\n app: { use: (middleware: any) => unknown },\n options?: ExpressHandlerOptions,\n): void {\n coreSetupExpressErrorHandler(app, options);\n ensureIsWrapped(app.use, 'express');\n}\n\nexport type ExpressInstrumentationConfig = InstrumentationConfig &\n Omit<ExpressIntegrationOptions, 'express' | 'onRouteResolved'>;\n\nexport const instrumentExpress = generateInstrumentOnce(\n INTEGRATION_NAME,\n (options?: ExpressInstrumentationConfig) => new ExpressInstrumentation(options),\n);\n\nexport class ExpressInstrumentation extends InstrumentationBase<ExpressInstrumentationConfig> {\n public constructor(config: ExpressInstrumentationConfig = {}) {\n super('sentry-express', SDK_VERSION, config);\n }\n public init(): InstrumentationNodeModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition(\n 'express',\n SUPPORTED_VERSIONS,\n express => {\n try {\n patchExpressModule({\n ...this.getConfig(),\n express,\n onRouteResolved(route) {\n const rpcMetadata = getRPCMetadata(context.active());\n if (route && rpcMetadata?.type === RPCType.HTTP) {\n rpcMetadata.route = route;\n }\n },\n });\n } catch (e) {\n DEBUG_BUILD && debug.error('Failed to patch express module:', e);\n }\n return express;\n },\n // we do not ever actually unpatch in our SDKs\n express => express,\n );\n return module;\n }\n}\n\nconst _expressInstrumentation = ((options?: ExpressInstrumentationConfig) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentExpress(options);\n },\n };\n}) satisfies IntegrationFn;\n\nexport const expressIntegration = defineIntegration(_expressInstrumentation);\n"],"names":["coreSetupExpressErrorHandler"],"mappings":";;;;;;;;AAoBA,MAAM,gBAAA,GAAmB,SAAS;AAClC,MAAM,kBAAA,GAAqB,CAAC,YAAY,CAAC;;AAElC,SAAS,wBAAwB;AACxC;AACA,EAAE,GAAG;AACL,EAAE,OAAO;AACT,EAAQ;AACR,EAAEA,0BAA4B,CAAC,GAAG,EAAE,OAAO,CAAC;AAC5C,EAAE,eAAe,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC;AACrC;;AAKO,MAAM,iBAAA,GAAoB,sBAAsB;AACvD,EAAE,gBAAgB;AAClB,EAAE,CAAC,OAAO,KAAoC,IAAI,sBAAsB,CAAC,OAAO,CAAC;AACjF;;AAEO,MAAM,sBAAA,SAA+B,mBAAmB,CAA+B;AAC9F,GAAS,WAAW,CAAC,MAAM,GAAiC,EAAE,EAAE;AAChE,IAAI,KAAK,CAAC,gBAAgB,EAAE,WAAW,EAAE,MAAM,CAAC;AAChD,EAAE;AACF,GAAS,IAAI,GAAwC;AACrD,IAAI,MAAM,MAAA,GAAS,IAAI,mCAAmC;AAC1D,MAAM,SAAS;AACf,MAAM,kBAAkB;AACxB,MAAM,WAAW;AACjB,QAAQ,IAAI;AACZ,UAAU,kBAAkB,CAAC;AAC7B,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE;AAC/B,YAAY,OAAO;AACnB,YAAY,eAAe,CAAC,KAAK,EAAE;AACnC,cAAc,MAAM,WAAA,GAAc,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;AAClE,cAAc,IAAI,KAAA,IAAS,WAAW,EAAE,IAAA,KAAS,OAAO,CAAC,IAAI,EAAE;AAC/D,gBAAgB,WAAW,CAAC,KAAA,GAAQ,KAAK;AACzC,cAAc;AACd,YAAY,CAAC;AACb,WAAW,CAAC;AACZ,QAAQ,CAAA,CAAE,OAAO,CAAC,EAAE;AACpB,UAAU,WAAA,IAAe,KAAK,CAAC,KAAK,CAAC,iCAAiC,EAAE,CAAC,CAAC;AAC1E,QAAQ;AACR,QAAQ,OAAO,OAAO;AACtB,MAAM,CAAC;AACP;AACA,MAAM,OAAA,IAAW,OAAO;AACxB,KAAK;AACL,IAAI,OAAO,MAAM;AACjB,EAAE;AACF;;AAEA,MAAM,2BAA2B,CAAC,OAAO,KAAoC;AAC7E,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,iBAAiB,CAAC,OAAO,CAAC;AAChC,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;MAEY,kBAAA,GAAqB,iBAAiB,CAAC,uBAAuB;;;;"}
|
|
@@ -102,9 +102,10 @@ const _langChainIntegration = ((options = {}) => {
|
|
|
102
102
|
* ## Supported Events
|
|
103
103
|
*
|
|
104
104
|
* The integration captures the following LangChain lifecycle events:
|
|
105
|
-
* - LLM/Chat Model: start, end, error
|
|
106
|
-
* - Chain: start, end, error
|
|
107
|
-
* - Tool: start, end, error
|
|
105
|
+
* - LLM/Chat Model: start, end, error (via callbacks)
|
|
106
|
+
* - Chain: start, end, error (via callbacks)
|
|
107
|
+
* - Tool: start, end, error (via callbacks)
|
|
108
|
+
* - Embeddings: embedQuery, embedDocuments (via direct method wrapping)
|
|
108
109
|
*
|
|
109
110
|
*/
|
|
110
111
|
const langChainIntegration = defineIntegration(_langChainIntegration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/langchain/index.ts"],"sourcesContent":["import type { IntegrationFn, LangChainOptions } from '@sentry/core';\nimport { defineIntegration, LANGCHAIN_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryLangChainInstrumentation } from './instrumentation';\n\nexport const instrumentLangChain = generateInstrumentOnce<LangChainOptions>(\n LANGCHAIN_INTEGRATION_NAME,\n options => new SentryLangChainInstrumentation(options),\n);\n\nconst _langChainIntegration = ((options: LangChainOptions = {}) => {\n return {\n name: LANGCHAIN_INTEGRATION_NAME,\n setupOnce() {\n instrumentLangChain(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for LangChain.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments LangChain runnable instances\n * to capture telemetry data by injecting Sentry callback handlers into all LangChain calls.\n *\n * **Important:** This integration automatically skips wrapping the OpenAI, Anthropic, and Google GenAI\n * providers to prevent duplicate spans when using LangChain with these AI providers.\n * LangChain handles the instrumentation for all underlying AI providers.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n * import { ChatOpenAI } from '@langchain/openai';\n *\n * Sentry.init({\n * integrations: [Sentry.langChainIntegration()],\n * sendDefaultPii: true, // Enable to record inputs/outputs\n * });\n *\n * // LangChain calls are automatically instrumented\n * const model = new ChatOpenAI();\n * await model.invoke(\"What is the capital of France?\");\n * ```\n *\n * ## Manual Callback Handler\n *\n * You can also manually add the Sentry callback handler alongside other callbacks:\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n * import { ChatOpenAI } from '@langchain/openai';\n *\n * const sentryHandler = Sentry.createLangChainCallbackHandler({\n * recordInputs: true,\n * recordOutputs: true\n * });\n *\n * const model = new ChatOpenAI();\n * await model.invoke(\n * \"What is the capital of France?\",\n * { callbacks: [sentryHandler, myOtherCallback] }\n * );\n * ```\n *\n * ## Options\n *\n * - `recordInputs`: Whether to record input messages/prompts (default: respects `sendDefaultPii` client option)\n * - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)\n *\n * ### Default Behavior\n *\n * By default, the integration will:\n * - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options\n * - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled\n *\n * @example\n * ```javascript\n * // Record inputs and outputs when sendDefaultPii is false\n * Sentry.init({\n * integrations: [\n * Sentry.langChainIntegration({\n * recordInputs: true,\n * recordOutputs: true\n * })\n * ],\n * });\n *\n * // Never record inputs/outputs regardless of sendDefaultPii\n * Sentry.init({\n * sendDefaultPii: true,\n * integrations: [\n * Sentry.langChainIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n * ## Supported Events\n *\n * The integration captures the following LangChain lifecycle events:\n * - LLM/Chat Model: start, end, error\n * - Chain: start, end, error\n * - Tool: start, end, error\n *\n */\nexport const langChainIntegration = defineIntegration(_langChainIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,mBAAA,GAAsB,sBAAsB;AACzD,EAAE,0BAA0B;AAC5B,EAAE,WAAW,IAAI,8BAA8B,CAAC,OAAO,CAAC;AACxD;;AAEA,MAAM,qBAAA,IAAyB,CAAC,OAAO,GAAqB,EAAE,KAAK;AACnE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,0BAA0B;AACpC,IAAI,SAAS,GAAG;AAChB,MAAM,mBAAmB,CAAC,OAAO,CAAC;AAClC,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,oBAAA,GAAuB,iBAAiB,CAAC,qBAAqB;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/langchain/index.ts"],"sourcesContent":["import type { IntegrationFn, LangChainOptions } from '@sentry/core';\nimport { defineIntegration, LANGCHAIN_INTEGRATION_NAME } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { SentryLangChainInstrumentation } from './instrumentation';\n\nexport const instrumentLangChain = generateInstrumentOnce<LangChainOptions>(\n LANGCHAIN_INTEGRATION_NAME,\n options => new SentryLangChainInstrumentation(options),\n);\n\nconst _langChainIntegration = ((options: LangChainOptions = {}) => {\n return {\n name: LANGCHAIN_INTEGRATION_NAME,\n setupOnce() {\n instrumentLangChain(options);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for LangChain.\n *\n * This integration is enabled by default.\n *\n * When configured, this integration automatically instruments LangChain runnable instances\n * to capture telemetry data by injecting Sentry callback handlers into all LangChain calls.\n *\n * **Important:** This integration automatically skips wrapping the OpenAI, Anthropic, and Google GenAI\n * providers to prevent duplicate spans when using LangChain with these AI providers.\n * LangChain handles the instrumentation for all underlying AI providers.\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n * import { ChatOpenAI } from '@langchain/openai';\n *\n * Sentry.init({\n * integrations: [Sentry.langChainIntegration()],\n * sendDefaultPii: true, // Enable to record inputs/outputs\n * });\n *\n * // LangChain calls are automatically instrumented\n * const model = new ChatOpenAI();\n * await model.invoke(\"What is the capital of France?\");\n * ```\n *\n * ## Manual Callback Handler\n *\n * You can also manually add the Sentry callback handler alongside other callbacks:\n *\n * @example\n * ```javascript\n * import * as Sentry from '@sentry/node';\n * import { ChatOpenAI } from '@langchain/openai';\n *\n * const sentryHandler = Sentry.createLangChainCallbackHandler({\n * recordInputs: true,\n * recordOutputs: true\n * });\n *\n * const model = new ChatOpenAI();\n * await model.invoke(\n * \"What is the capital of France?\",\n * { callbacks: [sentryHandler, myOtherCallback] }\n * );\n * ```\n *\n * ## Options\n *\n * - `recordInputs`: Whether to record input messages/prompts (default: respects `sendDefaultPii` client option)\n * - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)\n *\n * ### Default Behavior\n *\n * By default, the integration will:\n * - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options\n * - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled\n *\n * @example\n * ```javascript\n * // Record inputs and outputs when sendDefaultPii is false\n * Sentry.init({\n * integrations: [\n * Sentry.langChainIntegration({\n * recordInputs: true,\n * recordOutputs: true\n * })\n * ],\n * });\n *\n * // Never record inputs/outputs regardless of sendDefaultPii\n * Sentry.init({\n * sendDefaultPii: true,\n * integrations: [\n * Sentry.langChainIntegration({\n * recordInputs: false,\n * recordOutputs: false\n * })\n * ],\n * });\n * ```\n *\n * ## Supported Events\n *\n * The integration captures the following LangChain lifecycle events:\n * - LLM/Chat Model: start, end, error (via callbacks)\n * - Chain: start, end, error (via callbacks)\n * - Tool: start, end, error (via callbacks)\n * - Embeddings: embedQuery, embedDocuments (via direct method wrapping)\n *\n */\nexport const langChainIntegration = defineIntegration(_langChainIntegration);\n"],"names":[],"mappings":";;;;AAKO,MAAM,mBAAA,GAAsB,sBAAsB;AACzD,EAAE,0BAA0B;AAC5B,EAAE,WAAW,IAAI,8BAA8B,CAAC,OAAO,CAAC;AACxD;;AAEA,MAAM,qBAAA,IAAyB,CAAC,OAAO,GAAqB,EAAE,KAAK;AACnE,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,0BAA0B;AACpC,IAAI,SAAS,GAAG;AAChB,MAAM,mBAAmB,CAAC,OAAO,CAAC;AAClC,IAAI,CAAC;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,oBAAA,GAAuB,iBAAiB,CAAC,qBAAqB;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition, InstrumentationNodeModuleFile } from '@opentelemetry/instrumentation';
|
|
2
|
-
import { SDK_VERSION, _INTERNAL_skipAiProviderWrapping, OPENAI_INTEGRATION_NAME, ANTHROPIC_AI_INTEGRATION_NAME, GOOGLE_GENAI_INTEGRATION_NAME, createLangChainCallbackHandler } from '@sentry/core';
|
|
2
|
+
import { SDK_VERSION, _INTERNAL_skipAiProviderWrapping, OPENAI_INTEGRATION_NAME, ANTHROPIC_AI_INTEGRATION_NAME, GOOGLE_GENAI_INTEGRATION_NAME, createLangChainCallbackHandler, instrumentLangChainEmbeddings } from '@sentry/core';
|
|
3
3
|
|
|
4
4
|
const supportedVersions = ['>=0.1.0 <2.0.0'];
|
|
5
5
|
|
|
@@ -142,7 +142,7 @@ class SentryLangChainInstrumentation extends InstrumentationBase {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* Core patch logic - patches chat model
|
|
145
|
+
* Core patch logic - patches chat model and embedding methods
|
|
146
146
|
* This is called when a LangChain provider package is loaded
|
|
147
147
|
*/
|
|
148
148
|
_patch(exports$1) {
|
|
@@ -154,13 +154,19 @@ class SentryLangChainInstrumentation extends InstrumentationBase {
|
|
|
154
154
|
GOOGLE_GENAI_INTEGRATION_NAME,
|
|
155
155
|
]);
|
|
156
156
|
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
const config = this.getConfig();
|
|
158
|
+
|
|
159
|
+
// Create a shared handler instance for chat model callbacks
|
|
160
|
+
const sentryHandler = createLangChainCallbackHandler(config);
|
|
159
161
|
|
|
160
162
|
// Patch Runnable methods to inject callbacks at request time
|
|
161
163
|
// This directly manipulates options.callbacks that LangChain uses
|
|
162
164
|
this._patchRunnableMethods(exports$1, sentryHandler);
|
|
163
165
|
|
|
166
|
+
// Patch embedding methods to create spans directly
|
|
167
|
+
// Embeddings don't use the callback system, so we wrap the methods themselves
|
|
168
|
+
this._patchEmbeddingsMethods(exports$1, config);
|
|
169
|
+
|
|
164
170
|
return exports$1;
|
|
165
171
|
}
|
|
166
172
|
|
|
@@ -212,6 +218,34 @@ class SentryLangChainInstrumentation extends InstrumentationBase {
|
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
220
|
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Patches embedding class methods (embedQuery, embedDocuments) to create Sentry spans.
|
|
224
|
+
*
|
|
225
|
+
* Unlike chat models which use LangChain's callback system, the Embeddings base class
|
|
226
|
+
* has no callback support. We wrap the methods directly on the prototype.
|
|
227
|
+
*
|
|
228
|
+
* Instruments any exported class whose prototype has both embedQuery and embedDocuments as functions.
|
|
229
|
+
*/
|
|
230
|
+
_patchEmbeddingsMethods(exports$1, options) {
|
|
231
|
+
const exportsToPatch = (exports$1.universal_exports ?? exports$1) ;
|
|
232
|
+
|
|
233
|
+
for (const exp of Object.values(exportsToPatch)) {
|
|
234
|
+
if (typeof exp !== 'function' || !exp.prototype) {
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const proto = exp.prototype ;
|
|
238
|
+
if (typeof proto.embedQuery !== 'function' || typeof proto.embedDocuments !== 'function') {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (proto.__sentry_patched__) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
proto.__sentry_patched__ = true;
|
|
245
|
+
|
|
246
|
+
instrumentLangChainEmbeddings(proto, options);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
215
249
|
}
|
|
216
250
|
|
|
217
251
|
export { SentryLangChainInstrumentation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/langchain/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n} from '@opentelemetry/instrumentation';\nimport type { LangChainOptions } from '@sentry/core';\nimport {\n _INTERNAL_skipAiProviderWrapping,\n ANTHROPIC_AI_INTEGRATION_NAME,\n createLangChainCallbackHandler,\n GOOGLE_GENAI_INTEGRATION_NAME,\n OPENAI_INTEGRATION_NAME,\n SDK_VERSION,\n} from '@sentry/core';\n\nconst supportedVersions = ['>=0.1.0 <2.0.0'];\n\ntype LangChainInstrumentationOptions = InstrumentationConfig & LangChainOptions;\n\n/**\n * Represents the patched shape of LangChain provider package exports\n */\ninterface PatchedLangChainExports {\n [key: string]: unknown;\n}\n\n/**\n * Augments a callback handler list with Sentry's handler if not already present\n */\nfunction augmentCallbackHandlers(handlers: unknown, sentryHandler: unknown): unknown {\n // Handle null/undefined - return array with just our handler\n if (!handlers) {\n return [sentryHandler];\n }\n\n // If handlers is already an array\n if (Array.isArray(handlers)) {\n // Check if our handler is already in the list\n if (handlers.includes(sentryHandler)) {\n return handlers;\n }\n // Add our handler to the list\n return [...handlers, sentryHandler];\n }\n\n // If it's a single handler object, convert to array\n if (typeof handlers === 'object') {\n return [handlers, sentryHandler];\n }\n\n // Unknown type - return original\n return handlers;\n}\n\n/**\n * Wraps Runnable methods (invoke, stream, batch) to inject Sentry callbacks at request time\n * Uses a Proxy to intercept method calls and augment the options.callbacks\n */\nfunction wrapRunnableMethod(\n originalMethod: (...args: unknown[]) => unknown,\n sentryHandler: unknown,\n _methodName: string,\n): (...args: unknown[]) => unknown {\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: unknown[]): unknown {\n // LangChain Runnable method signatures:\n // invoke(input, options?) - options contains callbacks\n // stream(input, options?) - options contains callbacks\n // batch(inputs, options?) - options contains callbacks\n\n // Options is typically the second argument\n const optionsIndex = 1;\n let options = args[optionsIndex] as Record<string, unknown> | undefined;\n\n // If options don't exist or aren't an object, create them\n if (!options || typeof options !== 'object' || Array.isArray(options)) {\n options = {};\n args[optionsIndex] = options;\n }\n\n // Inject our callback handler into options.callbacks (request time callbacks)\n const existingCallbacks = options.callbacks;\n const augmentedCallbacks = augmentCallbackHandlers(existingCallbacks, sentryHandler);\n options.callbacks = augmentedCallbacks;\n\n // Call original method with augmented options\n return Reflect.apply(target, thisArg, args);\n },\n }) as (...args: unknown[]) => unknown;\n}\n\n/**\n * Sentry LangChain instrumentation using OpenTelemetry.\n */\nexport class SentryLangChainInstrumentation extends InstrumentationBase<LangChainInstrumentationOptions> {\n public constructor(config: LangChainInstrumentationOptions = {}) {\n super('@sentry/instrumentation-langchain', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n * We patch the BaseChatModel class methods to inject callbacks\n *\n * We hook into provider packages (@langchain/anthropic, @langchain/openai, etc.)\n * because @langchain/core is often bundled and not loaded as a separate module\n */\n public init(): InstrumentationModuleDefinition | InstrumentationModuleDefinition[] {\n const modules: InstrumentationModuleDefinition[] = [];\n\n // Hook into common LangChain provider packages\n const providerPackages = [\n '@langchain/anthropic',\n '@langchain/openai',\n '@langchain/google-genai',\n '@langchain/mistralai',\n '@langchain/google-vertexai',\n '@langchain/groq',\n ];\n\n for (const packageName of providerPackages) {\n // In CJS, LangChain 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 modules.push(\n new InstrumentationNodeModuleDefinition(\n packageName,\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n [\n new InstrumentationNodeModuleFile(\n `${packageName}/dist/index.cjs`,\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n ],\n ),\n );\n }\n\n // Hook into main 'langchain' package to catch initChatModel (v1+)\n modules.push(\n new InstrumentationNodeModuleDefinition(\n 'langchain',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n [\n // To catch the CJS build that contains ConfigurableModel / initChatModel for v1\n new InstrumentationNodeModuleFile(\n 'langchain/dist/chat_models/universal.cjs',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n ],\n ),\n );\n\n return modules;\n }\n\n /**\n * Core patch logic - patches chat model methods to inject Sentry callbacks\n * This is called when a LangChain provider package is loaded\n */\n private _patch(exports: PatchedLangChainExports): PatchedLangChainExports | void {\n // Skip AI provider wrapping now that LangChain is actually being used\n // This prevents duplicate spans from Anthropic/OpenAI/GoogleGenAI standalone integrations\n _INTERNAL_skipAiProviderWrapping([\n OPENAI_INTEGRATION_NAME,\n ANTHROPIC_AI_INTEGRATION_NAME,\n GOOGLE_GENAI_INTEGRATION_NAME,\n ]);\n\n // Create a shared handler instance\n const sentryHandler = createLangChainCallbackHandler(this.getConfig());\n\n // Patch Runnable methods to inject callbacks at request time\n // This directly manipulates options.callbacks that LangChain uses\n this._patchRunnableMethods(exports, sentryHandler);\n\n return exports;\n }\n\n /**\n * Patches chat model methods (invoke, stream, batch) to inject Sentry callbacks\n * Finds a chat model class from the provider package exports and patches its prototype methods\n */\n private _patchRunnableMethods(exports: PatchedLangChainExports, sentryHandler: unknown): void {\n // Known chat model class names for each provider\n const knownChatModelNames = [\n 'ChatAnthropic',\n 'ChatOpenAI',\n 'ChatGoogleGenerativeAI',\n 'ChatMistralAI',\n 'ChatVertexAI',\n 'ChatGroq',\n 'ConfigurableModel',\n ];\n\n const exportsToPatch = (exports.universal_exports ?? exports) as Record<string, unknown>;\n\n const chatModelClass = Object.values(exportsToPatch).find(exp => {\n return typeof exp === 'function' && knownChatModelNames.includes(exp.name);\n }) as { prototype: unknown; name: string } | undefined;\n\n if (!chatModelClass) {\n return;\n }\n\n // Patch directly on chatModelClass.prototype\n const targetProto = chatModelClass.prototype as Record<string, unknown>;\n\n // Skip if already patched (both file-level and module-level hooks resolve to the same prototype)\n if (targetProto.__sentry_patched__) {\n return;\n }\n targetProto.__sentry_patched__ = true;\n\n // Patch the methods (invoke, stream, batch)\n // All chat model instances will inherit these patched methods\n const methodsToPatch = ['invoke', 'stream', 'batch'] as const;\n\n for (const methodName of methodsToPatch) {\n const method = targetProto[methodName];\n if (typeof method === 'function') {\n targetProto[methodName] = wrapRunnableMethod(\n method as (...args: unknown[]) => unknown,\n sentryHandler,\n methodName,\n );\n }\n }\n }\n}\n"],"names":["exports"],"mappings":";;;AAiBA,MAAM,iBAAA,GAAoB,CAAC,gBAAgB,CAAC;;AAW5C;AACA;AACA;AACA,SAAS,uBAAuB,CAAC,QAAQ,EAAW,aAAa,EAAoB;AACrF;AACA,EAAE,IAAI,CAAC,QAAQ,EAAE;AACjB,IAAI,OAAO,CAAC,aAAa,CAAC;AAC1B,EA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A;AACA,IAAA,WAAA,CAAA,kBAAA,GAAA,IAAA;;AAEA;AACA;AACA,IAAA,MAAA,cAAA,GAAA,CAAA,QAAA,EAAA,QAAA,EAAA,OAAA,CAAA;;AAEA,IAAA,KAAA,MAAA,UAAA,IAAA,cAAA,EAAA;AACA,MAAA,MAAA,MAAA,GAAA,WAAA,CAAA,UAAA,CAAA;AACA,MAAA,IAAA,OAAA,MAAA,KAAA,UAAA,EAAA;AACA,QAAA,WAAA,CAAA,UAAA,CAAA,GAAA,kBAAA;AACA,UAAA,MAAA;AACA,UAAA,aAEA,CAAA;AACA,MAAA;AACA,IAAA;AACA,EAAA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/langchain/instrumentation.ts"],"sourcesContent":["import {\n InstrumentationBase,\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n} from '@opentelemetry/instrumentation';\nimport type { LangChainOptions } from '@sentry/core';\nimport {\n _INTERNAL_skipAiProviderWrapping,\n ANTHROPIC_AI_INTEGRATION_NAME,\n createLangChainCallbackHandler,\n GOOGLE_GENAI_INTEGRATION_NAME,\n instrumentLangChainEmbeddings,\n OPENAI_INTEGRATION_NAME,\n SDK_VERSION,\n} from '@sentry/core';\n\nconst supportedVersions = ['>=0.1.0 <2.0.0'];\n\ntype LangChainInstrumentationOptions = InstrumentationConfig & LangChainOptions;\n\n/**\n * Represents the patched shape of LangChain provider package exports\n */\ninterface PatchedLangChainExports {\n [key: string]: unknown;\n}\n\n/**\n * Augments a callback handler list with Sentry's handler if not already present\n */\nfunction augmentCallbackHandlers(handlers: unknown, sentryHandler: unknown): unknown {\n // Handle null/undefined - return array with just our handler\n if (!handlers) {\n return [sentryHandler];\n }\n\n // If handlers is already an array\n if (Array.isArray(handlers)) {\n // Check if our handler is already in the list\n if (handlers.includes(sentryHandler)) {\n return handlers;\n }\n // Add our handler to the list\n return [...handlers, sentryHandler];\n }\n\n // If it's a single handler object, convert to array\n if (typeof handlers === 'object') {\n return [handlers, sentryHandler];\n }\n\n // Unknown type - return original\n return handlers;\n}\n\n/**\n * Wraps Runnable methods (invoke, stream, batch) to inject Sentry callbacks at request time\n * Uses a Proxy to intercept method calls and augment the options.callbacks\n */\nfunction wrapRunnableMethod(\n originalMethod: (...args: unknown[]) => unknown,\n sentryHandler: unknown,\n _methodName: string,\n): (...args: unknown[]) => unknown {\n return new Proxy(originalMethod, {\n apply(target, thisArg, args: unknown[]): unknown {\n // LangChain Runnable method signatures:\n // invoke(input, options?) - options contains callbacks\n // stream(input, options?) - options contains callbacks\n // batch(inputs, options?) - options contains callbacks\n\n // Options is typically the second argument\n const optionsIndex = 1;\n let options = args[optionsIndex] as Record<string, unknown> | undefined;\n\n // If options don't exist or aren't an object, create them\n if (!options || typeof options !== 'object' || Array.isArray(options)) {\n options = {};\n args[optionsIndex] = options;\n }\n\n // Inject our callback handler into options.callbacks (request time callbacks)\n const existingCallbacks = options.callbacks;\n const augmentedCallbacks = augmentCallbackHandlers(existingCallbacks, sentryHandler);\n options.callbacks = augmentedCallbacks;\n\n // Call original method with augmented options\n return Reflect.apply(target, thisArg, args);\n },\n }) as (...args: unknown[]) => unknown;\n}\n\n/**\n * Sentry LangChain instrumentation using OpenTelemetry.\n */\nexport class SentryLangChainInstrumentation extends InstrumentationBase<LangChainInstrumentationOptions> {\n public constructor(config: LangChainInstrumentationOptions = {}) {\n super('@sentry/instrumentation-langchain', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation by defining the modules to be patched.\n * We patch the BaseChatModel class methods to inject callbacks\n *\n * We hook into provider packages (@langchain/anthropic, @langchain/openai, etc.)\n * because @langchain/core is often bundled and not loaded as a separate module\n */\n public init(): InstrumentationModuleDefinition | InstrumentationModuleDefinition[] {\n const modules: InstrumentationModuleDefinition[] = [];\n\n // Hook into common LangChain provider packages\n const providerPackages = [\n '@langchain/anthropic',\n '@langchain/openai',\n '@langchain/google-genai',\n '@langchain/mistralai',\n '@langchain/google-vertexai',\n '@langchain/groq',\n ];\n\n for (const packageName of providerPackages) {\n // In CJS, LangChain 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 modules.push(\n new InstrumentationNodeModuleDefinition(\n packageName,\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n [\n new InstrumentationNodeModuleFile(\n `${packageName}/dist/index.cjs`,\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n ],\n ),\n );\n }\n\n // Hook into main 'langchain' package to catch initChatModel (v1+)\n modules.push(\n new InstrumentationNodeModuleDefinition(\n 'langchain',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n [\n // To catch the CJS build that contains ConfigurableModel / initChatModel for v1\n new InstrumentationNodeModuleFile(\n 'langchain/dist/chat_models/universal.cjs',\n supportedVersions,\n this._patch.bind(this),\n exports => exports,\n ),\n ],\n ),\n );\n\n return modules;\n }\n\n /**\n * Core patch logic - patches chat model and embedding methods\n * This is called when a LangChain provider package is loaded\n */\n private _patch(exports: PatchedLangChainExports): PatchedLangChainExports | void {\n // Skip AI provider wrapping now that LangChain is actually being used\n // This prevents duplicate spans from Anthropic/OpenAI/GoogleGenAI standalone integrations\n _INTERNAL_skipAiProviderWrapping([\n OPENAI_INTEGRATION_NAME,\n ANTHROPIC_AI_INTEGRATION_NAME,\n GOOGLE_GENAI_INTEGRATION_NAME,\n ]);\n\n const config = this.getConfig();\n\n // Create a shared handler instance for chat model callbacks\n const sentryHandler = createLangChainCallbackHandler(config);\n\n // Patch Runnable methods to inject callbacks at request time\n // This directly manipulates options.callbacks that LangChain uses\n this._patchRunnableMethods(exports, sentryHandler);\n\n // Patch embedding methods to create spans directly\n // Embeddings don't use the callback system, so we wrap the methods themselves\n this._patchEmbeddingsMethods(exports, config);\n\n return exports;\n }\n\n /**\n * Patches chat model methods (invoke, stream, batch) to inject Sentry callbacks\n * Finds a chat model class from the provider package exports and patches its prototype methods\n */\n private _patchRunnableMethods(exports: PatchedLangChainExports, sentryHandler: unknown): void {\n // Known chat model class names for each provider\n const knownChatModelNames = [\n 'ChatAnthropic',\n 'ChatOpenAI',\n 'ChatGoogleGenerativeAI',\n 'ChatMistralAI',\n 'ChatVertexAI',\n 'ChatGroq',\n 'ConfigurableModel',\n ];\n\n const exportsToPatch = (exports.universal_exports ?? exports) as Record<string, unknown>;\n\n const chatModelClass = Object.values(exportsToPatch).find(exp => {\n return typeof exp === 'function' && knownChatModelNames.includes(exp.name);\n }) as { prototype: unknown; name: string } | undefined;\n\n if (!chatModelClass) {\n return;\n }\n\n // Patch directly on chatModelClass.prototype\n const targetProto = chatModelClass.prototype as Record<string, unknown>;\n\n // Skip if already patched (both file-level and module-level hooks resolve to the same prototype)\n if (targetProto.__sentry_patched__) {\n return;\n }\n targetProto.__sentry_patched__ = true;\n\n // Patch the methods (invoke, stream, batch)\n // All chat model instances will inherit these patched methods\n const methodsToPatch = ['invoke', 'stream', 'batch'] as const;\n\n for (const methodName of methodsToPatch) {\n const method = targetProto[methodName];\n if (typeof method === 'function') {\n targetProto[methodName] = wrapRunnableMethod(\n method as (...args: unknown[]) => unknown,\n sentryHandler,\n methodName,\n );\n }\n }\n }\n\n /**\n * Patches embedding class methods (embedQuery, embedDocuments) to create Sentry spans.\n *\n * Unlike chat models which use LangChain's callback system, the Embeddings base class\n * has no callback support. We wrap the methods directly on the prototype.\n *\n * Instruments any exported class whose prototype has both embedQuery and embedDocuments as functions.\n */\n private _patchEmbeddingsMethods(exports: PatchedLangChainExports, options: LangChainOptions): void {\n const exportsToPatch = (exports.universal_exports ?? exports) as Record<string, unknown>;\n\n for (const exp of Object.values(exportsToPatch)) {\n if (typeof exp !== 'function' || !exp.prototype) {\n continue;\n }\n const proto = exp.prototype as Record<string, unknown>;\n if (typeof proto.embedQuery !== 'function' || typeof proto.embedDocuments !== 'function') {\n continue;\n }\n if (proto.__sentry_patched__) {\n continue;\n }\n proto.__sentry_patched__ = true;\n\n instrumentLangChainEmbeddings(proto, options);\n }\n }\n}\n"],"names":["exports"],"mappings":";;;AAkBA,MAAM,iBAAA,GAAoB,CAAC,gBAAgB,CAAC;;AAW5C;AACA;AACA;AACA,SAAS,uBAAuB,CAAC,QAAQ,EAAW,aAAa,EAAoB;AACrF;AACA,EAAE,IAAI,CAAC,QAAQ,EAAE;AACjB,IAAI,OAAO,CAAC,aAAa,CAAC;AAC1B,EAAE;;AAEF;AACA,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;AAC/B;AACA,IAAI,IAAI,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;AAC1C,MAAM,OAAO,QAAQ;AACrB,IAAI;AACJ;AACA,IAAI,OAAO,CAAC,GAAG,QAAQ,EAAE,aAAa,CAAC;AACvC,EAAE;;AAEF;AACA,EAAE,IAAI,OAAO,QAAA,KAAa,QAAQ,EAAE;AACpC,IAAI,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC;AACpC,EAAE;;AAEF;AACA,EAAE,OAAO,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA,SAAS,kBAAkB;AAC3B,EAAE,cAAc;AAChB,EAAE,aAAa;AACf,EAAE,WAAW;AACb,EAAmC;AACnC,EAAE,OAAO,IAAI,KAAK,CAAC,cAAc,EAAE;AACnC,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAsB;AACrD;AACA;AACA;AACA;;AAEA;AACA,MAAM,MAAM,YAAA,GAAe,CAAC;AAC5B,MAAM,IAAI,OAAA,GAAU,IAAI,CAAC,YAAY,CAAA;;AAErC;AACA,MAAM,IAAI,CAAC,OAAA,IAAW,OAAO,OAAA,KAAY,QAAA,IAAY,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;AAC7E,QAAQ,OAAA,GAAU,EAAE;AACpB,QAAQ,IAAI,CAAC,YAAY,CAAA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AAA,UAAA,KAAA,UAAA,IAAA,OAAA,KAAA,CAAA,cAAA,KAAA,UAAA,EAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA,IAAA,KAAA,CAAA,kBAAA,EAAA;AACA,QAAA;AACA,MAAA;AACA,MAAA,KAAA,CAAA,kBAAA,GAAA,IAAA;;AAEA,MAAA,6BAAA,CAAA,KAAA,EAAA,OAAA,CAAA;AACA,IAAA;AACA,EAAA;AACA;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.48.0","sideEffects":false}
|
package/build/types/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export { initOpenTelemetry, preloadOpenTelemetry } from './sdk/initOtel';
|
|
|
36
36
|
export { getAutoPerformanceIntegrations } from './integrations/tracing';
|
|
37
37
|
export type { NodeOptions } from './types';
|
|
38
38
|
export { setOpenTelemetryContextAsyncContextStrategy as setNodeAsyncContextStrategy, } from '@sentry/opentelemetry';
|
|
39
|
-
export { addBreadcrumb, isInitialized, isEnabled, getGlobalScope, lastEventId, close, createTransport, flush, SDK_VERSION, getSpanStatusFromHttpCode, setHttpStatus, captureCheckIn, withMonitor, requestDataIntegration, functionToStringIntegration, inboundFiltersIntegration, eventFiltersIntegration, linkedErrorsIntegration, addEventProcessor, setContext, setExtra, setExtras, setTag, setTags, setUser, setConversationId, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, setCurrentClient, Scope, setMeasurement, getSpanDescendants, parameterize, getClient, getCurrentScope, getIsolationScope, getTraceData, getTraceMetaTags, httpHeadersToSpanAttributes, winterCGHeadersToDict, continueTrace, withScope, withIsolationScope, captureException, captureEvent, captureMessage, captureFeedback, captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, startSession, captureSession, endSession, addIntegration, startSpan, startSpanManual, startInactiveSpan, startNewTrace, suppressTracing, getActiveSpan, withActiveSpan, getRootSpan, spanToJSON, spanToTraceHeader, spanToBaggageHeader, trpcMiddleware, updateSpanName, supabaseIntegration, instrumentSupabaseClient, instrumentOpenAiClient, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, zodErrorsIntegration, profiler, consoleLoggingIntegration, createConsolaReporter, consoleIntegration, wrapMcpServerWithSentry, featureFlagsIntegration, createLangChainCallbackHandler, instrumentLangGraph, instrumentStateGraphCompile, } from '@sentry/core';
|
|
39
|
+
export { addBreadcrumb, isInitialized, isEnabled, getGlobalScope, lastEventId, close, createTransport, flush, SDK_VERSION, getSpanStatusFromHttpCode, setHttpStatus, captureCheckIn, withMonitor, requestDataIntegration, functionToStringIntegration, inboundFiltersIntegration, eventFiltersIntegration, linkedErrorsIntegration, addEventProcessor, setContext, setExtra, setExtras, setTag, setTags, setUser, setConversationId, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, setCurrentClient, Scope, setMeasurement, getSpanDescendants, parameterize, getClient, getCurrentScope, getIsolationScope, getTraceData, getTraceMetaTags, httpHeadersToSpanAttributes, winterCGHeadersToDict, continueTrace, withScope, withIsolationScope, captureException, captureEvent, captureMessage, captureFeedback, captureConsoleIntegration, dedupeIntegration, extraErrorDataIntegration, rewriteFramesIntegration, startSession, captureSession, endSession, addIntegration, startSpan, startSpanManual, startInactiveSpan, startNewTrace, suppressTracing, getActiveSpan, withActiveSpan, getRootSpan, spanToJSON, spanToTraceHeader, spanToBaggageHeader, trpcMiddleware, updateSpanName, supabaseIntegration, instrumentSupabaseClient, instrumentOpenAiClient, instrumentAnthropicAiClient, instrumentGoogleGenAIClient, zodErrorsIntegration, profiler, consoleLoggingIntegration, createConsolaReporter, consoleIntegration, wrapMcpServerWithSentry, featureFlagsIntegration, spanStreamingIntegration, createLangChainCallbackHandler, instrumentLangChainEmbeddings, instrumentLangGraph, instrumentStateGraphCompile, } from '@sentry/core';
|
|
40
40
|
export type { Breadcrumb, BreadcrumbHint, PolymorphicRequest, RequestEventData, SdkInfo, Event, EventHint, ErrorEvent, Exception, Session, SeverityLevel, StackFrame, Stacktrace, Thread, User, Span, Metric, Log, LogSeverityLevel, FeatureFlagsIntegration, ExclusiveEventHintOrCaptureContext, CaptureContext, } from '@sentry/core';
|
|
41
|
-
export { logger, metrics, httpServerIntegration, httpServerSpansIntegration, nodeContextIntegration, contextLinesIntegration, localVariablesIntegration, modulesIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, anrIntegration, disableAnrDetectionForCallback, spotlightIntegration, childProcessIntegration, processSessionIntegration, nodeRuntimeMetricsIntegration, type NodeRuntimeMetricsOptions, pinoIntegration, createSentryWinstonTransport, SentryContextManager, systemErrorIntegration, generateInstrumentOnce, getSentryRelease, defaultStackParser, createGetModuleFromFilename, makeNodeTransport, NodeClient, cron, NODE_VERSION, validateOpenTelemetrySetup, } from '@sentry/node-core';
|
|
41
|
+
export { logger, metrics, httpServerIntegration, httpServerSpansIntegration, nodeContextIntegration, contextLinesIntegration, localVariablesIntegration, modulesIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, anrIntegration, disableAnrDetectionForCallback, spotlightIntegration, childProcessIntegration, processSessionIntegration, nodeRuntimeMetricsIntegration, type NodeRuntimeMetricsOptions, pinoIntegration, createSentryWinstonTransport, SentryContextManager, systemErrorIntegration, generateInstrumentOnce, getSentryRelease, defaultStackParser, createGetModuleFromFilename, makeNodeTransport, NodeClient, cron, NODE_VERSION, validateOpenTelemetrySetup, withStreamedSpan, _INTERNAL_normalizeCollectionInterval, } from '@sentry/node-core';
|
|
42
42
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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EACnB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,EACpB,QAAQ,EACR,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAC9B,6BAA6B,EAC7B,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,GAAG,EACH,gBAAgB,EAChB,uBAAuB,EACvB,kCAAkC,EAClC,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,MAAM,EACN,OAAO,EACP,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,8BAA8B,EAC9B,+BAA+B,EAE/B,cAAc,EAEd,8BAA8B,EAC9B,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,6BAA6B,EAC7B,KAAK,yBAAyB,EAC9B,eAAe,EACf,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,2BAA2B,EAC3B,iBAAiB,EACjB,UAAU,EACV,IAAI,EACJ,YAAY,EACZ,0BAA0B,EAC1B,gBAAgB,EAChB,qCAAqC,GACtC,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,72 +1,17 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { type ExpressIntegrationOptions, type ExpressHandlerOptions } from '@sentry/core';
|
|
4
|
+
export { expressErrorHandler } from '@sentry/core';
|
|
5
|
+
export declare function setupExpressErrorHandler(app: {
|
|
6
|
+
use: (middleware: any) => unknown;
|
|
7
|
+
}, options?: ExpressHandlerOptions): void;
|
|
8
|
+
export type ExpressInstrumentationConfig = InstrumentationConfig & Omit<ExpressIntegrationOptions, 'express' | 'onRouteResolved'>;
|
|
9
|
+
export declare const instrumentExpress: ((options?: ExpressInstrumentationConfig | undefined) => ExpressInstrumentation) & {
|
|
4
10
|
id: string;
|
|
5
11
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* If you also want to capture errors, you need to call `setupExpressErrorHandler(app)` after you set up your Express server.
|
|
10
|
-
*
|
|
11
|
-
* For more information, see the [express documentation](https://docs.sentry.io/platforms/javascript/guides/express/).
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```javascript
|
|
15
|
-
* const Sentry = require('@sentry/node');
|
|
16
|
-
*
|
|
17
|
-
* Sentry.init({
|
|
18
|
-
* integrations: [Sentry.expressIntegration()],
|
|
19
|
-
* })
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare const expressIntegration: () => import("@sentry/core").Integration;
|
|
23
|
-
interface MiddlewareError extends Error {
|
|
24
|
-
status?: number | string;
|
|
25
|
-
statusCode?: number | string;
|
|
26
|
-
status_code?: number | string;
|
|
27
|
-
output?: {
|
|
28
|
-
statusCode?: number | string;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
type ExpressMiddleware = (req: http.IncomingMessage, res: http.ServerResponse, next: () => void) => void;
|
|
32
|
-
type ExpressErrorMiddleware = (error: MiddlewareError, req: http.IncomingMessage, res: http.ServerResponse, next: (error: MiddlewareError) => void) => void;
|
|
33
|
-
interface ExpressHandlerOptions {
|
|
34
|
-
/**
|
|
35
|
-
* Callback method deciding whether error should be captured and sent to Sentry
|
|
36
|
-
* @param error Captured middleware error
|
|
37
|
-
*/
|
|
38
|
-
shouldHandleError?(this: void, error: MiddlewareError): boolean;
|
|
12
|
+
export declare class ExpressInstrumentation extends InstrumentationBase<ExpressInstrumentationConfig> {
|
|
13
|
+
constructor(config?: ExpressInstrumentationConfig);
|
|
14
|
+
init(): InstrumentationNodeModuleDefinition;
|
|
39
15
|
}
|
|
40
|
-
|
|
41
|
-
* An Express-compatible error handler.
|
|
42
|
-
*/
|
|
43
|
-
export declare function expressErrorHandler(options?: ExpressHandlerOptions): ExpressErrorMiddleware;
|
|
44
|
-
/**
|
|
45
|
-
* Add an Express error handler to capture errors to Sentry.
|
|
46
|
-
*
|
|
47
|
-
* The error handler must be before any other middleware and after all controllers.
|
|
48
|
-
*
|
|
49
|
-
* @param app The Express instances
|
|
50
|
-
* @param options {ExpressHandlerOptions} Configuration options for the handler
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```javascript
|
|
54
|
-
* const Sentry = require('@sentry/node');
|
|
55
|
-
* const express = require("express");
|
|
56
|
-
*
|
|
57
|
-
* const app = express();
|
|
58
|
-
*
|
|
59
|
-
* // Add your routes, etc.
|
|
60
|
-
*
|
|
61
|
-
* // Add this after all routes,
|
|
62
|
-
* // but before any and other error-handling middlewares are defined
|
|
63
|
-
* Sentry.setupExpressErrorHandler(app);
|
|
64
|
-
*
|
|
65
|
-
* app.listen(3000);
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
export declare function setupExpressErrorHandler(app: {
|
|
69
|
-
use: (middleware: ExpressMiddleware | ExpressErrorMiddleware) => unknown;
|
|
70
|
-
}, options?: ExpressHandlerOptions): void;
|
|
71
|
-
export {};
|
|
16
|
+
export declare const expressIntegration: (options?: ExpressInstrumentationConfig | undefined) => import("@sentry/core").Integration;
|
|
72
17
|
//# sourceMappingURL=express.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/express.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/express.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAK1G,OAAO,EACL,KAAK,yBAAyB,EAO9B,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMnD,wBAAgB,wBAAwB,CAEtC,GAAG,EAAE;IAAE,GAAG,EAAE,CAAC,UAAU,EAAE,GAAG,KAAK,OAAO,CAAA;CAAE,EAC1C,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CAGN;AAED,MAAM,MAAM,4BAA4B,GAAG,qBAAqB,GAC9D,IAAI,CAAC,yBAAyB,EAAE,SAAS,GAAG,iBAAiB,CAAC,CAAC;AAEjE,eAAO,MAAM,iBAAiB;;CAG7B,CAAC;AAEF,qBAAa,sBAAuB,SAAQ,mBAAmB,CAAC,4BAA4B,CAAC;gBACxE,MAAM,GAAE,4BAAiC;IAGrD,IAAI,IAAI,mCAAmC;CA0BnD;AAWD,eAAO,MAAM,kBAAkB,4FAA6C,CAAC"}
|
|
@@ -88,9 +88,10 @@ export declare const instrumentLangChain: ((options?: LangChainOptions | undefin
|
|
|
88
88
|
* ## Supported Events
|
|
89
89
|
*
|
|
90
90
|
* The integration captures the following LangChain lifecycle events:
|
|
91
|
-
* - LLM/Chat Model: start, end, error
|
|
92
|
-
* - Chain: start, end, error
|
|
93
|
-
* - Tool: start, end, error
|
|
91
|
+
* - LLM/Chat Model: start, end, error (via callbacks)
|
|
92
|
+
* - Chain: start, end, error (via callbacks)
|
|
93
|
+
* - Tool: start, end, error (via callbacks)
|
|
94
|
+
* - Embeddings: embedQuery, embedDocuments (via direct method wrapping)
|
|
94
95
|
*
|
|
95
96
|
*/
|
|
96
97
|
export declare const langChainIntegration: (options?: LangChainOptions | undefined) => import("@sentry/core").Integration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/langchain/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKpE,eAAO,MAAM,mBAAmB;;CAG/B,CAAC;AAWF
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/langchain/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKpE,eAAO,MAAM,mBAAmB;;CAG/B,CAAC;AAWF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,eAAO,MAAM,oBAAoB,gFAA2C,CAAC"}
|