@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
@@ -29,15 +29,16 @@ const index$3 = require('./integrations/tracing/vercelai/index.js');
29
29
  const index$4 = require('./integrations/tracing/openai/index.js');
30
30
  const index$5 = require('./integrations/tracing/anthropic-ai/index.js');
31
31
  const index$6 = require('./integrations/tracing/google-genai/index.js');
32
+ const index$7 = require('./integrations/tracing/langchain/index.js');
32
33
  const launchDarkly = require('./integrations/featureFlagShims/launchDarkly.js');
33
34
  const openFeature = require('./integrations/featureFlagShims/openFeature.js');
34
35
  const statsig = require('./integrations/featureFlagShims/statsig.js');
35
36
  const unleash = require('./integrations/featureFlagShims/unleash.js');
36
37
  const growthbook = require('./integrations/featureFlagShims/growthbook.js');
37
38
  const firebase = require('./integrations/tracing/firebase/firebase.js');
38
- const index$7 = require('./sdk/index.js');
39
+ const index$8 = require('./sdk/index.js');
39
40
  const initOtel = require('./sdk/initOtel.js');
40
- const index$8 = require('./integrations/tracing/index.js');
41
+ const index$9 = require('./integrations/tracing/index.js');
41
42
  const opentelemetry = require('@sentry/opentelemetry');
42
43
  const core = require('@sentry/core');
43
44
  const nodeCore = require('@sentry/node-core');
@@ -80,6 +81,7 @@ exports.vercelAIIntegration = index$3.vercelAIIntegration;
80
81
  exports.openAIIntegration = index$4.openAIIntegration;
81
82
  exports.anthropicAIIntegration = index$5.anthropicAIIntegration;
82
83
  exports.googleGenAIIntegration = index$6.googleGenAIIntegration;
84
+ exports.langChainIntegration = index$7.langChainIntegration;
83
85
  exports.buildLaunchDarklyFlagUsedHandler = launchDarkly.buildLaunchDarklyFlagUsedHandlerShim;
84
86
  exports.launchDarklyIntegration = launchDarkly.launchDarklyIntegrationShim;
85
87
  exports.OpenFeatureIntegrationHook = openFeature.OpenFeatureIntegrationHookShim;
@@ -88,13 +90,13 @@ exports.statsigIntegration = statsig.statsigIntegrationShim;
88
90
  exports.unleashIntegration = unleash.unleashIntegrationShim;
89
91
  exports.growthbookIntegration = growthbook.growthbookIntegrationShim;
90
92
  exports.firebaseIntegration = firebase.firebaseIntegration;
91
- exports.getDefaultIntegrations = index$7.getDefaultIntegrations;
92
- exports.getDefaultIntegrationsWithoutPerformance = index$7.getDefaultIntegrationsWithoutPerformance;
93
- exports.init = index$7.init;
94
- exports.initWithoutDefaultIntegrations = index$7.initWithoutDefaultIntegrations;
93
+ exports.getDefaultIntegrations = index$8.getDefaultIntegrations;
94
+ exports.getDefaultIntegrationsWithoutPerformance = index$8.getDefaultIntegrationsWithoutPerformance;
95
+ exports.init = index$8.init;
96
+ exports.initWithoutDefaultIntegrations = index$8.initWithoutDefaultIntegrations;
95
97
  exports.initOpenTelemetry = initOtel.initOpenTelemetry;
96
98
  exports.preloadOpenTelemetry = initOtel.preloadOpenTelemetry;
97
- exports.getAutoPerformanceIntegrations = index$8.getAutoPerformanceIntegrations;
99
+ exports.getAutoPerformanceIntegrations = index$9.getAutoPerformanceIntegrations;
98
100
  exports.setNodeAsyncContextStrategy = opentelemetry.setOpenTelemetryContextAsyncContextStrategy;
99
101
  exports.SDK_VERSION = core.SDK_VERSION;
100
102
  exports.SEMANTIC_ATTRIBUTE_SENTRY_OP = core.SEMANTIC_ATTRIBUTE_SENTRY_OP;
@@ -117,6 +119,7 @@ exports.consoleIntegration = core.consoleIntegration;
117
119
  exports.consoleLoggingIntegration = core.consoleLoggingIntegration;
118
120
  exports.continueTrace = core.continueTrace;
119
121
  exports.createConsolaReporter = core.createConsolaReporter;
122
+ exports.createLangChainCallbackHandler = core.createLangChainCallbackHandler;
120
123
  exports.createTransport = core.createTransport;
121
124
  exports.dedupeIntegration = core.dedupeIntegration;
122
125
  exports.endSession = core.endSession;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -81,6 +81,8 @@ function getConfigWithDefaults(options = {}) {
81
81
  [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.node_fetch',
82
82
  };
83
83
  },
84
+ requestHook: options.requestHook,
85
+ responseHook: options.responseHook,
84
86
  } ;
85
87
 
