@sentry/node 10.21.0 → 10.22.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.
Files changed (55) hide show
  1. package/build/cjs/index.js +10 -7
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/node-fetch.js +2 -0
  4. package/build/cjs/integrations/node-fetch.js.map +1 -1
  5. package/build/cjs/integrations/tracing/firebase/firebase.js +18 -0
  6. package/build/cjs/integrations/tracing/firebase/firebase.js.map +1 -1
  7. package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js +3 -0
  8. package/build/cjs/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -1
  9. package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js +265 -0
  10. package/build/cjs/integrations/tracing/firebase/otel/patches/functions.js.map +1 -0
  11. package/build/cjs/integrations/tracing/index.js +3 -0
  12. package/build/cjs/integrations/tracing/index.js.map +1 -1
  13. package/build/cjs/integrations/tracing/langchain/index.js +112 -0
  14. package/build/cjs/integrations/tracing/langchain/index.js.map +1 -0
  15. package/build/cjs/integrations/tracing/langchain/instrumentation.js +201 -0
  16. package/build/cjs/integrations/tracing/langchain/instrumentation.js.map +1 -0
  17. package/build/esm/index.js +2 -1
  18. package/build/esm/index.js.map +1 -1
  19. package/build/esm/integrations/node-fetch.js +2 -0
  20. package/build/esm/integrations/node-fetch.js.map +1 -1
  21. package/build/esm/integrations/tracing/firebase/firebase.js +19 -1
  22. package/build/esm/integrations/tracing/firebase/firebase.js.map +1 -1
  23. package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js +3 -0
  24. package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -1
  25. package/build/esm/integrations/tracing/firebase/otel/patches/functions.js +262 -0
  26. package/build/esm/integrations/tracing/firebase/otel/patches/functions.js.map +1 -0
  27. package/build/esm/integrations/tracing/index.js +3 -0
  28. package/build/esm/integrations/tracing/index.js.map +1 -1
  29. package/build/esm/integrations/tracing/langchain/index.js +109 -0
  30. package/build/esm/integrations/tracing/langchain/index.js.map +1 -0
  31. package/build/esm/integrations/tracing/langchain/instrumentation.js +199 -0
  32. package/build/esm/integrations/tracing/langchain/instrumentation.js.map +1 -0
  33. package/build/esm/package.json +1 -1
  34. package/build/types/index.d.ts +2 -1
  35. package/build/types/index.d.ts.map +1 -1
  36. package/build/types/integrations/node-fetch.d.ts +2 -1
  37. package/build/types/integrations/node-fetch.d.ts.map +1 -1
  38. package/build/types/integrations/tracing/firebase/firebase.d.ts.map +1 -1
  39. package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts.map +1 -1
  40. package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
  41. package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts.map +1 -0
  42. package/build/types/integrations/tracing/firebase/otel/types.d.ts +34 -0
  43. package/build/types/integrations/tracing/firebase/otel/types.d.ts.map +1 -1
  44. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  45. package/build/types/integrations/tracing/langchain/index.d.ts +93 -0
  46. package/build/types/integrations/tracing/langchain/index.d.ts.map +1 -0
  47. package/build/types/integrations/tracing/langchain/instrumentation.d.ts +29 -0
  48. package/build/types/integrations/tracing/langchain/instrumentation.d.ts.map +1 -0
  49. package/build/types-ts3.8/index.d.ts +2 -1
  50. package/build/types-ts3.8/integrations/node-fetch.d.ts +2 -1
  51. package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
  52. package/build/types-ts3.8/integrations/tracing/firebase/otel/types.d.ts +34 -0
  53. package/build/types-ts3.8/integrations/tracing/langchain/index.d.ts +93 -0
  54. package/build/types-ts3.8/integrations/tracing/langchain/instrumentation.d.ts +29 -0
  55. package/package.json +4 -4
