@sentry/node 10.21.0 → 10.23.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 (59) 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/cjs/integrations/tracing/postgresjs.js +1 -1
  18. package/build/cjs/integrations/tracing/postgresjs.js.map +1 -1
  19. package/build/esm/index.js +2 -1
  20. package/build/esm/index.js.map +1 -1
  21. package/build/esm/integrations/node-fetch.js +2 -0
  22. package/build/esm/integrations/node-fetch.js.map +1 -1
  23. package/build/esm/integrations/tracing/firebase/firebase.js +19 -1
  24. package/build/esm/integrations/tracing/firebase/firebase.js.map +1 -1
  25. package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js +3 -0
  26. package/build/esm/integrations/tracing/firebase/otel/firebaseInstrumentation.js.map +1 -1
  27. package/build/esm/integrations/tracing/firebase/otel/patches/functions.js +262 -0
  28. package/build/esm/integrations/tracing/firebase/otel/patches/functions.js.map +1 -0
  29. package/build/esm/integrations/tracing/index.js +3 -0
  30. package/build/esm/integrations/tracing/index.js.map +1 -1
  31. package/build/esm/integrations/tracing/langchain/index.js +109 -0
  32. package/build/esm/integrations/tracing/langchain/index.js.map +1 -0
  33. package/build/esm/integrations/tracing/langchain/instrumentation.js +199 -0
  34. package/build/esm/integrations/tracing/langchain/instrumentation.js.map +1 -0
  35. package/build/esm/integrations/tracing/postgresjs.js +1 -1
  36. package/build/esm/integrations/tracing/postgresjs.js.map +1 -1
  37. package/build/esm/package.json +1 -1
  38. package/build/types/index.d.ts +2 -1
  39. package/build/types/index.d.ts.map +1 -1
  40. package/build/types/integrations/node-fetch.d.ts +2 -1
  41. package/build/types/integrations/node-fetch.d.ts.map +1 -1
  42. package/build/types/integrations/tracing/firebase/firebase.d.ts.map +1 -1
  43. package/build/types/integrations/tracing/firebase/otel/firebaseInstrumentation.d.ts.map +1 -1
  44. package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
  45. package/build/types/integrations/tracing/firebase/otel/patches/functions.d.ts.map +1 -0
  46. package/build/types/integrations/tracing/firebase/otel/types.d.ts +34 -0
  47. package/build/types/integrations/tracing/firebase/otel/types.d.ts.map +1 -1
  48. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  49. package/build/types/integrations/tracing/langchain/index.d.ts +93 -0
  50. package/build/types/integrations/tracing/langchain/index.d.ts.map +1 -0
  51. package/build/types/integrations/tracing/langchain/instrumentation.d.ts +29 -0
  52. package/build/types/integrations/tracing/langchain/instrumentation.d.ts.map +1 -0
  53. package/build/types-ts3.8/index.d.ts +2 -1
  54. package/build/types-ts3.8/integrations/node-fetch.d.ts +2 -1
  55. package/build/types-ts3.8/integrations/tracing/firebase/otel/patches/functions.d.ts +23 -0
  56. package/build/types-ts3.8/integrations/tracing/firebase/otel/types.d.ts +34 -0
  57. package/build/types-ts3.8/integrations/tracing/langchain/index.d.ts +93 -0
  58. package/build/types-ts3.8/integrations/tracing/langchain/instrumentation.d.ts +29 -0
  59. package/package.json +4 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/langchain/instrumentation.ts"],"sourcesContent":["import {\n type InstrumentationConfig,\n type InstrumentationModuleDefinition,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n} from '@opentelemetry/instrumentation';\nimport type { LangChainOptions } from '@sentry/core';\nimport { createLangChainCallbackHandler, getClient, SDK_VERSION } from '@sentry/core';\n\nconst supportedVersions = ['>=0.1.0 <1.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 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 const client = getClient();\n const defaultPii = Boolean(client?.getOptions().sendDefaultPii);\n\n const config = this.getConfig();\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const recordInputs = config?.recordInputs ?? defaultPii;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const recordOutputs = config?.recordOutputs ?? defaultPii;\n\n // Create a shared handler instance\n const sentryHandler = createLangChainCallbackHandler({\n recordInputs,\n recordOutputs,\n });\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 ];\n\n // Find a chat model class in the exports by checking known class names\n const chatModelClass = Object.values(exports).find(exp => {\n if (typeof exp !== 'function') {\n return false;\n }\n return 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 // 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":[],"mappings":";;;AAUA,MAAM,iBAAA,GAAoB,CAAC,gBAAgB,CAAC;;AAW5C;AACA;AACA;AACA,SAAS,uBAAuB,CAAC,QAAQ,EAAW,aAAa,EAAoB;AACrF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A;AACA,UAAA,MAAA;AACA,UAAA,aAEA,CAAA;AACA;AACA;AACA;AACA;;;;"}
@@ -83,7 +83,7 @@ class PostgresJsInstrumentation extends InstrumentationBase {
83
83
  code: SPAN_STATUS_ERROR,
84
84
  // This message is the error message from the rejectArgs, when available
85
85
  // e.g "relation 'User' does not exist"
86
- message: rejectArgs?.[0]?.message || 'unknown_error',
86
+ message: rejectArgs?.[0]?.message || 'internal_error',
87
87
  });