86
88
  return instrumentationConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"node-fetch.js","sources":["../../../src/integrations/node-fetch.ts"],"sourcesContent":["import type { UndiciInstrumentationConfig } from '@opentelemetry/instrumentation-undici';\nimport { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, getClient, hasSpansEnabled, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';\nimport type { NodeClient } from '@sentry/node-core';\nimport { generateInstrumentOnce, SentryNodeFetchInstrumentation } from '@sentry/node-core';\nimport type { NodeClientOptions } from '../types';\n\nconst INTEGRATION_NAME = 'NodeFetch';\n\ninterface NodeFetchOptions {\n /**\n * Whether breadcrumbs should be recorded for requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default UndiciInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for breadcrumbs & trace propagation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing fetch requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n */\n ignoreOutgoingRequests?: (url: string) => boolean;\n}\n\nconst instrumentOtelNodeFetch = generateInstrumentOnce(\n INTEGRATION_NAME,\n UndiciInstrumentation,\n (options: NodeFetchOptions) => {\n return getConfigWithDefaults(options);\n },\n);\n\nconst instrumentSentryNodeFetch = generateInstrumentOnce(\n `${INTEGRATION_NAME}.sentry`,\n SentryNodeFetchInstrumentation,\n (options: NodeFetchOptions) => {\n return options;\n },\n);\n\nconst _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {\n return {\n name: 'NodeFetch',\n setupOnce() {\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n instrumentOtelNodeFetch(options);\n }\n\n // This is the Sentry-specific instrumentation that creates breadcrumbs & propagates traces\n // This must be registered after the OTEL one, to ensure that the core trace propagation logic takes presedence\n // Otherwise, the sentry-trace header may be set multiple times\n instrumentSentryNodeFetch(options);\n },\n };\n}) satisfies IntegrationFn;\n\nexport const nativeNodeFetchIntegration = defineIntegration(_nativeNodeFetchIntegration);\n\n// Matching the behavior of the base instrumentation\nfunction getAbsoluteUrl(origin: string, path: string = '/'): string {\n const url = `${origin}`;\n\n if (url.endsWith('/') && path.startsWith('/')) {\n return `${url}${path.slice(1)}`;\n }\n\n if (!url.endsWith('/') && !path.startsWith('/')) {\n return `${url}/${path.slice(1)}`;\n }\n\n return `${url}${path}`;\n}\n\nfunction _shouldInstrumentSpans(options: NodeFetchOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true` or spans are not enabled\n return typeof options.spans === 'boolean'\n ? options.spans\n : !clientOptions.skipOpenTelemetrySetup && hasSpansEnabled(clientOptions);\n}\n\nfunction getConfigWithDefaults(options: Partial<NodeFetchOptions> = {}): UndiciInstrumentationConfig {\n const instrumentationConfig = {\n requireParentforSpans: false,\n ignoreRequestHook: request => {\n const url = getAbsoluteUrl(request.origin, request.path);\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n const shouldIgnore = _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url);\n\n return !!shouldIgnore;\n },\n startSpanHook: () => {\n return {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.node_fetch',\n };\n },\n } satisfies UndiciInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":["generateInstrumentOnce","UndiciInstrumentation","SentryNodeFetchInstrumentation","getClient","defineIntegration","hasSpansEnabled","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;AAQA,MAAM,gBAAA,GAAmB,WAAW;;AAyBpC,MAAM,uBAAA,GAA0BA,+BAAsB;AACtD,EAAE,gBAAgB;AAClB,EAAEC,2CAAqB;AACvB,EAAE,CAAC,OAAO,KAAuB;AACjC,IAAI,OAAO,qBAAqB,CAAC,OAAO,CAAC;AACzC,GAAG;AACH,CAAC;;AAED,MAAM,yBAAA,GAA4BD,+BAAsB;AACxD,EAAE,CAAC,EAAA,gBAAA,CAAA,OAAA,CAAA;AACA,EAAAE,uCAAA;AACA,EAAA,CAAA,OAAA,KAAA;AACA,IAAA,OAAA,OAAA;AACA,GAAA;AACA,CAAA;;AAEA,MAAA,2BAAA,IAAA,CAAA,OAAA,GAAA,EAAA,KAAA;AACA,EAAA,OAAA;AACA,IAAA,IAAA,EAAA,WAAA;AACA,IAAA,SAAA,GAAA;AACA,MAAA,MAAA,eAAA,GAAA,sBAAA,CAAA,OAAA,EAAAC,cAAA,EAAA,EAAA,UAAA,EAAA,CAAA;;AAEA;AACA,MAAA,IAAA,eAAA,EAAA;AACA,QAAA,uBAAA,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AA;AACA,MAAA,MAAA,uBAAA,GAAA,OAAA,CAAA,sBAAA;AACA,MAAA,MAAA,YAAA,GAAA,uBAAA,IAAA,GAAA,IAAA,uBAAA,CAAA,GAAA,CAAA;;AAEA,MAAA,OAAA,CAAA,CAAA,YAAA;AACA,KAAA;AACA,IAAA,aAAA,EAAA,MAAA;AACA,MAAA,OAAA;AACA,QAAA,CAAAC,qCAAA,GAAA,2BAAA;AACA,OAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAA,OAAA,qBAAA;AACA;;;;"}
1
+ {"version":3,"file":"node-fetch.js","sources":["../../../src/integrations/node-fetch.ts"],"sourcesContent":["import type { UndiciInstrumentationConfig } from '@opentelemetry/instrumentation-undici';\nimport { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, getClient, hasSpansEnabled, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';\nimport type { NodeClient } from '@sentry/node-core';\nimport { generateInstrumentOnce, SentryNodeFetchInstrumentation } from '@sentry/node-core';\nimport type { NodeClientOptions } from '../types';\n\nconst INTEGRATION_NAME = 'NodeFetch';\n\ninterface NodeFetchOptions extends Pick<UndiciInstrumentationConfig, 'requestHook' | 'responseHook'> {\n /**\n * Whether breadcrumbs should be recorded for requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default UndiciInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for breadcrumbs & trace propagation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing fetch requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n */\n ignoreOutgoingRequests?: (url: string) => boolean;\n}\n\nconst instrumentOtelNodeFetch = generateInstrumentOnce(\n INTEGRATION_NAME,\n UndiciInstrumentation,\n (options: NodeFetchOptions) => {\n return getConfigWithDefaults(options);\n },\n);\n\nconst instrumentSentryNodeFetch = generateInstrumentOnce(\n `${INTEGRATION_NAME}.sentry`,\n SentryNodeFetchInstrumentation,\n (options: NodeFetchOptions) => {\n return options;\n },\n);\n\nconst _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {\n return {\n name: 'NodeFetch',\n setupOnce() {\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n instrumentOtelNodeFetch(options);\n }\n\n // This is the Sentry-specific instrumentation that creates breadcrumbs & propagates traces\n // This must be registered after the OTEL one, to ensure that the core trace propagation logic takes presedence\n // Otherwise, the sentry-trace header may be set multiple times\n instrumentSentryNodeFetch(options);\n },\n };\n}) satisfies IntegrationFn;\n\nexport const nativeNodeFetchIntegration = defineIntegration(_nativeNodeFetchIntegration);\n\n// Matching the behavior of the base instrumentation\nfunction getAbsoluteUrl(origin: string, path: string = '/'): string {\n const url = `${origin}`;\n\n if (url.endsWith('/') && path.startsWith('/')) {\n return `${url}${path.slice(1)}`;\n }\n\n if (!url.endsWith('/') && !path.startsWith('/')) {\n return `${url}/${path.slice(1)}`;\n }\n\n return `${url}${path}`;\n}\n\nfunction _shouldInstrumentSpans(options: NodeFetchOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true` or spans are not enabled\n return typeof options.spans === 'boolean'\n ? options.spans\n : !clientOptions.skipOpenTelemetrySetup && hasSpansEnabled(clientOptions);\n}\n\nfunction getConfigWithDefaults(options: Partial<NodeFetchOptions> = {}): UndiciInstrumentationConfig {\n const instrumentationConfig = {\n requireParentforSpans: false,\n ignoreRequestHook: request => {\n const url = getAbsoluteUrl(request.origin, request.path);\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n const shouldIgnore = _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url);\n\n return !!shouldIgnore;\n },\n startSpanHook: () => {\n return {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.node_fetch',\n };\n },\n requestHook: options.requestHook,\n responseHook: options.responseHook,\n } satisfies UndiciInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":["generateInstrumentOnce","UndiciInstrumentation","SentryNodeFetchInstrumentation","getClient","defineIntegration","hasSpansEnabled","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;AAQA,MAAM,gBAAA,GAAmB,WAAW;;AAyBpC,MAAM,uBAAA,GAA0BA,+BAAsB;AACtD,EAAE,gBAAgB;AAClB,EAAEC,2CAAqB;AACvB,EAAE,CAAC,OAAO,KAAuB;AACjC,IAAI,OAAO,qBAAqB,CAAC,OAAO,CAAC;AACzC,GAAG;AACH,CAAC;;AAED,MAAM,yBAAA,GAA4BD,+BAAsB;AACxD,EAAE,CAAC,EAAA,gBAAA,CAAA,OAAA,CAAA;AACA,EAAAE,uCAAA;AACA,EAAA,CAAA,OAAA,KAAA;AACA,IAAA,OAAA,OAAA;AACA,GAAA;AACA,CAAA;;AAEA,MAAA,2BAAA,IAAA,CAAA,OAAA,GAAA,EAAA,KAAA;AACA,EAAA,OAAA;AACA,IAAA,IAAA,EAAA,WAAA;AACA,IAAA,SAAA,GAAA;AACA,MAAA,MAAA,eAAA,GAAA,sBAAA,CAAA,OAAA,EAAAC,cAAA,EAAA,EAAA,UAAA,EAAA,CAAA;;AAEA;AACA,MAAA,IAAA,eAAA,EAAA;AACA,QAAA,uBAAA,CAAA,OAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA,MAAA,yBAAA,CAAA,OAAA,CAAA;AACA,KAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA,MAAA,0BAAA,GAAAC,sBAAA,CAAA,2BAAA;;AAEA;AACA,SAAA,cAAA,CAAA,MAAA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EAAA,MAAA;AACA,MAAA,OAAA;AACA,QAAA,CAAAC,qCAAA,GAAA,2BAAA;AACA,OAAA;AACA,KAAA;AACA,IAAA,WAAA,EAAA,OAAA,CAAA,WAAA;AACA,IAAA,YAAA,EAAA,OAAA,CAAA,YAAA;AACA,GAAA;;AAEA,EAAA,OAAA,qBAAA;AACA;;;;"}
@@ -12,6 +12,24 @@ const config = {
12
12
 
13
13
  span.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_OP, 'db.query');
14
14
  },
15
+ functions: {
16
+ requestHook: span => {
17
+ nodeCore.addOriginToSpan(span, 'auto.firebase.otel.functions');
18
+
19
+ span.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_OP, 'http.request');
20
+ },
21
+ errorHook: async (_, error) => {
22
+ if (error) {
23
+ core.captureException(error, {
24
+ mechanism: {
25
+ type: 'auto.firebase.otel.functions',
26
+ handled: false,
27
+ },
28
+ });
29
+ await core.flush(2000);
30
+ }
31
+ },
32
+ },
15
33
  };
16
34
 
17
35
  const instrumentFirebase = nodeCore.generateInstrumentOnce(INTEGRATION_NAME, () => new firebaseInstrumentation.FirebaseInstrumentation(config));