@@ -0,0 +1,93 @@
1
+ import type { LangChainOptions } from '@sentry/core';
2
+ export declare const instrumentLangChain: ((options?: LangChainOptions | undefined) => import("@opentelemetry/instrumentation").Instrumentation<import("@opentelemetry/instrumentation").InstrumentationConfig>) & {
3
+ id: string;
4
+ };
5
+ /**
6
+ * Adds Sentry tracing instrumentation for LangChain.
7
+ *
8
+ * This integration is enabled by default.
9
+ *
10
+ * When configured, this integration automatically instruments LangChain runnable instances
11
+ * to capture telemetry data by injecting Sentry callback handlers into all LangChain calls.
12
+ *
13
+ * @example
14
+ * ```javascript
15
+ * import * as Sentry from '@sentry/node';
16
+ * import { ChatOpenAI } from '@langchain/openai';
17
+ *
18
+ * Sentry.init({
19
+ * integrations: [Sentry.langChainIntegration()],
20
+ * sendDefaultPii: true, // Enable to record inputs/outputs
21
+ * });
22
+ *
23
+ * // LangChain calls are automatically instrumented
24
+ * const model = new ChatOpenAI();
25
+ * await model.invoke("What is the capital of France?");
26
+ * ```
27
+ *
28
+ * ## Manual Callback Handler
29
+ *
30
+ * You can also manually add the Sentry callback handler alongside other callbacks:
31
+ *
32
+ * @example
33
+ * ```javascript
34
+ * import * as Sentry from '@sentry/node';
35
+ * import { ChatOpenAI } from '@langchain/openai';
36
+ *
37
+ * const sentryHandler = Sentry.createLangChainCallbackHandler({
38
+ * recordInputs: true,
39
+ * recordOutputs: true
40
+ * });
41
+ *
42
+ * const model = new ChatOpenAI();
43
+ * await model.invoke(
44
+ * "What is the capital of France?",
45
+ * { callbacks: [sentryHandler, myOtherCallback] }
46
+ * );
47
+ * ```
48
+ *
49
+ * ## Options
50
+ *
51
+ * - `recordInputs`: Whether to record input messages/prompts (default: respects `sendDefaultPii` client option)
52
+ * - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)
53
+ *
54
+ * ### Default Behavior
55
+ *
56
+ * By default, the integration will:
57
+ * - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options
58
+ * - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled
59
+ *
60
+ * @example
61
+ * ```javascript
62
+ * // Record inputs and outputs when sendDefaultPii is false
63
+ * Sentry.init({
64
+ * integrations: [
65
+ * Sentry.langChainIntegration({
66
+ * recordInputs: true,
67
+ * recordOutputs: true
68
+ * })
69
+ * ],
70
+ * });
71
+ *
72
+ * // Never record inputs/outputs regardless of sendDefaultPii
73
+ * Sentry.init({
74
+ * sendDefaultPii: true,
75
+ * integrations: [
76
+ * Sentry.langChainIntegration({
77
+ * recordInputs: false,
78
+ * recordOutputs: false
79
+ * })
80
+ * ],
81
+ * });
82
+ * ```
83
+ *
84
+ * ## Supported Events
85
+ *
86
+ * The integration captures the following LangChain lifecycle events:
87
+ * - LLM/Chat Model: start, end, error
88
+ * - Chain: start, end, error
89
+ * - Tool: start, end, error
90
+ *
91
+ */
92
+ export declare const langChainIntegration: (options?: LangChainOptions | undefined) => import("@sentry/core").Integration;
93
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AACH,eAAO,MAAM,oBAAoB,gFAA2C,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type InstrumentationConfig, type InstrumentationModuleDefinition, InstrumentationBase } from '@opentelemetry/instrumentation';
2
+ import type { LangChainOptions } from '@sentry/core';
3
+ type LangChainInstrumentationOptions = InstrumentationConfig & LangChainOptions;
4
+ /**
5
+ * Sentry LangChain instrumentation using OpenTelemetry.
6
+ */
7
+ export declare class SentryLangChainInstrumentation extends InstrumentationBase<LangChainInstrumentationOptions> {
8
+ constructor(config?: LangChainInstrumentationOptions);
9
+ /**
10
+ * Initializes the instrumentation by defining the modules to be patched.
11
+ * We patch the BaseChatModel class methods to inject callbacks
12
+ *
13
+ * We hook into provider packages (@langchain/anthropic, @langchain/openai, etc.)
14
+ * because @langchain/core is often bundled and not loaded as a separate module
15
+ */
16
+ init(): InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
17
+ /**
18
+ * Core patch logic - patches chat model methods to inject Sentry callbacks
19
+ * This is called when a LangChain provider package is loaded
20
+ */
21
+ private _patch;
22
+ /**
23
+ * Patches chat model methods (invoke, stream, batch) to inject Sentry callbacks
24
+ * Finds a chat model class from the provider package exports and patches its prototype methods
25
+ */
26
+ private _patchRunnableMethods;
27
+ }
28
+ export {};
29
+ //# sourceMappingURL=instrumentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/langchain/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACpC,mBAAmB,EAGpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKrD,KAAK,+BAA+B,GAAG,qBAAqB,GAAG,gBAAgB,CAAC;AA0EhF;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,mBAAmB,CAAC,+BAA+B,CAAC;gBACnF,MAAM,GAAE,+BAAoC;IAI/D;;;;;;OAMG;IACI,IAAI,IAAI,+BAA+B,GAAG,+BAA+B,EAAE;IAuClF;;;OAGG;IACH,OAAO,CAAC,MAAM;IAwBd;;;OAGG;IACH,OAAO,CAAC,qBAAqB;CAyC9B"}
@@ -27,6 +27,7 @@ export { vercelAIIntegration } from './integrations/tracing/vercelai';
27
27
  export { openAIIntegration } from './integrations/tracing/openai';