88
88
 
89
89
  const result = Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);
@@ -1 +1 @@
1
- {"version":3,"file":"postgresjs.js","sources":["../../../../src/integrations/tracing/postgresjs.ts"],"sourcesContent":["// Instrumentation for https://github.com/porsager/postgres\nimport { context, trace } from '@opentelemetry/api';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n ATTR_DB_NAMESPACE,\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_RESPONSE_STATUS_CODE,\n ATTR_DB_SYSTEM_NAME,\n ATTR_ERROR_TYPE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n getCurrentScope,\n SDK_VERSION,\n SPAN_STATUS_ERROR,\n startSpanManual,\n} from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'PostgresJs';\nconst SUPPORTED_VERSIONS = ['>=3.0.0 <4'];\n\ntype PostgresConnectionContext = {\n ATTR_DB_NAMESPACE?: string; // Database name\n ATTR_SERVER_ADDRESS?: string; // Hostname or IP address of the database server\n ATTR_SERVER_PORT?: string; // Port number of the database server\n};\n\ntype PostgresJsInstrumentationConfig = InstrumentationConfig & {\n /**\n * Whether to require a parent span for the instrumentation.\n * If set to true, the instrumentation will only create spans if there is a parent span\n * available in the current scope.\n * @default true\n */\n requireParentSpan?: boolean;\n /**\n * Hook to modify the span before it is started.\n * This can be used to set additional attributes or modify the span in any way.\n */\n requestHook?: (span: Span, sanitizedSqlQuery: string, postgresConnectionContext?: PostgresConnectionContext) => void;\n};\n\nexport const instrumentPostgresJs = generateInstrumentOnce(\n INTEGRATION_NAME,\n (options?: PostgresJsInstrumentationConfig) =>\n new PostgresJsInstrumentation({\n requireParentSpan: options?.requireParentSpan ?? true,\n requestHook: options?.requestHook,\n }),\n);\n\n/**\n * Instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n * This instrumentation captures postgresjs queries and their attributes,\n */\nexport class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsInstrumentationConfig> {\n public constructor(config: PostgresJsInstrumentationConfig) {\n super('sentry-postgres-js', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation.\n */\n public init(): InstrumentationNodeModuleDefinition[] {\n const instrumentationModule = new InstrumentationNodeModuleDefinition('postgres', SUPPORTED_VERSIONS);\n\n ['src', 'cf/src', 'cjs/src'].forEach(path => {\n instrumentationModule.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/connection.js`,\n ['*'],\n this._patchConnection.bind(this),\n this._unwrap.bind(this),\n ),\n );\n\n instrumentationModule.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/query.js`,\n SUPPORTED_VERSIONS,\n this._patchQuery.bind(this),\n this._unwrap.bind(this),\n ),\n );\n });\n\n return [instrumentationModule];\n }\n\n /**\n * Determines whether a span should be created based on the current context.\n * If `requireParentSpan` is set to true in the configuration, a span will\n * only be created if there is a parent span available.\n */\n private _shouldCreateSpans(): boolean {\n const config = this.getConfig();\n const hasParentSpan = trace.getSpan(context.active()) !== undefined;\n return hasParentSpan || !config.requireParentSpan;\n }\n\n /**\n * Patches the reject method of the Query class to set the span status and end it\n */\n private _patchReject(rejectTarget: any, span: Span): any {\n return new Proxy(rejectTarget, {\n apply: (\n rejectTarget,\n rejectThisArg,\n rejectArgs: {\n message?: string;\n code?: string;\n name?: string;\n }[],\n ) => {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n // This message is the error message from the rejectArgs, when available\n // e.g \"relation 'User' does not exist\"\n message: rejectArgs?.[0]?.message || 'unknown_error',\n });\n\n const result = Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);\n\n // This status code is PG error code, e.g. '42P01' for \"relation does not exist\"\n // https://www.postgresql.org/docs/current/errcodes-appendix.html\n span.setAttribute(ATTR_DB_RESPONSE_STATUS_CODE, rejectArgs?.[0]?.code || 'Unknown error');\n // This is the error type, e.g. 'PostgresError' for a Postgres error\n span.setAttribute(ATTR_ERROR_TYPE, rejectArgs?.[0]?.name || 'Unknown error');\n\n span.end();\n return result;\n },\n });\n }\n\n /**\n * Patches the resolve method of the Query class to end the span when the query is resolved.\n */\n private _patchResolve(resolveTarget: any, span: Span): any {\n return new Proxy(resolveTarget, {\n apply: (resolveTarget, resolveThisArg, resolveArgs: [{ command?: string }]) => {\n const result = Reflect.apply(resolveTarget, resolveThisArg, resolveArgs);\n const sqlCommand = resolveArgs?.[0]?.command;\n\n if (sqlCommand) {\n // SQL command is only available when the query is resolved successfully\n span.setAttribute(ATTR_DB_OPERATION_NAME, sqlCommand);\n }\n span.end();\n return result;\n },\n });\n }\n\n /**\n * Patches the Query class to instrument the handle method.\n */\n private _patchQuery(moduleExports: {\n Query: {\n prototype: {\n handle: any;\n };\n };\n }): any {\n moduleExports.Query.prototype.handle = new Proxy(moduleExports.Query.prototype.handle, {\n apply: async (\n handleTarget,\n handleThisArg: {\n resolve: any;\n reject: any;\n strings?: string[];\n },\n handleArgs,\n ) => {\n if (!this._shouldCreateSpans()) {\n // If we don't need to create spans, just call the original method\n return Reflect.apply(handleTarget, handleThisArg, handleArgs);\n }\n\n const sanitizedSqlQuery = this._sanitizeSqlQuery(handleThisArg.strings?.[0]);\n\n return startSpanManual(\n {\n name: sanitizedSqlQuery || 'postgresjs.query',\n op: 'db',\n },\n (span: Span) => {\n const scope = getCurrentScope();\n const postgresConnectionContext = scope.getScopeData().contexts['postgresjsConnection'] as\n | PostgresConnectionContext\n | undefined;\n\n addOriginToSpan(span, 'auto.db.otel.postgres');\n\n const { requestHook } = this.getConfig();\n\n if (requestHook) {\n safeExecuteInTheMiddle(\n () => requestHook(span, sanitizedSqlQuery, postgresConnectionContext),\n error => {\n if (error) {\n debug.error(`Error in requestHook for ${INTEGRATION_NAME} integration:`, error);\n }\n },\n );\n }\n\n // ATTR_DB_NAMESPACE is used to indicate the database name and the schema name\n // It's only the database name as we don't have the schema information\n const databaseName = postgresConnectionContext?.ATTR_DB_NAMESPACE || '<unknown database>';\n const databaseHost = postgresConnectionContext?.ATTR_SERVER_ADDRESS || '<unknown host>';\n const databasePort = postgresConnectionContext?.ATTR_SERVER_PORT || '<unknown port>';\n\n span.setAttribute(ATTR_DB_SYSTEM_NAME, 'postgres');\n span.setAttribute(ATTR_DB_NAMESPACE, databaseName);\n span.setAttribute(ATTR_SERVER_ADDRESS, databaseHost);\n span.setAttribute(ATTR_SERVER_PORT, databasePort);\n span.setAttribute(ATTR_DB_QUERY_TEXT, sanitizedSqlQuery);\n\n handleThisArg.resolve = this._patchResolve(handleThisArg.resolve, span);\n handleThisArg.reject = this._patchReject(handleThisArg.reject, span);\n\n try {\n return Reflect.apply(handleTarget, handleThisArg, handleArgs);\n } catch (error) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n });\n span.end();\n throw error; // Re-throw the error to propagate it\n }\n },\n );\n },\n });\n\n return moduleExports;\n }\n\n /**\n * Patches the Connection class to set the database, host, and port attributes\n * when a new connection is created.\n */\n private _patchConnection(Connection: any): any {\n return new Proxy(Connection, {\n apply: (connectionTarget, thisArg, connectionArgs: { database: string; host: string[]; port: number[] }[]) => {\n const databaseName = connectionArgs[0]?.database || '<unknown database>';\n const databaseHost = connectionArgs[0]?.host?.[0] || '<unknown host>';\n const databasePort = connectionArgs[0]?.port?.[0] || '<unknown port>';\n\n const scope = getCurrentScope();\n scope.setContext('postgresjsConnection', {\n ATTR_DB_NAMESPACE: databaseName,\n ATTR_SERVER_ADDRESS: databaseHost,\n ATTR_SERVER_PORT: databasePort,\n });\n\n return Reflect.apply(connectionTarget, thisArg, connectionArgs);\n },\n });\n }\n\n /**\n * Sanitize SQL query as per the OTEL semantic conventions\n * https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext\n */\n private _sanitizeSqlQuery(sqlQuery: string | undefined): string {\n if (!sqlQuery) {\n return 'Unknown SQL Query';\n }\n\n return (\n sqlQuery\n .replace(/\\s+/g, ' ')\n .trim() // Remove extra spaces including newlines and trim\n .substring(0, 1024) // Truncate to 1024 characters\n .replace(/--.*?(\\r?\\n|$)/g, '') // Single line comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Multi-line comments\n .replace(/;\\s*$/, '') // Remove trailing semicolons\n .replace(/\\b\\d+\\b/g, '?') // Replace standalone numbers\n // Collapse whitespace to a single space\n .replace(/\\s+/g, ' ')\n // Collapse IN and in clauses\n // eg. IN (?, ?, ?, ?) to IN (?)\n .replace(/\\bIN\\b\\s*\\(\\s*\\?(?:\\s*,\\s*\\?)*\\s*\\)/g, 'IN (?)')\n );\n }\n}\n\nconst _postgresJsIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgresJs();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresJsIntegration()],\n * });\n * ```\n */\n\nexport const postgresJsIntegration = defineIntegration(_postgresJsIntegration);\n"],"names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,iBAAiB,CAAC,QAAQ,EAA8B;AAClE,IAAI,IAAI,CAAC,QAAQ,EAAE;AACnB,MAAM,OAAO,mBAAmB;AAChC;;AAEA,IAAI;AACJ,MAAM;AACN,SAAS,OAAO,CAAC,MAAM,EAAE,GAAG;AAC5B,SAAS,IAAI,EAAC;AACd,SAAS,SAAS,CAAC,CAAC,EAAE,IAAI,CAAA;AAC1B,SAAS,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAA;AACtC,SAAS,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAA;AACxC,SAAS,OAAO,CAAC,OAAO,EAAE,EAAE,CAAA;AAC5B,SAAS,OAAO,CAAC,UAAU,EAAE,GAAG,CAAA;AAChC;AACA,SAAS,OAAO,CAAC,MAAM,EAAE,GAAG;AAC5B;AACA;AACA,SAAS,OAAO,CAAC,sCAAsC,EAAE,QAAQ;AACjE;AACA;AACA;;AAEA,MAAM,sBAAA,IAA0B,MAAM;AACtC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,oBAAoB,EAAE;AAC5B,KAAK;AACL,GAAG;AACH,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;MAEa,qBAAA,GAAwB,iBAAiB,CAAC,sBAAsB;;;;"}
1
+ {"version":3,"file":"postgresjs.js","sources":["../../../../src/integrations/tracing/postgresjs.ts"],"sourcesContent":["// Instrumentation for https://github.com/porsager/postgres\nimport { context, trace } from '@opentelemetry/api';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n ATTR_DB_NAMESPACE,\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_RESPONSE_STATUS_CODE,\n ATTR_DB_SYSTEM_NAME,\n ATTR_ERROR_TYPE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n debug,\n defineIntegration,\n getCurrentScope,\n SDK_VERSION,\n SPAN_STATUS_ERROR,\n startSpanManual,\n} from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'PostgresJs';\nconst SUPPORTED_VERSIONS = ['>=3.0.0 <4'];\n\ntype PostgresConnectionContext = {\n ATTR_DB_NAMESPACE?: string; // Database name\n ATTR_SERVER_ADDRESS?: string; // Hostname or IP address of the database server\n ATTR_SERVER_PORT?: string; // Port number of the database server\n};\n\ntype PostgresJsInstrumentationConfig = InstrumentationConfig & {\n /**\n * Whether to require a parent span for the instrumentation.\n * If set to true, the instrumentation will only create spans if there is a parent span\n * available in the current scope.\n * @default true\n */\n requireParentSpan?: boolean;\n /**\n * Hook to modify the span before it is started.\n * This can be used to set additional attributes or modify the span in any way.\n */\n requestHook?: (span: Span, sanitizedSqlQuery: string, postgresConnectionContext?: PostgresConnectionContext) => void;\n};\n\nexport const instrumentPostgresJs = generateInstrumentOnce(\n INTEGRATION_NAME,\n (options?: PostgresJsInstrumentationConfig) =>\n new PostgresJsInstrumentation({\n requireParentSpan: options?.requireParentSpan ?? true,\n requestHook: options?.requestHook,\n }),\n);\n\n/**\n * Instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n * This instrumentation captures postgresjs queries and their attributes,\n */\nexport class PostgresJsInstrumentation extends InstrumentationBase<PostgresJsInstrumentationConfig> {\n public constructor(config: PostgresJsInstrumentationConfig) {\n super('sentry-postgres-js', SDK_VERSION, config);\n }\n\n /**\n * Initializes the instrumentation.\n */\n public init(): InstrumentationNodeModuleDefinition[] {\n const instrumentationModule = new InstrumentationNodeModuleDefinition('postgres', SUPPORTED_VERSIONS);\n\n ['src', 'cf/src', 'cjs/src'].forEach(path => {\n instrumentationModule.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/connection.js`,\n ['*'],\n this._patchConnection.bind(this),\n this._unwrap.bind(this),\n ),\n );\n\n instrumentationModule.files.push(\n new InstrumentationNodeModuleFile(\n `postgres/${path}/query.js`,\n SUPPORTED_VERSIONS,\n this._patchQuery.bind(this),\n this._unwrap.bind(this),\n ),\n );\n });\n\n return [instrumentationModule];\n }\n\n /**\n * Determines whether a span should be created based on the current context.\n * If `requireParentSpan` is set to true in the configuration, a span will\n * only be created if there is a parent span available.\n */\n private _shouldCreateSpans(): boolean {\n const config = this.getConfig();\n const hasParentSpan = trace.getSpan(context.active()) !== undefined;\n return hasParentSpan || !config.requireParentSpan;\n }\n\n /**\n * Patches the reject method of the Query class to set the span status and end it\n */\n private _patchReject(rejectTarget: any, span: Span): any {\n return new Proxy(rejectTarget, {\n apply: (\n rejectTarget,\n rejectThisArg,\n rejectArgs: {\n message?: string;\n code?: string;\n name?: string;\n }[],\n ) => {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n // This message is the error message from the rejectArgs, when available\n // e.g \"relation 'User' does not exist\"\n message: rejectArgs?.[0]?.message || 'internal_error',\n });\n\n const result = Reflect.apply(rejectTarget, rejectThisArg, rejectArgs);\n\n // This status code is PG error code, e.g. '42P01' for \"relation does not exist\"\n // https://www.postgresql.org/docs/current/errcodes-appendix.html\n span.setAttribute(ATTR_DB_RESPONSE_STATUS_CODE, rejectArgs?.[0]?.code || 'Unknown error');\n // This is the error type, e.g. 'PostgresError' for a Postgres error\n span.setAttribute(ATTR_ERROR_TYPE, rejectArgs?.[0]?.name || 'Unknown error');\n\n span.end();\n return result;\n },\n });\n }\n\n /**\n * Patches the resolve method of the Query class to end the span when the query is resolved.\n */\n private _patchResolve(resolveTarget: any, span: Span): any {\n return new Proxy(resolveTarget, {\n apply: (resolveTarget, resolveThisArg, resolveArgs: [{ command?: string }]) => {\n const result = Reflect.apply(resolveTarget, resolveThisArg, resolveArgs);\n const sqlCommand = resolveArgs?.[0]?.command;\n\n if (sqlCommand) {\n // SQL command is only available when the query is resolved successfully\n span.setAttribute(ATTR_DB_OPERATION_NAME, sqlCommand);\n }\n span.end();\n return result;\n },\n });\n }\n\n /**\n * Patches the Query class to instrument the handle method.\n */\n private _patchQuery(moduleExports: {\n Query: {\n prototype: {\n handle: any;\n };\n };\n }): any {\n moduleExports.Query.prototype.handle = new Proxy(moduleExports.Query.prototype.handle, {\n apply: async (\n handleTarget,\n handleThisArg: {\n resolve: any;\n reject: any;\n strings?: string[];\n },\n handleArgs,\n ) => {\n if (!this._shouldCreateSpans()) {\n // If we don't need to create spans, just call the original method\n return Reflect.apply(handleTarget, handleThisArg, handleArgs);\n }\n\n const sanitizedSqlQuery = this._sanitizeSqlQuery(handleThisArg.strings?.[0]);\n\n return startSpanManual(\n {\n name: sanitizedSqlQuery || 'postgresjs.query',\n op: 'db',\n },\n (span: Span) => {\n const scope = getCurrentScope();\n const postgresConnectionContext = scope.getScopeData().contexts['postgresjsConnection'] as\n | PostgresConnectionContext\n | undefined;\n\n addOriginToSpan(span, 'auto.db.otel.postgres');\n\n const { requestHook } = this.getConfig();\n\n if (requestHook) {\n safeExecuteInTheMiddle(\n () => requestHook(span, sanitizedSqlQuery, postgresConnectionContext),\n error => {\n if (error) {\n debug.error(`Error in requestHook for ${INTEGRATION_NAME} integration:`, error);\n }\n },\n );\n }\n\n // ATTR_DB_NAMESPACE is used to indicate the database name and the schema name\n // It's only the database name as we don't have the schema information\n const databaseName = postgresConnectionContext?.ATTR_DB_NAMESPACE || '<unknown database>';\n const databaseHost = postgresConnectionContext?.ATTR_SERVER_ADDRESS || '<unknown host>';\n const databasePort = postgresConnectionContext?.ATTR_SERVER_PORT || '<unknown port>';\n\n span.setAttribute(ATTR_DB_SYSTEM_NAME, 'postgres');\n span.setAttribute(ATTR_DB_NAMESPACE, databaseName);\n span.setAttribute(ATTR_SERVER_ADDRESS, databaseHost);\n span.setAttribute(ATTR_SERVER_PORT, databasePort);\n span.setAttribute(ATTR_DB_QUERY_TEXT, sanitizedSqlQuery);\n\n handleThisArg.resolve = this._patchResolve(handleThisArg.resolve, span);\n handleThisArg.reject = this._patchReject(handleThisArg.reject, span);\n\n try {\n return Reflect.apply(handleTarget, handleThisArg, handleArgs);\n } catch (error) {\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n });\n span.end();\n throw error; // Re-throw the error to propagate it\n }\n },\n );\n },\n });\n\n return moduleExports;\n }\n\n /**\n * Patches the Connection class to set the database, host, and port attributes\n * when a new connection is created.\n */\n private _patchConnection(Connection: any): any {\n return new Proxy(Connection, {\n apply: (connectionTarget, thisArg, connectionArgs: { database: string; host: string[]; port: number[] }[]) => {\n const databaseName = connectionArgs[0]?.database || '<unknown database>';\n const databaseHost = connectionArgs[0]?.host?.[0] || '<unknown host>';\n const databasePort = connectionArgs[0]?.port?.[0] || '<unknown port>';\n\n const scope = getCurrentScope();\n scope.setContext('postgresjsConnection', {\n ATTR_DB_NAMESPACE: databaseName,\n ATTR_SERVER_ADDRESS: databaseHost,\n ATTR_SERVER_PORT: databasePort,\n });\n\n return Reflect.apply(connectionTarget, thisArg, connectionArgs);\n },\n });\n }\n\n /**\n * Sanitize SQL query as per the OTEL semantic conventions\n * https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext\n */\n private _sanitizeSqlQuery(sqlQuery: string | undefined): string {\n if (!sqlQuery) {\n return 'Unknown SQL Query';\n }\n\n return (\n sqlQuery\n .replace(/\\s+/g, ' ')\n .trim() // Remove extra spaces including newlines and trim\n .substring(0, 1024) // Truncate to 1024 characters\n .replace(/--.*?(\\r?\\n|$)/g, '') // Single line comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '') // Multi-line comments\n .replace(/;\\s*$/, '') // Remove trailing semicolons\n .replace(/\\b\\d+\\b/g, '?') // Replace standalone numbers\n // Collapse whitespace to a single space\n .replace(/\\s+/g, ' ')\n // Collapse IN and in clauses\n // eg. IN (?, ?, ?, ?) to IN (?)\n .replace(/\\bIN\\b\\s*\\(\\s*\\?(?:\\s*,\\s*\\?)*\\s*\\)/g, 'IN (?)')\n );\n }\n}\n\nconst _postgresJsIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPostgresJs();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [postgres](https://www.npmjs.com/package/postgres) library.\n *\n * For more information, see the [`postgresIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/postgres/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.postgresJsIntegration()],\n * });\n * ```\n */\n\nexport const postgresJsIntegration = defineIntegration(_postgresJsIntegration);\n"],"names":[],"mappings":";;;;;;AAAA;;AA8BA,MAAM,gBAAA,GAAmB,YAAY;AACrC,MAAM,kBAAA,GAAqB,CAAC,YAAY,CAAC;;AAuBlC,MAAM,oBAAA,GAAuB,sBAAsB;AAC1D,EAAE,gBAAgB;AAClB,EAAE,CAAC,OAAO;AACV,IAAI,IAAI,yBAAyB,CAAC;AAClC,MAAM,iBAAiB,EAAE,OAAO,EAAE,iBAAA,IAAqB,IAAI;AAC3D,MAAM,WAAW,EAAE,OAAO,EAAE,WAAW;AACvC,KAAK,CAAC;AACN;;AAEA;AACA;AACA;AACA;AACO,MAAM,yBAAA,SAAkC,mBAAmB,CAAkC;AACpG,GAAS,WAAW,CAAC,MAAM,EAAmC;AAC9D,IAAI,KAAK,CAAC,oBAAoB,EAAE,WAAW,EAAE,MAAM,CAAC;AACpD;;AAEA;AACA;AACA;AACA,GAAS,IAAI,GAA0C;AACvD,IAAI,MAAM,wBAAwB,IAAI,mCAAmC,CAAC,UAAU,EAAE,kBAAkB,CAAC;;AAEzG,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,IAAA,IAAQ;AACjD,MAAM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C,CAAA;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;MAEa,qBAAA,GAAwB,iBAAiB,CAAC,sBAAsB;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"10.21.0","sideEffects":false}
1
+ {"type":"module","version":"10.23.0","sideEffects":false}
@@ -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 type { 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 type { 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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AACnH,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;A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ACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,QAAQ,EACR,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,GACxB,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,uBAAuB,GACxB,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,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,GAC3B,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AACnH,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC9F,OAAO,E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,EAChB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EACxB,YAAY,EACZ,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,EACT,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,QAAQ,EACR,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,8BAA8B,GAC/B,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,uBAAuB,GACxB,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,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,GAC3B,MAAM,mBAAmB,CAAC"}
@@ -1,4 +1,5 @@
1
- interface NodeFetchOptions {
1
+ import type { 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
@@ -1 +1 @@
1
- {"version":3,"file":"node-fetch.d.ts","sourceRoot":"","sources":["../../../src/integrations/node-fetch.ts"],"names":[],"mappings":"AAUA,UAAU,gBAAgB;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CACnD;AAqCD,eAAO,MAAM,0BAA0B,gFAAiD,CAAC"}
1
+ {"version":3,"file":"node-fetch.d.ts","sourceRoot":"","sources":["../../../src/integrations/node-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AAUzF,UAAU,gBAAiB,SAAQ,IAAI,CAAC,2BAA2B,EAAE,aAAa,GAAG,cAAc,CAAC;IAClG;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CACnD;AAqCD,eAAO,MAAM,0BAA0B,gFAAiD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/firebase/firebase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsC,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AAYrF,eAAO,MAAM,kBAAkB;;CAAsF,CAAC;AAWtH,eAAO,MAAM,mBAAmB,0CAA0C,CAAC"}
1
+ {"version":3,"file":"firebase.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/firebase/firebase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsC,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AA8BrF,eAAO,MAAM,kBAAkB;;CAAsF,CAAC;AAWtH,eAAO,MAAM,mBAAmB,0CAA0C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"firebaseInstrumentation.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/firebase/otel/firebaseInstrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mCAAmC,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG/G,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAK7D;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,mBAAmB,CAAC,6BAA6B,CAAC;gBAC1E,MAAM,GAAE,6BAAoE;IAI/F;;;OAGG;IACa,SAAS,CAAC,MAAM,GAAE,6BAAkC,GAAG,IAAI;IAI3E;;;OAGG;IAEH,SAAS,CAAC,IAAI,IAAI,mCAAmC,GAAG,mCAAmC,EAAE,GAAG,IAAI;CAOrG"}
1
+ {"version":3,"file":"firebaseInstrumentation.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/firebase/otel/firebaseInstrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mCAAmC,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAI/G,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAM7D;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,mBAAmB,CAAC,6BAA6B,CAAC;gBAC1E,MAAM,GAAE,6BAAoE;IAI/F;;;OAGG;IACa,SAAS,CAAC,MAAM,GAAE,6BAAkC,GAAG,IAAI;IAI3E;;;OAGG;IAEH,SAAS,CAAC,IAAI,IAAI,mCAAmC,GAAG,mCAAmC,EAAE,GAAG,IAAI;CAQrG"}
@@ -0,0 +1,23 @@
1
+ import type { Tracer } from '@opentelemetry/api';
2
+ import type { InstrumentationBase } from '@opentelemetry/instrumentation';
3
+ import { InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
4
+ import type { 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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../../../../../src/integrations/tracing/firebase/otel/patches/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACL,mCAAmC,EAIpC,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EAEV,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EAGrB,MAAM,UAAU,CAAC;AAElB;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,0BAA0B,EAAE,MAAM,EAAE,EACpC,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAClC,MAAM,EAAE,mBAAmB,CAAC,SAAS,CAAC,EACtC,MAAM,EAAE,6BAA6B,GACpC,mCAAmC,CAgErC;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,EAC9E,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,6BAA6B,CAAC,WAAW,CAAC,EAC3D,WAAW,EAAE,MAAM,GAClB,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAqEtE"}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/firebase/otel/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAG5E,MAAM,WAAW,eAAe;IAC9B,CAAC,GA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AAO,CAAC,EAC9D,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,KACtC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AAE7D,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,gCAAgC,EAAE,iBAAiB,CAAC;IACpD,gCAAgC,EAAE,iBAAiB,CAAC;IACpD,gCAAgC,EAAE,iBAAiB,CAAC;IACpD,gCAAgC,EAAE,iBAAiB,CAAC;IACpD,UAAU,EAAE,iBAAiB,CAAC;IAC9B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,eAAe,EAAE,iBAAiB,CAAC;IACnC,uBAAuB,EAAE,iBAAiB,CAAC;CAC5C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA4BhD;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,EAAE,CA4B9D;AAED;;GAEG;AAEH,wBAAgB,wCAAwC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CA+BzG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA6BhD;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,EAAE,CA6B9D;AAED;;GAEG;AAEH,wBAAgB,wCAAwC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CAgCzG"}
@@ -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