@@ -1 +1 @@
1
- {"version":3,"file":"firebase.js","sources":["../../../../../src/integrations/tracing/firebase/firebase.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\nimport { type FirebaseInstrumentationConfig, FirebaseInstrumentation } from './otel';\n\nconst INTEGRATION_NAME = 'Firebase';\n\nconst config: FirebaseInstrumentationConfig = {\n firestoreSpanCreationHook: span => {\n addOriginToSpan(span, 'auto.firebase.otel.firestore');\n\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'db.query');\n },\n};\n\nexport const instrumentFirebase = generateInstrumentOnce(INTEGRATION_NAME, () => new FirebaseInstrumentation(config));\n\nconst _firebaseIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentFirebase();\n },\n };\n}) satisfies IntegrationFn;\n\nexport const firebaseIntegration = defineIntegration(_firebaseIntegration);\n"],"names":["addOriginToSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","generateInstrumentOnce","FirebaseInstrumentation","defineIntegration"],"mappings":";;;;;;AAKA,MAAM,gBAAA,GAAmB,UAAU;;AAEnC,MAAM,MAAM,GAAkC;AAC9C,EAAE,yBAAyB,EAAE,IAAA,IAAQ;AACrC,IAAIA,wBAAe,CAAC,IAAI,EAAE,8BAA8B,CAAC;;AAEzD,IAAI,IAAI,CAAC,YAAY,CAACC,iCAA4B,EAAE,UAAU,CAAC;AAC/D,GAAG;AACH,CAAC;;AAEM,MAAM,kBAAA,GAAqBC,+BAAsB,CAAC,gBAAgB,EAAE,MAAM,IAAIC,+CAAuB,CAAC,MAAM,CAAC;;AAEpH,MAAM,oBAAA,IAAwB,MAAM;AACpC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,kBAAkB,EAAE;AAC1B,KAAK;AACL,GAAG;AACH,CAAC,CAAA;;MAEY,mBAAA,GAAsBC,sBAAiB,CAAC,oBAAoB;;;;;"}
1
+ {"version":3,"file":"firebase.js","sources":["../../../../../src/integrations/tracing/firebase/firebase.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { captureException, defineIntegration, flush, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';\nimport { addOriginToSpan, generateInstrumentOnce } from '@sentry/node-core';\nimport { type FirebaseInstrumentationConfig, FirebaseInstrumentation } from './otel';\n\nconst INTEGRATION_NAME = 'Firebase';\n\nconst config: FirebaseInstrumentationConfig = {\n firestoreSpanCreationHook: span => {\n addOriginToSpan(span, 'auto.firebase.otel.firestore');\n\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'db.query');\n },\n functions: {\n requestHook: span => {\n addOriginToSpan(span, 'auto.firebase.otel.functions');\n\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, 'http.request');\n },\n errorHook: async (_, error) => {\n if (error) {\n captureException(error, {\n mechanism: {\n type: 'auto.firebase.otel.functions',\n handled: false,\n },\n });\n await flush(2000);\n }\n },\n },\n};\n\nexport const instrumentFirebase = generateInstrumentOnce(INTEGRATION_NAME, () => new FirebaseInstrumentation(config));\n\nconst _firebaseIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentFirebase();\n },\n };\n}) satisfies IntegrationFn;\n\nexport const firebaseIntegration = defineIntegration(_firebaseIntegration);\n"],"names":["addOriginToSpan","SEMANTIC_ATTRIBUTE_SENTRY_OP","captureException","flush","generateInstrumentOnce","FirebaseInstrumentation","defineIntegration"],"mappings":";;;;;;AAKA,MAAM,gBAAA,GAAmB,UAAU;;AAEnC,MAAM,MAAM,GAAkC;AAC9C,EAAE,yBAAyB,EAAE,IAAA,IAAQ;AACrC,IAAIA,wBAAe,CAAC,IAAI,EAAE,8BAA8B,CAAC;;AAEzD,IAAI,IAAI,CAAC,YAAY,CAACC,iCAA4B,EAAE,UAAU,CAAC;AAC/D,GAAG;AACH,EAAE,SAAS,EAAE;AACb,IAAI,WAAW,EAAE,IAAA,IAAQ;AACzB,MAAMD,wBAAe,CAAC,IAAI,EAAE,8BAA8B,CAAC;;AAE3D,MAAM,IAAI,CAAC,YAAY,CAACC,iCAA4B,EAAE,cAAc,CAAC;AACrE,KAAK;AACL,IAAI,SAAS,EAAE,OAAO,CAAC,EAAE,KAAK,KAAK;AACnC,MAAM,IAAI,KAAK,EAAE;AACjB,QAAQC,qBAAgB,CAAC,KAAK,EAAE;AAChC,UAAU,SAAS,EAAE;AACrB,YAAY,IAAI,EAAE,8BAA8B;AAChD,YAAY,OAAO,EAAE,KAAK;AAC1B,WAAW;AACX,SAAS,CAAC;AACV,QAAQ,MAAMC,UAAK,CAAC,IAAI,CAAC;AACzB;AACA,KAAK;AACL,GAAG;AACH,CAAC;;AAEM,MAAM,kBAAA,GAAqBC,+BAAsB,CAAC,gBAAgB,EAAE,MAAM,IAAIC,+CAAuB,CAAC,MAAM,CAAC;;AAEpH,MAAM,oBAAA,IAAwB,MAAM;AACpC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,kBAAkB,EAAE;AAC1B,KAAK;AACL,GAAG;AACH,CAAC,CAAA;;MAEY,mBAAA,GAAsBC,sBAAiB,CAAC,oBAAoB;;;;;"}
@@ -3,9 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const instrumentation = require('@opentelemetry/instrumentation');
4
4
  const core = require('@sentry/core');
5
5
  const firestore = require('./patches/firestore.js');
6
+ const functions = require('./patches/functions.js');
6
7
 
7
8
  const DefaultFirebaseInstrumentationConfig = {};
8
9
  const firestoreSupportedVersions = ['>=3.0.0 <5']; // firebase 9+
10
+ const functionsSupportedVersions = ['>=6.0.0 <7']; // firebase-functions v2
9
11
 