28
28
  export { anthropicAIIntegration } from './integrations/tracing/anthropic-ai';
29
29
  export { googleGenAIIntegration } from './integrations/tracing/google-genai';
30
+ export { langChainIntegration } from './integrations/tracing/langchain';
30
31
  export { launchDarklyIntegration, buildLaunchDarklyFlagUsedHandler, openFeatureIntegration, OpenFeatureIntegrationHook, statsigIntegration, unleashIntegration, growthbookIntegration, } from './integrations/featureFlagShims';
31
32
  export { firebaseIntegration } from './integrations/tracing/firebase';
32
33
  export { init, getDefaultIntegrations, getDefaultIntegrationsWithoutPerformance, initWithoutDefaultIntegrations, } from './sdk';
@@ -34,7 +35,7 @@ export { initOpenTelemetry, preloadOpenTelemetry } from './sdk/initOtel';
34
35
  export { getAutoPerformanceIntegrations } from './integrations/tracing';
35
36
  export { NodeOptions } from './types';
36
37
  export { setOpenTelemetryContextAsyncContextStrategy as setNodeAsyncContextStrategy, } from '@sentry/opentelemetry';
37
- 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, 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, zodErrorsIntegration, profiler, consoleLoggingIntegration, createConsolaReporter, consoleIntegration, wrapMcpServerWithSentry, featureFlagsIntegration, } from '@sentry/core';
38
+ 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, 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, zodErrorsIntegration, profiler, consoleLoggingIntegration, createConsolaReporter, consoleIntegration, wrapMcpServerWithSentry, featureFlagsIntegration, createLangChainCallbackHandler, } from '@sentry/core';
38
39
  export { Breadcrumb, BreadcrumbHint, PolymorphicRequest, RequestEventData, SdkInfo, Event, EventHint, ErrorEvent, Exception, Session, SeverityLevel, StackFrame, Stacktrace, Thread, User, Span, Metric, FeatureFlagsIntegration, } from '@sentry/core';