10
12
  /**
11
13
  * Instrumentation for Firebase services, specifically Firestore.
@@ -32,6 +34,7 @@ class FirebaseInstrumentation extends instrumentation.InstrumentationBase {
32
34
  const modules = [];
33
35
 
34
36
  modules.push(firestore.patchFirestore(this.tracer, firestoreSupportedVersions, this._wrap, this._unwrap, this.getConfig()));
37
+ modules.push(functions.patchFunctions(this.tracer, functionsSupportedVersions, this._wrap, this._unwrap, this.getConfig()));
35
38
 
36
39
  return modules;
37
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"firebaseInstrumentation.js","sources":["../../../../../../src/integrations/tracing/firebase/otel/firebaseInstrumentation.ts"],"sourcesContent":["import { type InstrumentationNodeModuleDefinition, InstrumentationBase } from '@opentelemetry/instrumentation';\nimport { SDK_VERSION } from '@sentry/core';\nimport { patchFirestore } from './patches/firestore';\nimport type { FirebaseInstrumentationConfig } from './types';\n\nconst DefaultFirebaseInstrumentationConfig: FirebaseInstrumentationConfig = {};\nconst firestoreSupportedVersions = ['>=3.0.0 <5']; // firebase 9+\n\n/**\n * Instrumentation for Firebase services, specifically Firestore.\n */\nexport class FirebaseInstrumentation extends InstrumentationBase<FirebaseInstrumentationConfig> {\n public constructor(config: FirebaseInstrumentationConfig = DefaultFirebaseInstrumentationConfig) {\n super('@sentry/instrumentation-firebase', SDK_VERSION, config);\n }\n\n /**\n * sets config\n * @param config\n */\n public override setConfig(config: FirebaseInstrumentationConfig = {}): void {\n super.setConfig({ ...DefaultFirebaseInstrumentationConfig, ...config });\n }\n\n /**\n *\n * @protected\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected init(): InstrumentationNodeModuleDefinition | InstrumentationNodeModuleDefinition[] | void {\n const modules: InstrumentationNodeModuleDefinition[] = [];\n\n modules.push(patchFirestore(this.tracer, firestoreSupportedVersions, this._wrap, this._unwrap, this.getConfig()));\n\n return modules;\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","patchFirestore"],"mappings":";;;;;;AAKA,MAAM,oCAAoC,GAAkC,EAAE;AAC9E,MAAM,0BAAA,GAA6B,CAAC,YAAY,CAAC,CAAA;;AAEjD;AACA;AACA;AACO,MAAM,uBAAA,SAAgCA,mCAAmB,CAAgC;AAChG,GAAS,WAAW,CAAC,MAAM,GAAkC,oCAAoC,EAAE;AACnG,IAAI,KAAK,CAAC,kCAAkC,EAAEC,gBAAW,EAAE,MAAM,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA,IAAkB,SAAS,CAAC,MAAM,GAAkC,EAAE,EAAQ;AAC9E,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,oCAAoC,EAAE,GAAG,MAAA,EAAQ,CAAC;AAC3E;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAY,IAAI,GAAuF;AACvG,IAAI,MAAM,OAAO,GAA0C,EAAE;;AAE7D,IAAI,OAAO,CAAC,IAAI,CAACC,wBAAc,CAAC,IAAI,CAAC,MAAM,EAAE,0BAA0B,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;;AAErH,IAAI,OAAO,OAAO;AAClB;AACA;;;;"}
1
+ {"version":3,"file":"firebaseInstrumentation.js","sources":["../../../../../../src/integrations/tracing/firebase/otel/firebaseInstrumentation.ts"],"sourcesContent":["import { type InstrumentationNodeModuleDefinition, InstrumentationBase } from '@opentelemetry/instrumentation';\nimport { SDK_VERSION } from '@sentry/core';\nimport { patchFirestore } from './patches/firestore';\nimport { patchFunctions } from './patches/functions';\nimport type { FirebaseInstrumentationConfig } from './types';\n\nconst DefaultFirebaseInstrumentationConfig: FirebaseInstrumentationConfig = {};\nconst firestoreSupportedVersions = ['>=3.0.0 <5']; // firebase 9+\nconst functionsSupportedVersions = ['>=6.0.0 <7']; // firebase-functions v2\n\n/**\n * Instrumentation for Firebase services, specifically Firestore.\n */\nexport class FirebaseInstrumentation extends InstrumentationBase<FirebaseInstrumentationConfig> {\n public constructor(config: FirebaseInstrumentationConfig = DefaultFirebaseInstrumentationConfig) {\n super('@sentry/instrumentation-firebase', SDK_VERSION, config);\n }\n\n /**\n * sets config\n * @param config\n */\n public override setConfig(config: FirebaseInstrumentationConfig = {}): void {\n super.setConfig({ ...DefaultFirebaseInstrumentationConfig, ...config });\n }\n\n /**\n *\n * @protected\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n protected init(): InstrumentationNodeModuleDefinition | InstrumentationNodeModuleDefinition[] | void {\n const modules: InstrumentationNodeModuleDefinition[] = [];\n\n modules.push(patchFirestore(this.tracer, firestoreSupportedVersions, this._wrap, this._unwrap, this.getConfig()));\n modules.push(patchFunctions(this.tracer, functionsSupportedVersions, this._wrap, this._unwrap, this.getConfig()));\n\n return modules;\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","patchFirestore","patchFunctions"],"mappings":";;;;;;;AAMA,MAAM,oCAAoC,GAAkC,EAAE;AAC9E,MAAM,0BAAA,GAA6B,CAAC,YAAY,CAAC,CAAA;AACjD,MAAM,0BAAA,GAA6B,CAAC,YAAY,CAAC,CAAA;;AAEjD;AACA;AACA;AACO,MAAM,uBAAA,SAAgCA,mCAAmB,CAAgC;AAChG,GAAS,WAAW,CAAC,MAAM,GAAkC,oCAAoC,EAAE;AACnG,IAAI,KAAK,CAAC,kCAAkC,EAAEC,gBAAW,EAAE,MAAM,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA,IAAkB,SAAS,CAAC,MAAM,GAAkC,EAAE,EAAQ;AAC9E,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,oCAAoC,EAAE,GAAG,MAAA,EAAQ,CAAC;AAC3E;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAY,IAAI,GAAuF;AACvG,IAAI,MAAM,OAAO,GAA0C,EAAE;;AAE7D,IAAI,OAAO,CAAC,IAAI,CAACC,wBAAc,CAAC,IAAI,CAAC,MAAM,EAAE,0BAA0B,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;AACrH,IAAI,OAAO,CAAC,IAAI,CAACC,wBAAc,CAAC,IAAI,CAAC,MAAM,EAAE,0BAA0B,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;;AAErH,IAAI,OAAO,OAAO;AAClB;AACA;;;;"}
@@ -0,0 +1,265 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const api = require('@opentelemetry/api');
4
+ const instrumentation = require('@opentelemetry/instrumentation');
5
+
6
+ /**
7
+ * Patches Firebase Functions v2 to add OpenTelemetry instrumentation
8
+ * @param tracer - Opentelemetry Tracer
9
+ * @param functionsSupportedVersions - supported versions of firebase-functions
10
+ * @param wrap - reference to native instrumentation wrap function
11
+ * @param unwrap - reference to native instrumentation unwrap function
12
+ * @param config - Firebase instrumentation config
13
+ */
14
+ function patchFunctions(
15
+ tracer,
16
+ functionsSupportedVersions,
17
+ wrap,
18
+ unwrap,
19
+ config,
20
+ ) {
21
+ let requestHook = () => {};
22
+ let responseHook = () => {};
23
+ const errorHook = config.functions?.errorHook;
24
+ const configRequestHook = config.functions?.requestHook;
25
+ const configResponseHook = config.functions?.responseHook;
26
+
27
+ if (typeof configResponseHook === 'function') {
28
+ responseHook = (span, err) => {
29
+ instrumentation.safeExecuteInTheMiddle(
30
+ () => configResponseHook(span, err),
31
+ error => {
32
+ if (!error) {
33
+ return;
34
+ }
35
+ api.diag.error(error?.message);
36
+ },
37
+ true,
38
+ );
39
+ };
40
+ }
41
+ if (typeof configRequestHook === 'function') {
42
+ requestHook = (span) => {
43
+ instrumentation.safeExecuteInTheMiddle(
44
+ () => configRequestHook(span),
45
+ error => {
46
+ if (!error) {
47
+ return;
48
+ }
49
+ api.diag.error(error?.message);
50
+ },
51
+ true,
52
+ );
53
+ };
54
+ }
55
+
56
+ const moduleFunctionsCJS = new instrumentation.InstrumentationNodeModuleDefinition('firebase-functions', functionsSupportedVersions);
57
+ const modulesToInstrument = [
58
+ { name: 'firebase-functions/lib/v2/providers/https.js', triggerType: 'function' },
59
+ { name: 'firebase-functions/lib/v2/providers/firestore.js', triggerType: 'firestore' },
60
+ { name: 'firebase-functions/lib/v2/providers/scheduler.js', triggerType: 'scheduler' },
61
+ { name: 'firebase-functions/lib/v2/storage.js', triggerType: 'storage' },
62
+ ] ;
63
+
64
+ modulesToInstrument.forEach(({ name, triggerType }) => {
65
+ moduleFunctionsCJS.files.push(
66
+ new instrumentation.InstrumentationNodeModuleFile(
67
+ name,
68
+ functionsSupportedVersions,
69
+ moduleExports =>
70
+ wrapCommonFunctions(
71
+ moduleExports,
72
+ wrap,
73
+ unwrap,
74
+ tracer,
75
+ { requestHook, responseHook, errorHook },
76
+ triggerType,
77
+ ),
78
+ moduleExports => unwrapCommonFunctions(moduleExports, unwrap),
79
+ ),
80
+ );
81
+ });
82
+
83
+ return moduleFunctionsCJS;
84
+ }
85
+
86
+ /**
87
+ * Patches Cloud Functions for Firebase (v2) to add OpenTelemetry instrumentation
88
+ *
89
+ * @param tracer - Opentelemetry Tracer
90
+ * @param functionsConfig - Firebase instrumentation config
91
+ * @param triggerType - Type of trigger
92
+ * @returns A function that patches the function
93
+ */
94
+ function patchV2Functions(
95
+ tracer,
96
+ functionsConfig,
97
+ triggerType,
98
+ ) {
99
+ return function v2FunctionsWrapper(original) {
100
+ return function ( ...args) {
101
+ const handler = typeof args[0] === 'function' ? args[0] : args[1];
102
+ const documentOrOptions = typeof args[0] === 'function' ? undefined : args[0];
103
+
104
+ if (!handler) {
105
+ return original.call(this, ...args);
106
+ }
107
+
108
+ const wrappedHandler = async function ( ...handlerArgs) {
109
+ const functionName = process.env.FUNCTION_TARGET || process.env.K_SERVICE || 'unknown';
110
+ const span = tracer.startSpan(`firebase.function.${triggerType}`, {
111
+ kind: api.SpanKind.SERVER,
112
+ });
113
+
114
+ const attributes = {
115
+ 'faas.name': functionName,
116
+ 'faas.trigger': triggerType,
117
+ 'faas.provider': 'firebase',
118
+ };
119
+
120
+ if (process.env.GCLOUD_PROJECT) {
121
+ attributes['cloud.project_id'] = process.env.GCLOUD_PROJECT;
122
+ }
123
+
124
+ if (process.env.EVENTARC_CLOUD_EVENT_SOURCE) {
125
+ attributes['cloud.event_source'] = process.env.EVENTARC_CLOUD_EVENT_SOURCE;
126
+ }
127
+
128
+ span.setAttributes(attributes);
129
+ functionsConfig?.requestHook?.(span);
130
+
131
+ // Can be changed to safeExecuteInTheMiddleAsync once following is merged and released
132
+ // https://github.com/open-telemetry/opentelemetry-js/pull/6032
133
+ return api.context.with(api.trace.setSpan(api.context.active(), span), async () => {
134
+ let error;
135
+ let result;
136
+
137
+ try {
138
+ result = await handler.apply(this, handlerArgs);
139
+ } catch (e) {
140
+ error = e ;
141
+ }
142
+
143
+ functionsConfig?.responseHook?.(span, error);
144
+
145
+ if (error) {
146
+ span.recordException(error);
147
+ }
148
+
149
+ span.end();
150
+
151
+ if (error) {
152
+ await functionsConfig?.errorHook?.(span, error);
153
+ throw error;
154
+ }
155
+
156
+ return result;
157
+ });
158
+ };
159
+
160
+ if (documentOrOptions) {
161
+ return original.call(this, documentOrOptions, wrappedHandler);
162
+ } else {
163
+ return original.call(this, wrappedHandler);
164
+ }
165
+ };
166
+ };
167
+ }
168
+
169
+ function wrapCommonFunctions(
170
+ moduleExports,
171
+ wrap,
172
+ unwrap,
173
+ tracer,
174
+ functionsConfig,
175
+ triggerType,
176
+ ) {
177
+ unwrapCommonFunctions(moduleExports, unwrap);
178
+
179
+ switch (triggerType) {
180
+ case 'function':
181
+ wrap(moduleExports, 'onRequest', patchV2Functions(tracer, functionsConfig, 'http.request'));
182
+ wrap(moduleExports, 'onCall', patchV2Functions(tracer, functionsConfig, 'http.call'));
183
+ break;
184
+
185
+ case 'firestore':
186
+ wrap(moduleExports, 'onDocumentCreated', patchV2Functions(tracer, functionsConfig, 'firestore.document.created'));
187
+ wrap(moduleExports, 'onDocumentUpdated', patchV2Functions(tracer, functionsConfig, 'firestore.document.updated'));
188
+ wrap(moduleExports, 'onDocumentDeleted', patchV2Functions(tracer, functionsConfig, 'firestore.document.deleted'));
189
+ wrap(moduleExports, 'onDocumentWritten', patchV2Functions(tracer, functionsConfig, 'firestore.document.written'));
190
+ wrap(
191
+ moduleExports,
192
+ 'onDocumentCreatedWithAuthContext',
193
+ patchV2Functions(tracer, functionsConfig, 'firestore.document.created'),
194
+ );
195
+ wrap(
196
+ moduleExports,
197
+ 'onDocumentUpdatedWithAuthContext',
198
+ patchV2Functions(tracer, functionsConfig, 'firestore.document.updated'),
199
+ );
200
+
201
+ wrap(
202
+ moduleExports,
203
+ 'onDocumentDeletedWithAuthContext',
204
+ patchV2Functions(tracer, functionsConfig, 'firestore.document.deleted'),
205
+ );
206
+
207
+ wrap(
208
+ moduleExports,
209
+ 'onDocumentWrittenWithAuthContext',
210
+ patchV2Functions(tracer, functionsConfig, 'firestore.document.written'),
211
+ );
212
+ break;
213
+
214
+ case 'scheduler':
215
+ wrap(moduleExports, 'onSchedule', patchV2Functions(tracer, functionsConfig, 'scheduler.scheduled'));
216
+ break;
217
+
218
+ case 'storage':
219
+ wrap(moduleExports, 'onObjectFinalized', patchV2Functions(tracer, functionsConfig, 'storage.object.finalized'));
220
+ wrap(moduleExports, 'onObjectArchived', patchV2Functions(tracer, functionsConfig, 'storage.object.archived'));
221
+ wrap(moduleExports, 'onObjectDeleted', patchV2Functions(tracer, functionsConfig, 'storage.object.deleted'));
222
+ wrap(
223
+ moduleExports,
224
+ 'onObjectMetadataUpdated',
225
+ patchV2Functions(tracer, functionsConfig, 'storage.object.metadataUpdated'),
226
+ );
227
+ break;
228
+ }
229
+
230
+ return moduleExports;
231
+ }
232
+
233
+ function unwrapCommonFunctions(
234
+ moduleExports,
235
+ unwrap,
236
+ ) {
237
+ const methods = [
238
+ 'onSchedule',
239
+ 'onRequest',
240
+ 'onCall',
241
+ 'onObjectFinalized',
242
+ 'onObjectArchived',
243
+ 'onObjectDeleted',
244
+ 'onObjectMetadataUpdated',
245
+ 'onDocumentCreated',
246
+ 'onDocumentUpdated',
247
+ 'onDocumentDeleted',
248
+ 'onDocumentWritten',
249
+ 'onDocumentCreatedWithAuthContext',
250
+ 'onDocumentUpdatedWithAuthContext',
251
+ 'onDocumentDeletedWithAuthContext',
252
+ 'onDocumentWrittenWithAuthContext',
253
+ ];
254
+
255
+ for (const method of methods) {
256
+ if (instrumentation.isWrapped(moduleExports[method])) {
257
+ unwrap(moduleExports, method);
258
+ }
259
+ }
260
+ return moduleExports;
261
+ }
262
+
263
+ exports.patchFunctions = patchFunctions;
264
+ exports.patchV2Functions = patchV2Functions;
265
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sources":["../../../../../../../src/integrations/tracing/firebase/otel/patches/functions.ts"],"sourcesContent":["import type { Span, Tracer } from '@opentelemetry/api';\nimport { context, diag, SpanKind, trace } from '@opentelemetry/api';\nimport type { InstrumentationBase } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport type { SpanAttributes } from '@sentry/core';\nimport type { FirebaseInstrumentation } from '../firebaseInstrumentation';\nimport type {\n AvailableFirebaseFunctions,\n FirebaseFunctions,\n FirebaseInstrumentationConfig,\n OverloadedParameters,\n RequestHook,\n ResponseHook,\n} from '../types';\n\n/**\n * Patches Firebase Functions v2 to add OpenTelemetry instrumentation\n * @param tracer - Opentelemetry Tracer\n * @param functionsSupportedVersions - supported versions of firebase-functions\n * @param wrap - reference to native instrumentation wrap function\n * @param unwrap - reference to native instrumentation unwrap function\n * @param config - Firebase instrumentation config\n */\nexport function patchFunctions(\n tracer: Tracer,\n functionsSupportedVersions: string[],\n wrap: InstrumentationBase['_wrap'],\n unwrap: InstrumentationBase['_unwrap'],\n config: FirebaseInstrumentationConfig,\n): InstrumentationNodeModuleDefinition {\n let requestHook: RequestHook = () => {};\n let responseHook: ResponseHook = () => {};\n const errorHook = config.functions?.errorHook;\n const configRequestHook = config.functions?.requestHook;\n const configResponseHook = config.functions?.responseHook;\n\n if (typeof configResponseHook === 'function') {\n responseHook = (span: Span, err: unknown) => {\n safeExecuteInTheMiddle(\n () => configResponseHook(span, err),\n error => {\n if (!error) {\n return;\n }\n diag.error(error?.message);\n },\n true,\n );\n };\n }\n if (typeof configRequestHook === 'function') {\n requestHook = (span: Span) => {\n safeExecuteInTheMiddle(\n () => configRequestHook(span),\n error => {\n if (!error) {\n return;\n }\n diag.error(error?.message);\n },\n true,\n );\n };\n }\n\n const moduleFunctionsCJS = new InstrumentationNodeModuleDefinition('firebase-functions', functionsSupportedVersions);\n const modulesToInstrument = [\n { name: 'firebase-functions/lib/v2/providers/https.js', triggerType: 'function' },\n { name: 'firebase-functions/lib/v2/providers/firestore.js', triggerType: 'firestore' },\n { name: 'firebase-functions/lib/v2/providers/scheduler.js', triggerType: 'scheduler' },\n { name: 'firebase-functions/lib/v2/storage.js', triggerType: 'storage' },\n ] as const;\n\n modulesToInstrument.forEach(({ name, triggerType }) => {\n moduleFunctionsCJS.files.push(\n new InstrumentationNodeModuleFile(\n name,\n functionsSupportedVersions,\n moduleExports =>\n wrapCommonFunctions(\n moduleExports,\n wrap,\n unwrap,\n tracer,\n { requestHook, responseHook, errorHook },\n triggerType,\n ),\n moduleExports => unwrapCommonFunctions(moduleExports, unwrap),\n ),\n );\n });\n\n return moduleFunctionsCJS;\n}\n\n/**\n * Patches Cloud Functions for Firebase (v2) to add OpenTelemetry instrumentation\n *\n * @param tracer - Opentelemetry Tracer\n * @param functionsConfig - Firebase instrumentation config\n * @param triggerType - Type of trigger\n * @returns A function that patches the function\n */\nexport function patchV2Functions<T extends FirebaseFunctions = FirebaseFunctions>(\n tracer: Tracer,\n functionsConfig: FirebaseInstrumentationConfig['functions'],\n triggerType: string,\n): (original: T) => (...args: OverloadedParameters<T>) => ReturnType<T> {\n return function v2FunctionsWrapper(original: T): (...args: OverloadedParameters<T>) => ReturnType<T> {\n return function (this: FirebaseInstrumentation, ...args: OverloadedParameters<T>): ReturnType<T> {\n const handler = typeof args[0] === 'function' ? args[0] : args[1];\n const documentOrOptions = typeof args[0] === 'function' ? undefined : args[0];\n\n if (!handler) {\n return original.call(this, ...args);\n }\n\n const wrappedHandler = async function (this: unknown, ...handlerArgs: unknown[]): Promise<unknown> {\n const functionName = process.env.FUNCTION_TARGET || process.env.K_SERVICE || 'unknown';\n const span = tracer.startSpan(`firebase.function.${triggerType}`, {\n kind: SpanKind.SERVER,\n });\n\n const attributes: SpanAttributes = {\n 'faas.name': functionName,\n 'faas.trigger': triggerType,\n 'faas.provider': 'firebase',\n };\n\n if (process.env.GCLOUD_PROJECT) {\n attributes['cloud.project_id'] = process.env.GCLOUD_PROJECT;\n }\n\n if (process.env.EVENTARC_CLOUD_EVENT_SOURCE) {\n attributes['cloud.event_source'] = process.env.EVENTARC_CLOUD_EVENT_SOURCE;\n }\n\n span.setAttributes(attributes);\n functionsConfig?.requestHook?.(span);\n\n // Can be changed to safeExecuteInTheMiddleAsync once following is merged and released\n // https://github.com/open-telemetry/opentelemetry-js/pull/6032\n return context.with(trace.setSpan(context.active(), span), async () => {\n let error: Error | undefined;\n let result: T | undefined;\n\n try {\n result = await handler.apply(this, handlerArgs);\n } catch (e) {\n error = e as Error;\n }\n\n functionsConfig?.responseHook?.(span, error);\n\n if (error) {\n span.recordException(error);\n }\n\n span.end();\n\n if (error) {\n await functionsConfig?.errorHook?.(span, error);\n throw error;\n }\n\n return result;\n });\n };\n\n if (documentOrOptions) {\n return original.call(this, documentOrOptions, wrappedHandler);\n } else {\n return original.call(this, wrappedHandler);\n }\n };\n };\n}\n\nfunction wrapCommonFunctions(\n moduleExports: AvailableFirebaseFunctions,\n wrap: InstrumentationBase<FirebaseInstrumentationConfig>['_wrap'],\n unwrap: InstrumentationBase<FirebaseInstrumentationConfig>['_unwrap'],\n tracer: Tracer,\n functionsConfig: FirebaseInstrumentationConfig['functions'],\n triggerType: 'function' | 'firestore' | 'scheduler' | 'storage',\n): AvailableFirebaseFunctions {\n unwrapCommonFunctions(moduleExports, unwrap);\n\n switch (triggerType) {\n case 'function':\n wrap(moduleExports, 'onRequest', patchV2Functions(tracer, functionsConfig, 'http.request'));\n wrap(moduleExports, 'onCall', patchV2Functions(tracer, functionsConfig, 'http.call'));\n break;\n\n case 'firestore':\n wrap(moduleExports, 'onDocumentCreated', patchV2Functions(tracer, functionsConfig, 'firestore.document.created'));\n wrap(moduleExports, 'onDocumentUpdated', patchV2Functions(tracer, functionsConfig, 'firestore.document.updated'));\n wrap(moduleExports, 'onDocumentDeleted', patchV2Functions(tracer, functionsConfig, 'firestore.document.deleted'));\n wrap(moduleExports, 'onDocumentWritten', patchV2Functions(tracer, functionsConfig, 'firestore.document.written'));\n wrap(\n moduleExports,\n 'onDocumentCreatedWithAuthContext',\n patchV2Functions(tracer, functionsConfig, 'firestore.document.created'),\n );\n wrap(\n moduleExports,\n 'onDocumentUpdatedWithAuthContext',\n patchV2Functions(tracer, functionsConfig, 'firestore.document.updated'),\n );\n\n wrap(\n moduleExports,\n 'onDocumentDeletedWithAuthContext',\n patchV2Functions(tracer, functionsConfig, 'firestore.document.deleted'),\n );\n\n wrap(\n moduleExports,\n 'onDocumentWrittenWithAuthContext',\n patchV2Functions(tracer, functionsConfig, 'firestore.document.written'),\n );\n break;\n\n case 'scheduler':\n wrap(moduleExports, 'onSchedule', patchV2Functions(tracer, functionsConfig, 'scheduler.scheduled'));\n break;\n\n case 'storage':\n wrap(moduleExports, 'onObjectFinalized', patchV2Functions(tracer, functionsConfig, 'storage.object.finalized'));\n wrap(moduleExports, 'onObjectArchived', patchV2Functions(tracer, functionsConfig, 'storage.object.archived'));\n wrap(moduleExports, 'onObjectDeleted', patchV2Functions(tracer, functionsConfig, 'storage.object.deleted'));\n wrap(\n moduleExports,\n 'onObjectMetadataUpdated',\n patchV2Functions(tracer, functionsConfig, 'storage.object.metadataUpdated'),\n );\n break;\n }\n\n return moduleExports;\n}\n\nfunction unwrapCommonFunctions(\n moduleExports: AvailableFirebaseFunctions,\n unwrap: InstrumentationBase<FirebaseInstrumentationConfig>['_unwrap'],\n): AvailableFirebaseFunctions {\n const methods: (keyof AvailableFirebaseFunctions)[] = [\n 'onSchedule',\n 'onRequest',\n 'onCall',\n 'onObjectFinalized',\n 'onObjectArchived',\n 'onObjectDeleted',\n 'onObjectMetadataUpdated',\n 'onDocumentCreated',\n 'onDocumentUpdated',\n 'onDocumentDeleted',\n 'onDocumentWritten',\n 'onDocumentCreatedWithAuthContext',\n 'onDocumentUpdatedWithAuthContext',\n 'onDocumentDeletedWithAuthContext',\n 'onDocumentWrittenWithAuthContext',\n ];\n\n for (const method of methods) {\n if (isWrapped(moduleExports[method])) {\n unwrap(moduleExports, method);\n }\n }\n return moduleExports;\n}\n"],"names":["safeExecuteInTheMiddle","diag","InstrumentationNodeModuleDefinition","InstrumentationNodeModuleFile","SpanKind","context","trace","isWrapped"],"mappings":";;;;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc;AAC9B,EAAE,MAAM;AACR,EAAE,0BAA0B;AAC5B,EAAE,IAAI;AACN,EAAE,MAAM;AACR,EAAE,MAAM;AACR,EAAuC;AACvC,EAAE,IAAI,WAAW,GAAgB,MAAM,EAAE;AACzC,EAAE,IAAI,YAAY,GAAiB,MAAM,EAAE;AAC3C,EAAE,MAAM,SAAA,GAAY,MAAM,CAAC,SAAS,EAAE,SAAS;AAC/C,EAAE,MAAM,iBAAA,GAAoB,MAAM,CAAC,SAAS,EAAE,WAAW;AACzD,EAAE,MAAM,kBAAA,GAAqB,MAAM,CAAC,SAAS,EAAE,YAAY;;AAE3D,EAAE,IAAI,OAAO,kBAAA,KAAuB,UAAU,EAAE;AAChD,IAAI,eAAe,CAAC,IAAI,EAAQ,GAAG,KAAc;AACjD,MAAMA,sCAAsB;AAC5B,QAAQ,MAAM,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC;AAC3C,QAAQ,SAAS;AACjB,UAAU,IAAI,CAAC,KAAK,EAAE;AACtB,YAAY;AACZ;AACA,UAAUC,QAAI,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC;AACpC,SAAS;AACT,QAAQ,IAAI;AACZ,OAAO;AACP,KAAK;AACL;AACA,EAAE,IAAI,OAAO,iBAAA,KAAsB,UAAU,EAAE;AAC/C,IAAI,WAAA,GAAc,CAAC,IAAI,KAAW;AAClC,MAAMD,sCAAsB;AAC5B,QAAQ,MAAM,iBAAiB,CAAC,IAAI,CAAC;AACrC,QAAQ,SAAS;AACjB,UAAU,IAAI,CAAC,KAAK,EAAE;AACtB,YAAY;AACZ;AACA,UAAUC,QAAI,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC;AACpC,SAAS;A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,CAAA,CAAA;AACA,MAAA,IAAA,CAAA,aAAA,EAAA,kBAAA,EAAA,gBAAA,CAAA,MAAA,EAAA,eAAA,EAAA,yBAAA,CAAA,CAAA;AACA,MAAA,IAAA,CAAA,aAAA,EAAA,iBAAA,EAAA,gBAAA,CAAA,MAAA,EAAA,eAAA,EAAA,wBAAA,CAAA,CAAA;AACA,MAAA,IAAA;AACA,QAAA,aAAA;AACA,QAAA,yBAAA;AACA,QAAA,gBAAA,CAAA,MAAA,EAAA,eAAA,EAAA,gCAAA,CAAA;AACA,OAAA;AACA,MAAA;AACA;;AAEA,EAAA,OAAA,aAAA;AACA;;AAEA,SAAA,qBAAA;AACA,EAAA,aAAA;AACA,EAAA,MAAA;AACA,EAAA;AACA,EAAA,MAAA,OAAA,GAAA;AACA,IAAA,YAAA;AACA,IAAA,WAAA;AACA,IAAA,QAAA;AACA,IAAA,mBAAA;AACA,IAAA,kBAAA;AACA,IAAA,iBAAA;AACA,IAAA,yBAAA;AACA,IAAA,mBAAA;AACA,IAAA,mBAAA;AACA,IAAA,mBAAA;AACA,IAAA,mBAAA;AACA,IAAA,kCAAA;AACA,IAAA,kCAAA;AACA,IAAA,kCAAA;AACA,IAAA,kCAAA;AACA,GAAA;;AAEA,EAAA,KAAA,MAAA,MAAA,IAAA,OAAA,EAAA;AACA,IAAA,IAAAE,yBAAA,CAAA,aAAA,CAAA,MAAA,CAAA,CAAA,EAAA;AACA,MAAA,MAAA,CAAA,aAAA,EAAA,MAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,aAAA;AACA;;;;;"}
@@ -14,6 +14,7 @@ const index$1 = require('./hapi/index.js');
14
14
  const index$2 = require('./hono/index.js');
15
15
  const kafka = require('./kafka.js');
16
16
  const koa = require('./koa.js');
17
+ const index$7 = require('./langchain/index.js');
17
18
  const lrumemoizer = require('./lrumemoizer.js');
18
19
  const mongo = require('./mongo.js');
19
20
  const mongoose = require('./mongoose.js');
@@ -57,6 +58,7 @@ function getAutoPerformanceIntegrations() {
57
58
  firebase.firebaseIntegration(),
58
59
  index$5.anthropicAIIntegration(),
59
60
  index$6.googleGenAIIntegration(),
61
+ index$7.langChainIntegration(),
60
62
  ];
61
63
  }
62
64
 
@@ -94,6 +96,7 @@ function getOpenTelemetryInstrumentationToPreload() {
94
96
  firebase.instrumentFirebase,
95
97
  index$5.instrumentAnthropicAi,
96
98
  index$6.instrumentGoogleGenAI,
99
+ index$7.instrumentLangChain,
97
100
  ];
98
101
  }
99
102
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { instrumentOtelHttp, instrumentSentryHttp } from '../http';\nimport { amqplibIntegration, instrumentAmqplib } from './amqplib';\nimport { anthropicAIIntegration, instrumentAnthropicAi } from './anthropic-ai';\nimport { connectIntegration, instrumentConnect } from './connect';\nimport { expressIntegration, instrumentExpress } from './express';\nimport { fastifyIntegration, instrumentFastify, instrumentFastifyV3 } from './fastify';\nimport { firebaseIntegration, instrumentFirebase } from './firebase';\nimport { genericPoolIntegration, instrumentGenericPool } from './genericPool';\nimport { googleGenAIIntegration, instrumentGoogleGenAI } from './google-genai';\nimport { graphqlIntegration, instrumentGraphql } from './graphql';\nimport { hapiIntegration, instrumentHapi } from './hapi';\nimport { honoIntegration, instrumentHono } from './hono';\nimport { instrumentKafka, kafkaIntegration } from './kafka';\nimport { instrumentKoa, koaIntegration } from './koa';\nimport { instrumentLruMemoizer, lruMemoizerIntegration } from './lrumemoizer';\nimport { instrumentMongo, mongoIntegration } from './mongo';\nimport { instrumentMongoose, mongooseIntegration } from './mongoose';\nimport { instrumentMysql, mysqlIntegration } from './mysql';\nimport { instrumentMysql2, mysql2Integration } from './mysql2';\nimport { instrumentOpenAi, openAIIntegration } from './openai';\nimport { instrumentPostgres, postgresIntegration } from './postgres';\nimport { instrumentPostgresJs, postgresJsIntegration } from './postgresjs';\nimport { prismaIntegration } from './prisma';\nimport { instrumentRedis, redisIntegration } from './redis';\nimport { instrumentTedious, tediousIntegration } from './tedious';\nimport { instrumentVercelAi, vercelAIIntegration } from './vercelai';\n\n/**\n * With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.\n */\nexport function getAutoPerformanceIntegrations(): Integration[] {\n return [\n expressIntegration(),\n fastifyIntegration(),\n graphqlIntegration(),\n honoIntegration(),\n mongoIntegration(),\n mongooseIntegration(),\n mysqlIntegration(),\n mysql2Integration(),\n redisIntegration(),\n postgresIntegration(),\n prismaIntegration(),\n hapiIntegration(),\n koaIntegration(),\n connectIntegration(),\n tediousIntegration(),\n genericPoolIntegration(),\n kafkaIntegration(),\n amqplibIntegration(),\n lruMemoizerIntegration(),\n vercelAIIntegration(),\n openAIIntegration(),\n postgresJsIntegration(),\n firebaseIntegration(),\n anthropicAIIntegration(),\n googleGenAIIntegration(),\n ];\n}\n\n/**\n * Get a list of methods to instrument OTEL, when preload instrumentation.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getOpenTelemetryInstrumentationToPreload(): (((options?: any) => void) & { id: string })[] {\n return [\n instrumentSentryHttp,\n instrumentOtelHttp,\n instrumentExpress,\n instrumentConnect,\n instrumentFastify,\n instrumentFastifyV3,\n instrumentHapi,\n instrumentHono,\n instrumentKafka,\n instrumentKoa,\n instrumentLruMemoizer,\n instrumentMongo,\n instrumentMongoose,\n instrumentMysql,\n instrumentMysql2,\n instrumentPostgres,\n instrumentHapi,\n instrumentGraphql,\n instrumentRedis,\n instrumentTedious,\n instrumentGenericPool,\n instrumentAmqplib,\n instrumentVercelAi,\n instrumentOpenAi,\n instrumentPostgresJs,\n instrumentFirebase,\n instrumentAnthropicAi,\n instrumentGoogleGenAI,\n ];\n}\n"],"names":["expressIntegration","fastifyIntegration","graphqlIntegration","honoIntegration","mongoIntegration","mongooseIntegration","mysqlIntegration","mysql2Integration","redisIntegration","postgresIntegration","prismaIntegration","hapiIntegration","koaIntegration","connectIntegration","tediousIntegration","genericPoolIntegration","kafkaIntegration","amqplibIntegration","lruMemoizerIntegration","vercelAIIntegration","openAIIntegration","postgresJsIntegration","firebaseIntegration","anthropicAIIntegration","googleGenAIIntegration","instrumentSentryHttp","instrumentOtelHttp","instrumentExpress","instrumentConnect","instrumentFastify","instrumentFastifyV3","instrumentHapi","instrumentHono","instrumentKafka","instrumentKoa","instrumentLruMemoizer","instrumentMongo","instrumentMongoose","instrumentMysql","instrumentMysql2","instrumentPostgres","instrumentGraphql","instrumentRedis","instrumentTedious","instrumentGenericPool","instrumentAmqplib","instrumentVercelAi","instrumentOpenAi","instrumentPostgresJs","instrumentFirebase","instrumentAnthropicAi","instrumentGoogleGenAI"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA;AACA;AACA;AACO,SAAS,8BAA8B,GAAkB;AAChE,EAAE,OAAO;AACT,IAAIA,0BAAkB,EAAE;AACxB,IAAIC,wBAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,uBAAe,EAAE;AACrB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,4BAAmB,EAAE;AACzB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,wBAAiB,EAAE;AACvB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,4BAAmB,EAAE;AACzB,IAAIC,wBAAiB,EAAE;AACvB,IAAIC,uBAAe,EAAE;AACrB,IAAIC,kBAAc,EAAE;AACpB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,kCAAsB,EAAE;AAC5B,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,kCAAsB,EAAE;AAC5B,IAAIC,2BAAmB,EAAE;AACzB,IAAIC,yBAAiB,EAAE;AACvB,IAAIC,gCAAqB,EAAE;AAC3B,IAAIC,4BAAmB,EAAE;AACzB,IAAIC,8BAAsB,EAAE;AAC5B,IAAIC,8BAAsB,EAAE;AAC5B,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAmD;AAC3G,EAAE,OAAO;AACT,IAAIC,yBAAoB;AACxB,IAAIC,uBAAkB;AACtB,IAAIC,yBAAiB;AACrB,IAAIC,yBAAiB;AACrB,IAAIC,uBAAiB;AACrB,IAAIC,yBAAmB;AACvB,IAAIC,sBAAc;AAClB,IAAIC,sBAAc;AAClB,IAAIC,qBAAe;AACnB,IAAIC,iBAAa;AACjB,IAAIC,iCAAqB;AACzB,IAAIC,qBAAe;AACnB,IAAIC,2BAAkB;AACtB,IAAIC,qBAAe;AACnB,IAAIC,uBAAgB;AACpB,IAAIC,2BAAkB;AACtB,IAAIT,sBAAc;AAClB,IAAIU,yBAAiB;AACrB,IAAIC,qBAAe;AACnB,IAAIC,yBAAiB;AACrB,IAAIC,iCAAqB;AACzB,IAAIC,yBAAiB;AACrB,IAAIC,0BAAkB;AACtB,IAAIC,wBAAgB;AACpB,IAAIC,+BAAoB;AACxB,IAAIC,2BAAkB;AACtB,IAAIC,6BAAqB;AACzB,IAAIC,6BAAqB;AACzB,GAAG;AACH;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { instrumentOtelHttp, instrumentSentryHttp } from '../http';\nimport { amqplibIntegration, instrumentAmqplib } from './amqplib';\nimport { anthropicAIIntegration, instrumentAnthropicAi } from './anthropic-ai';\nimport { connectIntegration, instrumentConnect } from './connect';\nimport { expressIntegration, instrumentExpress } from './express';\nimport { fastifyIntegration, instrumentFastify, instrumentFastifyV3 } from './fastify';\nimport { firebaseIntegration, instrumentFirebase } from './firebase';\nimport { genericPoolIntegration, instrumentGenericPool } from './genericPool';\nimport { googleGenAIIntegration, instrumentGoogleGenAI } from './google-genai';\nimport { graphqlIntegration, instrumentGraphql } from './graphql';\nimport { hapiIntegration, instrumentHapi } from './hapi';\nimport { honoIntegration, instrumentHono } from './hono';\nimport { instrumentKafka, kafkaIntegration } from './kafka';\nimport { instrumentKoa, koaIntegration } from './koa';\nimport { instrumentLangChain, langChainIntegration } from './langchain';\nimport { instrumentLruMemoizer, lruMemoizerIntegration } from './lrumemoizer';\nimport { instrumentMongo, mongoIntegration } from './mongo';\nimport { instrumentMongoose, mongooseIntegration } from './mongoose';\nimport { instrumentMysql, mysqlIntegration } from './mysql';\nimport { instrumentMysql2, mysql2Integration } from './mysql2';\nimport { instrumentOpenAi, openAIIntegration } from './openai';\nimport { instrumentPostgres, postgresIntegration } from './postgres';\nimport { instrumentPostgresJs, postgresJsIntegration } from './postgresjs';\nimport { prismaIntegration } from './prisma';\nimport { instrumentRedis, redisIntegration } from './redis';\nimport { instrumentTedious, tediousIntegration } from './tedious';\nimport { instrumentVercelAi, vercelAIIntegration } from './vercelai';\n\n/**\n * With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.\n */\nexport function getAutoPerformanceIntegrations(): Integration[] {\n return [\n expressIntegration(),\n fastifyIntegration(),\n graphqlIntegration(),\n honoIntegration(),\n mongoIntegration(),\n mongooseIntegration(),\n mysqlIntegration(),\n mysql2Integration(),\n redisIntegration(),\n postgresIntegration(),\n prismaIntegration(),\n hapiIntegration(),\n koaIntegration(),\n connectIntegration(),\n tediousIntegration(),\n genericPoolIntegration(),\n kafkaIntegration(),\n amqplibIntegration(),\n lruMemoizerIntegration(),\n vercelAIIntegration(),\n openAIIntegration(),\n postgresJsIntegration(),\n firebaseIntegration(),\n anthropicAIIntegration(),\n googleGenAIIntegration(),\n langChainIntegration(),\n ];\n}\n\n/**\n * Get a list of methods to instrument OTEL, when preload instrumentation.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getOpenTelemetryInstrumentationToPreload(): (((options?: any) => void) & { id: string })[] {\n return [\n instrumentSentryHttp,\n instrumentOtelHttp,\n instrumentExpress,\n instrumentConnect,\n instrumentFastify,\n instrumentFastifyV3,\n instrumentHapi,\n instrumentHono,\n instrumentKafka,\n instrumentKoa,\n instrumentLruMemoizer,\n instrumentMongo,\n instrumentMongoose,\n instrumentMysql,\n instrumentMysql2,\n instrumentPostgres,\n instrumentHapi,\n instrumentGraphql,\n instrumentRedis,\n instrumentTedious,\n instrumentGenericPool,\n instrumentAmqplib,\n instrumentVercelAi,\n instrumentOpenAi,\n instrumentPostgresJs,\n instrumentFirebase,\n instrumentAnthropicAi,\n instrumentGoogleGenAI,\n instrumentLangChain,\n ];\n}\n"],"names":["expressIntegration","fastifyIntegration","graphqlIntegration","honoIntegration","mongoIntegration","mongooseIntegration","mysqlIntegration","mysql2Integration","redisIntegration","postgresIntegration","prismaIntegration","hapiIntegration","koaIntegration","connectIntegration","tediousIntegration","genericPoolIntegration","kafkaIntegration","amqplibIntegration","lruMemoizerIntegration","vercelAIIntegration","openAIIntegration","postgresJsIntegration","firebaseIntegration","anthropicAIIntegration","googleGenAIIntegration","langChainIntegration","instrumentSentryHttp","instrumentOtelHttp","instrumentExpress","instrumentConnect","instrumentFastify","instrumentFastifyV3","instrumentHapi","instrumentHono","instrumentKafka","instrumentKoa","instrumentLruMemoizer","instrumentMongo","instrumentMongoose","instrumentMysql","instrumentMysql2","instrumentPostgres","instrumentGraphql","instrumentRedis","instrumentTedious","instrumentGenericPool","instrumentAmqplib","instrumentVercelAi","instrumentOpenAi","instrumentPostgresJs","instrumentFirebase","instrumentAnthropicAi","instrumentGoogleGenAI","instrumentLangChain"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA;AACA;AACA;AACO,SAAS,8BAA8B,GAAkB;AAChE,EAAE,OAAO;AACT,IAAIA,0BAAkB,EAAE;AACxB,IAAIC,wBAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,uBAAe,EAAE;AACrB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,4BAAmB,EAAE;AACzB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,wBAAiB,EAAE;AACvB,IAAIC,sBAAgB,EAAE;AACtB,IAAIC,4BAAm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ag, { value: 'Module' });
2
+
3
+ const core = require('@sentry/core');
4
+ const nodeCore = require('@sentry/node-core');
5
+ const instrumentation = require('./instrumentation.js');
6
+
7
+ const instrumentLangChain = nodeCore.generateInstrumentOnce(
8
+ core.LANGCHAIN_INTEGRATION_NAME,
9
+ options => new instrumentation.SentryLangChainInstrumentation(options),
10
+ );
11
+
12
+ const _langChainIntegration = ((options = {}) => {
13
+ return {
14
+ name: core.LANGCHAIN_INTEGRATION_NAME,
15
+ setupOnce() {
16
+ instrumentLangChain(options);
17
+ },
18
+ };
19
+ }) ;
20
+
21
+ /**
22
+ * Adds Sentry tracing instrumentation for LangChain.
23
+ *
24
+ * This integration is enabled by default.
25
+ *
26
+ * When configured, this integration automatically instruments LangChain runnable instances
27
+ * to capture telemetry data by injecting Sentry callback handlers into all LangChain calls.
28
+ *
29
+ * @example
30
+ * ```javascript
31
+ * import * as Sentry from '@sentry/node';
32
+ * import { ChatOpenAI } from '@langchain/openai';
33
+ *
34
+ * Sentry.init({
35
+ * integrations: [Sentry.langChainIntegration()],
36
+ * sendDefaultPii: true, // Enable to record inputs/outputs
37
+ * });
38
+ *
39
+ * // LangChain calls are automatically instrumented
40
+ * const model = new ChatOpenAI();
41
+ * await model.invoke("What is the capital of France?");
42
+ * ```
43
+ *
44
+ * ## Manual Callback Handler
45
+ *
46
+ * You can also manually add the Sentry callback handler alongside other callbacks:
47
+ *
48
+ * @example
49
+ * ```javascript
50
+ * import * as Sentry from '@sentry/node';
51
+ * import { ChatOpenAI } from '@langchain/openai';
52
+ *
53
+ * const sentryHandler = Sentry.createLangChainCallbackHandler({
54
+ * recordInputs: true,
55
+ * recordOutputs: true
56
+ * });
57
+ *
58
+ * const model = new ChatOpenAI();
59
+ * await model.invoke(
60
+ * "What is the capital of France?",
61
+ * { callbacks: [sentryHandler, myOtherCallback] }
62
+ * );
63
+ * ```
64
+ *
65
+ * ## Options
66
+ *
67
+ * - `recordInputs`: Whether to record input messages/prompts (default: respects `sendDefaultPii` client option)
68
+ * - `recordOutputs`: Whether to record response text (default: respects `sendDefaultPii` client option)
69
+ *
70
+ * ### Default Behavior
71
+ *
72
+ * By default, the integration will:
73
+ * - Record inputs and outputs ONLY if `sendDefaultPii` is set to `true` in your Sentry client options
74
+ * - Otherwise, inputs and outputs are NOT recorded unless explicitly enabled
75
+ *
76
+ * @example
77
+ * ```javascript
78
+ * // Record inputs and outputs when sendDefaultPii is false
79
+ * Sentry.init({
80
+ * integrations: [
81
+ * Sentry.langChainIntegration({
82
+ * recordInputs: true,
83
+ * recordOutputs: true
84
+ * })
85
+ * ],
86
+ * });
87
+ *
88
+ * // Never record inputs/outputs regardless of sendDefaultPii
89
+ * Sentry.init({
90
+ * sendDefaultPii: true,
91
+ * integrations: [
92
+ * Sentry.langChainIntegration({
93
+ * recordInputs: false,
94
+ * recordOutputs: false
95
+ * })
96
+ * ],
97
+ * });
98
+ * ```
99
+ *
100
+ * ## Supported Events
101
+ *
102
+ * The integration captures the following LangChain lifecycle events:
103
+ * - LLM/Chat Model: start, end, error
104
+ * - Chain: start, end, error
105
+ * - Tool: start, end, error
106
+ *
107
+ */
108
+ const langChainIntegration = core.defineIntegration(_langChainIntegration);
109
+
110
+ exports.instrumentLangChain = instrumentLangChain;
111
+ exports.langChainIntegration = langChainIntegration;
112
+ //# sourceMappingURL=index.js.map