39
40
  export { logger, metrics, httpServerIntegration, httpServerSpansIntegration, nodeContextIntegration, contextLinesIntegration, localVariablesIntegration, modulesIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, anrIntegration, disableAnrDetectionForCallback, spotlightIntegration, childProcessIntegration, pinoIntegration, createSentryWinstonTransport, SentryContextManager, systemErrorIntegration, generateInstrumentOnce, getSentryRelease, defaultStackParser, createGetModuleFromFilename, makeNodeTransport, NodeClient, cron, NODE_VERSION, validateOpenTelemetrySetup, } from '@sentry/node-core';
40
41
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,5 @@
1
- interface NodeFetchOptions {
1
+ import { UndiciInstrumentationConfig } from '@opentelemetry/instrumentation-undici';
2
+ interface NodeFetchOptions extends Pick<UndiciInstrumentationConfig, 'requestHook' | 'responseHook'> {
2
3
  /**
3
4
  * Whether breadcrumbs should be recorded for requests.
4
5
  * Defaults to true
@@ -0,0 +1,23 @@
1
+ import { Tracer } from '@opentelemetry/api';
2
+ import { InstrumentationBase } from '@opentelemetry/instrumentation';
3
+ import { InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
4
+ import { FirebaseFunctions, FirebaseInstrumentationConfig, OverloadedParameters } from '../types';
5
+ /**
6
+ * Patches Firebase Functions v2 to add OpenTelemetry instrumentation
7
+ * @param tracer - Opentelemetry Tracer
8
+ * @param functionsSupportedVersions - supported versions of firebase-functions
9
+ * @param wrap - reference to native instrumentation wrap function
10
+ * @param unwrap - reference to native instrumentation unwrap function
11
+ * @param config - Firebase instrumentation config
12
+ */
13
+ export declare function patchFunctions(tracer: Tracer, functionsSupportedVersions: string[], wrap: InstrumentationBase['_wrap'], unwrap: InstrumentationBase['_unwrap'], config: FirebaseInstrumentationConfig): InstrumentationNodeModuleDefinition;
14
+ /**
15
+ * Patches Cloud Functions for Firebase (v2) to add OpenTelemetry instrumentation
16
+ *
17
+ * @param tracer - Opentelemetry Tracer
18
+ * @param functionsConfig - Firebase instrumentation config
19
+ * @param triggerType - Type of trigger
20
+ * @returns A function that patches the function
21
+ */
22
+ export declare function patchV2Functions<T extends FirebaseFunctions = FirebaseFunctions>(tracer: Tracer, functionsConfig: FirebaseInstrumentationConfig['functions'], triggerType: string): (original: T) => (...args: OverloadedParameters<T>) => ReturnType<T>;
23
+ //# sourceMappingURL=functions.d.ts.map
@@ -75,7 +75,16 @@ export interface FirestoreSettings {
75
75
  */
76
76
  export interface FirebaseInstrumentationConfig extends InstrumentationConfig {
77
77
  firestoreSpanCreationHook?: FirestoreSpanCreationHook;
78
+ functions?: FunctionsConfig;
78
79
  }
80
+ export interface FunctionsConfig {
81
+ requestHook?: RequestHook;
82
+ responseHook?: ResponseHook;
83
+ errorHook?: ErrorHook;
84
+ }
85
+ export type RequestHook = (span: Span) => void;
86
+ export type ResponseHook = (span: Span, error?: unknown) => void;
87
+ export type ErrorHook = (span: Span, error?: unknown) => Promise<void> | void;
79
88
  export interface FirestoreSpanCreationHook {
80
89
  (span: Span): void;
81
90
  }
@@ -83,4 +92,29 @@ export type GetDocsType<AppModelType = DocumentData, DbModelType extends Documen
83
92
  export type SetDocType<AppModelType = DocumentData, DbModelType extends DocumentData = DocumentData> = ((reference: DocumentReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>) => Promise<void>) & ((reference: DocumentReference<AppModelType, DbModelType>, data: PartialWithFieldValue<AppModelType>, options: SetOptions) => Promise<void>);
84
93
  export type AddDocType<AppModelType, DbModelType extends DocumentData> = (reference: CollectionReference<AppModelType, DbModelType>, data: WithFieldValue<AppModelType>) => Promise<DocumentReference<AppModelType, DbModelType>>;
85
94
  export type DeleteDocType<AppModelType, DbModelType extends DocumentData> = (reference: DocumentReference<AppModelType, DbModelType>) => Promise<void>;
95
+ export type OverloadedParameters<T> = T extends {
96
+ (...args: infer A1): unknown;
97
+ (...args: infer A2): unknown;
98
+ } ? A1 | A2 : T extends (...args: infer A) => unknown ? A : unknown;
99
+ /**
100
+ * A bare minimum of how Cloud Functions for Firebase (v2) are defined.
101
+ */
102
+ export type FirebaseFunctions = ((handler: () => Promise<unknown> | unknown) => (...args: unknown[]) => Promise<unknown> | unknown) | ((documentOrOptions: string | string[] | Record<string, unknown>, handler: () => Promise<unknown> | unknown) => (...args: unknown[]) => Promise<unknown> | unknown);
103
+ export type AvailableFirebaseFunctions = {
104
+ onRequest: FirebaseFunctions;
105
+ onCall: FirebaseFunctions;
106
+ onDocumentCreated: FirebaseFunctions;
107
+ onDocumentUpdated: FirebaseFunctions;
108
+ onDocumentDeleted: FirebaseFunctions;
109
+ onDocumentWritten: FirebaseFunctions;
110
+ onDocumentCreatedWithAuthContext: FirebaseFunctions;
111
+ onDocumentUpdatedWithAuthContext: FirebaseFunctions;
112
+ onDocumentDeletedWithAuthContext: FirebaseFunctions;
113
+ onDocumentWrittenWithAuthContext: FirebaseFunctions;
114
+ onSchedule: FirebaseFunctions;
115
+ onObjectFinalized: FirebaseFunctions;
116
+ onObjectArchived: FirebaseFunctions;
117
+ onObjectDeleted: FirebaseFunctions;
118
+ onObjectMetadataUpdated: FirebaseFunctions;
119
+ };
86
120
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,93 @@
1
+ import { LangChainOptions } from '@sentry/core';
2
+ export declare const instrumentLangChain: ((options?: LangChainOptions | undefined) => import("@opentelemetry/instrumentation").Instrumentation<import("@opentelemetry/instrumentation").InstrumentationConfig>) & {
3
+ id: string;
4
+ };
5
+ /**
6
+ * Adds Sentry tracing instrumentation for LangChain.
7
+ *
8
+ * This integration is enabled by default.
9
+ *
10
+ * When configured, this integration automatically instruments LangChain runnable instances
11
+ * to capture telemetry data by injecting Sentry callback handlers into all LangChain calls.
12
+ *
13
+ * @example
14
+ * ```javascript
15
+ * import * as Sentry from '@sentry/node';
16
+ * import { ChatOpenAI } from '@langchain/openai';
17
+ *
18
+ * Sentry.init({
19
+ * integrations: [Sentry.langChainIntegration()],
20
+ * sendDefaultPii: true, // Enable to record inputs/outputs
21
+ * });
22
+ *
23
+ * // LangChain calls are automatically instrumented
24
+ * const model = new ChatOpenAI();
25
+ * await model.invoke("What is the capital of France?");
26
+ * ```
27
+ *
28
+ * ## Manual Callback Handler
29
+ *
30
+ * You can also manually add the Sentry callback handler alongside other callbacks:
31
+ *
32
+ * @example
33
+ * ```javascript
34
+ * import * as Sentry from '@sentry/node';
35
+ * import { ChatOpenAI } from '@langchain/openai';
36
+ *
37
+ * const sentryHandler = Sentry.createLangChainCallbackHandler({
38
+ * recordInputs: true,
39
+ * recordOutputs: true
40
+ * });
41
+ *
42
+ * const model = new ChatOpenAI();
43
+ * await model.invoke(
44
+ * "What is the capital of France?",
45
+ * { callbacks: [sentryHandler, myOtherCallback] }
46
+ * );
47
+ * ```
48
+ *
49
+ * ## Options
50
+ *
51
+ * - `recordInputs`: Whether to record input messages/prompts (default: respects `sendDefaultPii` client option)
52
+ * - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)
53
+ *
54
+ * ### Default Behavior
55
+ *
56
+ * By default, the integration will:
57
+ * - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options
58
+ * - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled
59
+ *
60
+ * @example
61
+ * ```javascript
62
+ * // Record inputs and outputs when sendDefaultPii is false
63
+ * Sentry.init({
64
+ * integrations: [
65
+ * Sentry.langChainIntegration({
66
+ * recordInputs: true,
67
+ * recordOutputs: true
68
+ * })
69
+ * ],
70
+ * });
71
+ *
72
+ * // Never record inputs/outputs regardless of sendDefaultPii
73
+ * Sentry.init({
74
+ * sendDefaultPii: true,
75
+ * integrations: [
76
+ * Sentry.langChainIntegration({
77
+ * recordInputs: false,
78
+ * recordOutputs: false
79
+ * })
80
+ * ],
81
+ * });
82
+ * ```
83
+ *
84
+ * ## Supported Events
85
+ *
86
+ * The integration captures the following LangChain lifecycle events:
87
+ * - LLM/Chat Model: start, end, error
88
+ * - Chain: start, end, error
89
+ * - Tool: start, end, error
90
+ *
91
+ */
92
+ export declare const langChainIntegration: (options?: LangChainOptions | undefined) => import("@sentry/core").Integration;
93
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { InstrumentationConfig, InstrumentationModuleDefinition, InstrumentationBase } from '@opentelemetry/instrumentation';
2
+ import { LangChainOptions } from '@sentry/core';
3
+ type LangChainInstrumentationOptions = InstrumentationConfig & LangChainOptions;
4
+ /**
5
+ * Sentry LangChain instrumentation using OpenTelemetry.
6
+ */
7
+ export declare class SentryLangChainInstrumentation extends InstrumentationBase<LangChainInstrumentationOptions> {
8
+ constructor(config?: LangChainInstrumentationOptions);
9
+ /**
10
+ * Initializes the instrumentation by defining the modules to be patched.
11
+ * We patch the BaseChatModel class methods to inject callbacks
12
+ *
13
+ * We hook into provider packages (@langchain/anthropic, @langchain/openai, etc.)
14
+ * because @langchain/core is often bundled and not loaded as a separate module
15
+ */
16
+ init(): InstrumentationModuleDefinition | InstrumentationModuleDefinition[];
17
+ /**
18
+ * Core patch logic - patches chat model methods to inject Sentry callbacks
19
+ * This is called when a LangChain provider package is loaded
20
+ */
21
+ private _patch;
22
+ /**
23
+ * Patches chat model methods (invoke, stream, batch) to inject Sentry callbacks
24
+ * Finds a chat model class from the provider package exports and patches its prototype methods
25
+ */
26
+ private _patchRunnableMethods;
27
+ }
28
+ export {};
29
+ //# sourceMappingURL=instrumentation.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/node",
3
- "version": "10.21.0",
3
+ "version": "10.22.0",
4
4
  "description": "Sentry Node SDK using OpenTelemetry for performance instrumentation",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
@@ -95,9 +95,9 @@
95
95
  "@opentelemetry/sdk-trace-base": "^2.1.0",
96
96
  "@opentelemetry/semantic-conventions": "^1.37.0",
97
97
  "@prisma/instrumentation": "6.15.0",
98
- "@sentry/core": "10.21.0",
99
- "@sentry/node-core": "10.21.0",
100
- "@sentry/opentelemetry": "10.21.0",
98
+ "@sentry/core": "10.22.0",
99
+ "@sentry/node-core": "10.22.0",
100
+ "@sentry/opentelemetry": "10.22.0",
101
101
  "import-in-the-middle": "^1.14.2",
102
102
  "minimatch": "^9.0.0"
103
103
  },