@sentry/node 9.11.0 → 9.13.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 (93) hide show
  1. package/build/cjs/index.js +5 -4
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/cjs/integrations/anr/index.js +3 -3
  4. package/build/cjs/integrations/anr/index.js.map +1 -1
  5. package/build/cjs/integrations/context.js +3 -3
  6. package/build/cjs/integrations/context.js.map +1 -1
  7. package/build/cjs/integrations/http/SentryHttpInstrumentation.js +6 -2
  8. package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
  9. package/build/cjs/integrations/http/index.js.map +1 -1
  10. package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  11. package/build/cjs/integrations/node-fetch/index.js +11 -7
  12. package/build/cjs/integrations/node-fetch/index.js.map +1 -1
  13. package/build/cjs/integrations/tracing/graphql.js +31 -3
  14. package/build/cjs/integrations/tracing/graphql.js.map +1 -1
  15. package/build/cjs/integrations/winston.js +151 -0
  16. package/build/cjs/integrations/winston.js.map +1 -0
  17. package/build/cjs/logs/capture.js +29 -0
  18. package/build/cjs/logs/capture.js.map +1 -0
  19. package/build/cjs/{log.js → logs/exports.js} +8 -30
  20. package/build/cjs/logs/exports.js.map +1 -0
  21. package/build/cjs/otel/instrument.js +50 -2
  22. package/build/cjs/otel/instrument.js.map +1 -1
  23. package/build/cjs/sdk/client.js +23 -1
  24. package/build/cjs/sdk/client.js.map +1 -1
  25. package/build/cjs/sdk/index.js +2 -2
  26. package/build/cjs/sdk/index.js.map +1 -1
  27. package/build/esm/index.js +4 -4
  28. package/build/esm/integrations/anr/index.js +1 -1
  29. package/build/esm/integrations/anr/worker-script.js +2 -2
  30. package/build/esm/integrations/http/SentryHttpInstrumentation.js +6 -2
  31. package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
  32. package/build/esm/integrations/http/index.js.map +1 -1
  33. package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  34. package/build/esm/integrations/local-variables/worker-script.js +2 -2
  35. package/build/esm/integrations/node-fetch/index.js +11 -7
  36. package/build/esm/integrations/node-fetch/index.js.map +1 -1
  37. package/build/esm/integrations/tracing/express.js +1 -1
  38. package/build/esm/integrations/tracing/fastify.js +1 -1
  39. package/build/esm/integrations/tracing/graphql.js +32 -4
  40. package/build/esm/integrations/tracing/graphql.js.map +1 -1
  41. package/build/esm/integrations/tracing/koa.js +1 -1
  42. package/build/esm/integrations/winston.js +149 -0
  43. package/build/esm/integrations/winston.js.map +1 -0
  44. package/build/esm/logs/capture.js +27 -0
  45. package/build/esm/logs/capture.js.map +1 -0
  46. package/build/esm/{log.js → logs/exports.js} +2 -25
  47. package/build/esm/logs/exports.js.map +1 -0
  48. package/build/esm/otel/instrument.js +50 -2
  49. package/build/esm/otel/instrument.js.map +1 -1
  50. package/build/esm/package.json +1 -1
  51. package/build/esm/sdk/client.js +24 -2
  52. package/build/esm/sdk/client.js.map +1 -1
  53. package/build/esm/sdk/index.js +2 -2
  54. package/build/esm/sdk/index.js.map +1 -1
  55. package/build/types/index.d.ts +3 -3
  56. package/build/types/index.d.ts.map +1 -1
  57. package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +8 -0
  58. package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
  59. package/build/types/integrations/http/index.d.ts +8 -0
  60. package/build/types/integrations/http/index.d.ts.map +1 -1
  61. package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
  62. package/build/types/integrations/tracing/graphql.d.ts +2 -1
  63. package/build/types/integrations/tracing/graphql.d.ts.map +1 -1
  64. package/build/types/integrations/winston.d.ts +44 -0
  65. package/build/types/integrations/winston.d.ts.map +1 -0
  66. package/build/types/logs/capture.d.ts +11 -0
  67. package/build/types/logs/capture.d.ts.map +1 -0
  68. package/build/{types-ts3.8/log.d.ts → types/logs/exports.d.ts} +150 -158
  69. package/build/types/logs/exports.d.ts.map +1 -0
  70. package/build/types/otel/instrument.d.ts +3 -4
  71. package/build/types/otel/instrument.d.ts.map +1 -1
  72. package/build/types/sdk/client.d.ts +1 -0
  73. package/build/types/sdk/client.d.ts.map +1 -1
  74. package/build/types-ts3.8/index.d.ts +3 -3
  75. package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +8 -0
  76. package/build/types-ts3.8/integrations/http/index.d.ts +8 -0
  77. package/build/types-ts3.8/integrations/tracing/graphql.d.ts +2 -1
  78. package/build/types-ts3.8/integrations/winston.d.ts +44 -0
  79. package/build/types-ts3.8/logs/capture.d.ts +18 -0
  80. package/build/{types/log.d.ts → types-ts3.8/logs/exports.d.ts} +150 -151
  81. package/build/types-ts3.8/otel/instrument.d.ts +3 -4
  82. package/build/types-ts3.8/sdk/client.d.ts +1 -0
  83. package/package.json +3 -3
  84. package/build/cjs/integrations/console.js +0 -37
  85. package/build/cjs/integrations/console.js.map +0 -1
  86. package/build/cjs/log.js.map +0 -1
  87. package/build/esm/integrations/console.js +0 -35
  88. package/build/esm/integrations/console.js.map +0 -1
  89. package/build/esm/log.js.map +0 -1
  90. package/build/types/integrations/console.d.ts +0 -5
  91. package/build/types/integrations/console.d.ts.map +0 -1
  92. package/build/types/log.d.ts.map +0 -1
  93. package/build/types-ts3.8/integrations/console.d.ts +0 -5
@@ -0,0 +1,29 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const node_util = require('node:util');
4
+ const core = require('@sentry/core');
5
+
6
+ /**
7
+ * Capture a log with the given level.
8
+ *
9
+ * @param level - The level of the log.
10
+ * @param message - The message to log.
11
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.
12
+ */
13
+ function captureLog(level, ...args) {
14
+ const [messageOrMessageTemplate, paramsOrAttributes, maybeAttributes] = args;
15
+ if (Array.isArray(paramsOrAttributes)) {
16
+ const attributes = { ...maybeAttributes };
17
+ attributes['sentry.message.template'] = messageOrMessageTemplate;
18
+ paramsOrAttributes.forEach((param, index) => {
19
+ attributes[`sentry.message.parameter.${index}`] = param;
20
+ });
21
+ const message = node_util.format(messageOrMessageTemplate, ...paramsOrAttributes);
22
+ core._INTERNAL_captureLog({ level, message, attributes });
23
+ } else {
24
+ core._INTERNAL_captureLog({ level, message: messageOrMessageTemplate, attributes: paramsOrAttributes });
25
+ }
26
+ }
27
+
28
+ exports.captureLog = captureLog;
29
+ //# sourceMappingURL=capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture.js","sources":["../../../src/logs/capture.ts"],"sourcesContent":["import { format } from 'node:util';\n\nimport type { LogSeverityLevel, Log, ParameterizedString } from '@sentry/core';\nimport { _INTERNAL_captureLog } from '@sentry/core';\n\nexport type CaptureLogArgs =\n | [message: ParameterizedString, attributes?: Log['attributes']]\n | [messageTemplate: string, messageParams: Array<unknown>, attributes?: Log['attributes']];\n\n/**\n * Capture a log with the given level.\n *\n * @param level - The level of the log.\n * @param message - The message to log.\n * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.\n */\nexport function captureLog(level: LogSeverityLevel, ...args: CaptureLogArgs): void {\n const [messageOrMessageTemplate, paramsOrAttributes, maybeAttributes] = args;\n if (Array.isArray(paramsOrAttributes)) {\n const attributes = { ...maybeAttributes };\n attributes['sentry.message.template'] = messageOrMessageTemplate;\n paramsOrAttributes.forEach((param, index) => {\n attributes[`sentry.message.parameter.${index}`] = param;\n });\n const message = format(messageOrMessageTemplate, ...paramsOrAttributes);\n _INTERNAL_captureLog({ level, message, attributes });\n } else {\n _INTERNAL_captureLog({ level, message: messageOrMessageTemplate, attributes: paramsOrAttributes });\n }\n}\n"],"names":["format","_INTERNAL_captureLog"],"mappings":";;;;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,UAAU,CAAC,KAAK,EAAoB,GAAG,IAAI,EAAwB;AACnF,EAAE,MAAM,CAAC,wBAAwB,EAAE,kBAAkB,EAAE,eAAe,CAAE,GAAE,IAAI;AAC9E,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE;AACzC,IAAI,MAAM,UAAW,GAAE,EAAE,GAAG,iBAAiB;AAC7C,IAAI,UAAU,CAAC,yBAAyB,CAAA,GAAI,wBAAwB;AACpE,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK;AACjD,MAAM,UAAU,CAAC,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAA,CAAA,GAAA,KAAA;AACA,KAAA,CAAA;AACA,IAAA,MAAA,OAAA,GAAAA,gBAAA,CAAA,wBAAA,EAAA,GAAA,kBAAA,CAAA;AACA,IAAAC,yBAAA,CAAA,EAAA,KAAA,EAAA,OAAA,EAAA,UAAA,EAAA,CAAA;AACA,GAAA,MAAA;AACA,IAAAA,yBAAA,CAAA,EAAA,KAAA,EAAA,OAAA,EAAA,wBAAA,EAAA,UAAA,EAAA,kBAAA,EAAA,CAAA;AACA;AACA;;;;"}
@@ -1,30 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
- const util = require('node:util');
3
+ const capture = require('./capture.js');
4
4
  const core = require('@sentry/core');
5
5
 
6
- /**
7
- * Capture a log with the given level.
8
- *
9
- * @param level - The level of the log.
10
- * @param message - The message to log.
11
- * @param attributes - Arbitrary structured data that stores information about the log - e.g., userId: 100.
12
- */
13
- function captureLog(level, ...args) {
14
- const [messageOrMessageTemplate, paramsOrAttributes, maybeAttributes] = args;
15
- if (Array.isArray(paramsOrAttributes)) {
16
- const attributes = { ...maybeAttributes };
17
- attributes['sentry.message.template'] = messageOrMessageTemplate;
18
- paramsOrAttributes.forEach((param, index) => {
19
- attributes[`sentry.message.param.${index}`] = param;
20
- });
21
- const message = util.format(messageOrMessageTemplate, ...paramsOrAttributes);
22
- core._INTERNAL_captureLog({ level, message, attributes });
23
- } else {
24
- core._INTERNAL_captureLog({ level, message: messageOrMessageTemplate, attributes: paramsOrAttributes });
25
- }
26
- }
27
-
28
6
  /**
29
7
  * @summary Capture a log with the `trace` level. Requires `_experiments.enableLogs` to be enabled.
30
8
  *
@@ -49,7 +27,7 @@ function captureLog(level, ...args) {
49
27
  * ```
50
28
  */
51
29
  function trace(...args) {
52
- captureLog('trace', ...args);
30
+ capture.captureLog('trace', ...args);
53
31
  }
54
32
 
55
33
  /**
@@ -76,7 +54,7 @@ function trace(...args) {
76
54
  * ```
77
55
  */
78
56
  function debug(...args) {
79
- captureLog('debug', ...args);
57
+ capture.captureLog('debug', ...args);
80
58
  }
81
59
 
82
60
  /**
@@ -103,7 +81,7 @@ function debug(...args) {
103
81
  * ```
104
82
  */
105
83
  function info(...args) {
106
- captureLog('info', ...args);
84
+ capture.captureLog('info', ...args);
107
85
  }
108
86
 
109
87
  /**
@@ -131,7 +109,7 @@ function info(...args) {
131
109
  * ```
132
110
  */
133
111
  function warn(...args) {
134
- captureLog('warn', ...args);
112
+ capture.captureLog('warn', ...args);
135
113
  }
136
114
 
137
115
  /**
@@ -159,7 +137,7 @@ function warn(...args) {
159
137
  * ```
160
138
  */
161
139
  function error(...args) {
162
- captureLog('error', ...args);
140
+ capture.captureLog('error', ...args);
163
141
  }
164
142
 
165
143
  /**
@@ -187,7 +165,7 @@ function error(...args) {
187
165
  * ```
188
166
  */
189
167
  function fatal(...args) {
190
- captureLog('fatal', ...args);
168
+ capture.captureLog('fatal', ...args);
191
169
  }
192
170
 
193
171
  exports.fmt = core.fmt;
@@ -197,4 +175,4 @@ exports.fatal = fatal;
197
175
  exports.info = info;
198
176
  exports.trace = trace;
199
177
  exports.warn = warn;
200
- //# sourceMappingURL=log.js.map
178
+ //# sourceMappingURL=exports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports.js","sources":["../../../src/logs/exports.ts"],"sourcesContent":["import { captureLog, type CaptureLogArgs } from './capture';\n\n/**\n * @summary Capture a log with the `trace` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * You can either pass a message and attributes or a message template, params and attributes.\n *\n * @example\n *\n * ```\n * Sentry.logger.trace('Starting database connection', {\n * database: 'users',\n * connectionId: 'conn_123'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.trace('Database connection %s established for %s',\n * ['successful', 'users'],\n * { connectionId: 'conn_123' }\n * );\n * ```\n */\nexport function trace(...args: CaptureLogArgs): void {\n captureLog('trace', ...args);\n}\n\n/**\n * @summary Capture a log with the `debug` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * You can either pass a message and attributes or a message template, params and attributes.\n *\n * @example\n *\n * ```\n * Sentry.logger.debug('Cache miss for user profile', {\n * userId: 'user_123',\n * cacheKey: 'profile:user_123'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.debug('Cache %s for %s: %s',\n * ['miss', 'user profile', 'key not found'],\n * { userId: 'user_123' }\n * );\n * ```\n */\nexport function debug(...args: CaptureLogArgs): void {\n captureLog('debug', ...args);\n}\n\n/**\n * @summary Capture a log with the `info` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * You can either pass a message and attributes or a message template, params and attributes.\n *\n * @example\n *\n * ```\n * Sentry.logger.info('User profile updated', {\n * userId: 'user_123',\n * updatedFields: ['email', 'preferences']\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.info('User %s updated their %s',\n * ['John Doe', 'profile settings'],\n * { userId: 'user_123' }\n * );\n * ```\n */\nexport function info(...args: CaptureLogArgs): void {\n captureLog('info', ...args);\n}\n\n/**\n * @summary Capture a log with the `warn` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * You can either pass a message and attributes or a message template, params and attributes.\n *\n * @example\n *\n * ```\n * Sentry.logger.warn('Rate limit approaching', {\n * endpoint: '/api/users',\n * currentRate: '95/100',\n * resetTime: '2024-03-20T10:00:00Z'\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.warn('Rate limit %s for %s: %s',\n * ['approaching', '/api/users', '95/100 requests'],\n * { resetTime: '2024-03-20T10:00:00Z' }\n * );\n * ```\n */\nexport function warn(...args: CaptureLogArgs): void {\n captureLog('warn', ...args);\n}\n\n/**\n * @summary Capture a log with the `error` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * You can either pass a message and attributes or a message template, params and attributes.\n *\n * @example\n *\n * ```\n * Sentry.logger.error('Failed to process payment', {\n * orderId: 'order_123',\n * errorCode: 'PAYMENT_FAILED',\n * amount: 99.99\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.error('Payment processing failed for order %s: %s',\n * ['order_123', 'insufficient funds'],\n * { amount: 99.99 }\n * );\n * ```\n */\nexport function error(...args: CaptureLogArgs): void {\n captureLog('error', ...args);\n}\n\n/**\n * @summary Capture a log with the `fatal` level. Requires `_experiments.enableLogs` to be enabled.\n *\n * You can either pass a message and attributes or a message template, params and attributes.\n *\n * @example\n *\n * ```\n * Sentry.logger.fatal('Database connection pool exhausted', {\n * database: 'users',\n * activeConnections: 100,\n * maxConnections: 100\n * });\n * ```\n *\n * @example With template strings\n *\n * ```\n * Sentry.logger.fatal('Database %s: %s connections active',\n * ['connection pool exhausted', '100/100'],\n * { database: 'users' }\n * );\n * ```\n */\nexport function fatal(...args: CaptureLogArgs): void {\n captureLog('fatal', ...args);\n}\n\nexport { fmt } from '@sentry/core';\n"],"names":["captureLog"],"mappings":";;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,GAAG,IAAI,EAAwB;AACrD,EAAEA,kBAAU,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;AAC9B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,GAAG,IAAI,EAAwB;AACrD,EAAEA,kBAAU,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;AAC9B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,GAAG,IAAI,EAAwB;AACpD,EAAEA,kBAAU,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,IAAI,CAAC,GAAG,IAAI,EAAwB;AACpD,EAAEA,kBAAU,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,GAAG,IAAI,EAAwB;AACrD,EAAEA,kBAAU,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;AAC9B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,KAAK,CAAC,GAAG,IAAI,EAAwB;AACrD,EAAEA,kBAAU,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;AAC9B;;;;;;;;;;"}
@@ -9,9 +9,25 @@ const INSTRUMENTED = {};
9
9
  * Instrument an OpenTelemetry instrumentation once.
10
10
  * This will skip running instrumentation again if it was already instrumented.
11
11
  */
12
- function generateInstrumentOnce
12
+ function generateInstrumentOnce(
13
+ name,
14
+ creatorOrClass,
15
+ optionsCallback,
16
+ ) {
17
+ if (optionsCallback) {
18
+ return _generateInstrumentOnceWithOptions(
19
+ name,
20
+ creatorOrClass ,
21
+ optionsCallback,
22
+ );
23
+ }
13
24
 
14
- (
25
+ return _generateInstrumentOnce(name, creatorOrClass );
26
+ }
27
+
28
+ // The plain version without handling of options
29
+ // Should not be used with custom options that are mutated in the creator!
30
+ function _generateInstrumentOnce(
15
31
  name,
16
32
  creator,
17
33
  ) {
@@ -39,6 +55,38 @@ function generateInstrumentOnce
39
55
  );
40
56
  }
41
57
 
58
+ // This version handles options properly
59
+ function _generateInstrumentOnceWithOptions
60
+
61
+ (
62
+ name,
63
+ instrumentationClass,
64
+ optionsCallback,
65
+ ) {
66
+ return Object.assign(
67
+ (_options) => {
68
+ const options = optionsCallback(_options);
69
+
70
+ const instrumented = INSTRUMENTED[name] ;
71
+ if (instrumented) {
72
+ // Ensure we update options
73
+ instrumented.setConfig(options);
74
+ return instrumented;
75
+ }
76
+
77
+ const instrumentation$1 = new instrumentationClass(options) ;
78
+ INSTRUMENTED[name] = instrumentation$1;
79
+
80
+ instrumentation.registerInstrumentations({
81
+ instrumentations: [instrumentation$1],
82
+ });
83
+
84
+ return instrumentation$1;
85
+ },
86
+ { id: name },
87
+ );
88
+ }
89
+
42
90
  /**
43
91
  * Ensure a given callback is called when the instrumentation is actually wrapping something.
44
92
  * This can be used to ensure some logic is only called when the instrumentation is actually active.
@@ -1 +1 @@
1
- {"version":3,"file":"instrument.js","sources":["../../../src/otel/instrument.ts"],"sourcesContent":["import { type Instrumentation, registerInstrumentations } from '@opentelemetry/instrumentation';\n\n/** Exported only for tests. */\nexport const INSTRUMENTED: Record<string, Instrumentation> = {};\n\n/**\n * Instrument an OpenTelemetry instrumentation once.\n * This will skip running instrumentation again if it was already instrumented.\n */\nexport function generateInstrumentOnce<\n Options = unknown,\n InstrumentationInstance extends Instrumentation = Instrumentation,\n>(\n name: string,\n creator: (options?: Options) => InstrumentationInstance,\n): ((options?: Options) => InstrumentationInstance) & { id: string } {\n return Object.assign(\n (options?: Options) => {\n const instrumented = INSTRUMENTED[name] as InstrumentationInstance | undefined;\n if (instrumented) {\n // If options are provided, ensure we update them\n if (options) {\n instrumented.setConfig(options);\n }\n return instrumented;\n }\n\n const instrumentation = creator(options);\n INSTRUMENTED[name] = instrumentation;\n\n registerInstrumentations({\n instrumentations: [instrumentation],\n });\n\n return instrumentation;\n },\n { id: name },\n );\n}\n\n/**\n * Ensure a given callback is called when the instrumentation is actually wrapping something.\n * This can be used to ensure some logic is only called when the instrumentation is actually active.\n *\n * This function returns a function that can be invoked with a callback.\n * This callback will either be invoked immediately\n * (e.g. if the instrumentation was already wrapped, or if _wrap could not be patched),\n * or once the instrumentation is actually wrapping something.\n *\n * Make sure to call this function right after adding the instrumentation, otherwise it may be too late!\n * The returned callback can be used any time, and also multiple times.\n */\nexport function instrumentWhenWrapped<T extends Instrumentation>(instrumentation: T): (callback: () => void) => void {\n let isWrapped = false;\n let callbacks: (() => void)[] = [];\n\n if (!hasWrap(instrumentation)) {\n isWrapped = true;\n } else {\n const originalWrap = instrumentation['_wrap'];\n\n instrumentation['_wrap'] = (...args: Parameters<typeof originalWrap>) => {\n isWrapped = true;\n callbacks.forEach(callback => callback());\n callbacks = [];\n return originalWrap(...args);\n };\n }\n\n const registerCallback = (callback: () => void): void => {\n if (isWrapped) {\n callback();\n } else {\n callbacks.push(callback);\n }\n };\n\n return registerCallback;\n}\n\nfunction hasWrap<T extends Instrumentation>(\n instrumentation: T,\n): instrumentation is T & { _wrap: (...args: unknown[]) => unknown } {\n return typeof (instrumentation as T & { _wrap?: (...args: unknown[]) => unknown })['_wrap'] === 'function';\n}\n"],"names":["instrumentation","registerInstrumentations"],"mappings":";;;;AAEA;AACa,MAAA,YAAY,GAAoC;;AAE7D;AACA;AACA;AACA;AACO,SAAS;;AAGhB;AACA,EAAE,IAAI;AACN,EAAE,OAAO;AACT,EAAqE;AACrE,EAAE,OAAO,MAAM,CAAC,MAAM;AACtB,IAAI,CAAC,OAAO,KAAe;AAC3B,MAAM,MAAM,YAAa,GAAE,YAAY,CAAC,IAAI,CAAE;AAC9C,MAAM,IAAI,YAAY,EAAE;AACxB;AACA,QAAQ,IAAI,OAAO,EAAE;AACr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ACjB,EAAqE;AACrE,EAAE,OAAO,OAAO,CAAC,eAAA,GAAoE,OAAO,CAAE,KAAI,UAAU;AAC5G;;;;;;"}
1
+ {"version":3,"file":"instrument.js","sources":["../../../src/otel/instrument.ts"],"sourcesContent":["import { type Instrumentation, registerInstrumentations } from '@opentelemetry/instrumentation';\n\n/** Exported only for tests. */\nexport const INSTRUMENTED: Record<string, Instrumentation> = {};\n\nexport function generateInstrumentOnce<\n Options,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n InstrumentationClass extends new (...args: any[]) => Instrumentation,\n>(\n name: string,\n instrumentationClass: InstrumentationClass,\n optionsCallback: (options: Options) => ConstructorParameters<InstrumentationClass>[0],\n): ((options: Options) => InstanceType<InstrumentationClass>) & { id: string };\nexport function generateInstrumentOnce<\n Options = unknown,\n InstrumentationInstance extends Instrumentation = Instrumentation,\n>(\n name: string,\n creator: (options?: Options) => InstrumentationInstance,\n): ((options?: Options) => InstrumentationInstance) & { id: string };\n/**\n * Instrument an OpenTelemetry instrumentation once.\n * This will skip running instrumentation again if it was already instrumented.\n */\nexport function generateInstrumentOnce<Options>(\n name: string,\n creatorOrClass: (new (...args: any[]) => Instrumentation) | ((options?: Options) => Instrumentation),\n optionsCallback?: (options: Options) => unknown,\n): ((options: Options) => Instrumentation) & { id: string } {\n if (optionsCallback) {\n return _generateInstrumentOnceWithOptions(\n name,\n creatorOrClass as new (...args: unknown[]) => Instrumentation,\n optionsCallback,\n );\n }\n\n return _generateInstrumentOnce(name, creatorOrClass as (options?: Options) => Instrumentation);\n}\n\n// The plain version without handling of options\n// Should not be used with custom options that are mutated in the creator!\nfunction _generateInstrumentOnce<Options = unknown, InstrumentationInstance extends Instrumentation = Instrumentation>(\n name: string,\n creator: (options?: Options) => InstrumentationInstance,\n): ((options?: Options) => InstrumentationInstance) & { id: string } {\n return Object.assign(\n (options?: Options) => {\n const instrumented = INSTRUMENTED[name] as InstrumentationInstance | undefined;\n if (instrumented) {\n // If options are provided, ensure we update them\n if (options) {\n instrumented.setConfig(options);\n }\n return instrumented;\n }\n\n const instrumentation = creator(options);\n INSTRUMENTED[name] = instrumentation;\n\n registerInstrumentations({\n instrumentations: [instrumentation],\n });\n\n return instrumentation;\n },\n { id: name },\n );\n}\n\n// This version handles options properly\nfunction _generateInstrumentOnceWithOptions<\n Options,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n InstrumentationClass extends new (...args: any[]) => Instrumentation,\n>(\n name: string,\n instrumentationClass: InstrumentationClass,\n optionsCallback: (options: Options) => ConstructorParameters<InstrumentationClass>[0],\n): ((options: Options) => InstanceType<InstrumentationClass>) & { id: string } {\n return Object.assign(\n (_options: Options) => {\n const options = optionsCallback(_options);\n\n const instrumented = INSTRUMENTED[name] as InstanceType<InstrumentationClass> | undefined;\n if (instrumented) {\n // Ensure we update options\n instrumented.setConfig(options);\n return instrumented;\n }\n\n const instrumentation = new instrumentationClass(options) as InstanceType<InstrumentationClass>;\n INSTRUMENTED[name] = instrumentation;\n\n registerInstrumentations({\n instrumentations: [instrumentation],\n });\n\n return instrumentation;\n },\n { id: name },\n );\n}\n\n/**\n * Ensure a given callback is called when the instrumentation is actually wrapping something.\n * This can be used to ensure some logic is only called when the instrumentation is actually active.\n *\n * This function returns a function that can be invoked with a callback.\n * This callback will either be invoked immediately\n * (e.g. if the instrumentation was already wrapped, or if _wrap could not be patched),\n * or once the instrumentation is actually wrapping something.\n *\n * Make sure to call this function right after adding the instrumentation, otherwise it may be too late!\n * The returned callback can be used any time, and also multiple times.\n */\nexport function instrumentWhenWrapped<T extends Instrumentation>(instrumentation: T): (callback: () => void) => void {\n let isWrapped = false;\n let callbacks: (() => void)[] = [];\n\n if (!hasWrap(instrumentation)) {\n isWrapped = true;\n } else {\n const originalWrap = instrumentation['_wrap'];\n\n instrumentation['_wrap'] = (...args: Parameters<typeof originalWrap>) => {\n isWrapped = true;\n callbacks.forEach(callback => callback());\n callbacks = [];\n return originalWrap(...args);\n };\n }\n\n const registerCallback = (callback: () => void): void => {\n if (isWrapped) {\n callback();\n } else {\n callbacks.push(callback);\n }\n };\n\n return registerCallback;\n}\n\nfunction hasWrap<T extends Instrumentation>(\n instrumentation: T,\n): instrumentation is T & { _wrap: (...args: unknown[]) => unknown } {\n return typeof (instrumentation as T & { _wrap?: (...args: unknown[]) => unknown })['_wrap'] === 'function';\n}\n"],"names":["instrumentation","registerInstrumentations"],"mappings":";;;;AAEA;AACa,MAAA,YAAY,GAAoC;;AAkB7D;AACA;AACA;AACA;AACO,SAAS,sBAAsB;AACtC,EAAE,IAAI;AACN,EAAE,cAAc;AAChB,EAAE,eAAe;AACjB,EAA4D;AAC5D,EAAE,IAAI,eAAe,EAAE;AACvB,IAAI,OAAO,kCAAkC;AAC7C,MAAM,IAAI;AACV,MAAM,cAAe;AACrB,MAAM,eAAe;AACrB,KAAK;AACL;;AAEA,EAAE,OAAO,uBAAuB,CAAC,IAAI,EAAE,gBAAyD;AAChG;;AAEA;AACA;AACA,SAAS,uBAAuB;AAChC,EAAE,IAAI;AACN,EAAE,OAAO;AACT,EAAqE;AACrE,EAAE,OAAO,MAAM,CAAC,MAAM;AACtB,IAAI,CAAC,OAAO,KAAe;AAC3B,MAAM,MAAM,YAAa,GAAE,YAAY,CAAC,IAAI,CAAE;AAC9C,MAAM,IAAI,YAAY,EAAE;AACxB;AACA,QAAQ,IAAI,OAAO,EAAE;AACrB,UAAU,YAAY,CAAC,SAAS,CAAC,OAAO,CAAC;AACzC;AACA,QAAQ,OAAO,YAAY;AAC3B;;AAEA,MAAM,MAAMA,iBAAgB,GAAE,OAAO,CAAC,OAAO,CAAC;AAC9C,MAAM,YAAY,CAAC,IAAI,CAAA,GAAIA,iBAAe;;AAE1C,MAAMC,wCAAwB,CAAC;AAC/B,QAAQ,gBAAgB,EAAE,CAACD,iBAAe,CAAC;AAC3C,OAAO,CAAC;;AAER,MAAM,OAAOA,iBAAe;AAC5B,KAAK;AACL,IAAI,EAAE,EAAE,EAAE,IAAA,EAAM;AAChB,GAAG;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pB,MAAM,OAAO,YAAY,CAAC,GAAG,IAAI,CAAC;AAClC,KAAK;AACL;;AAEA,EAAE,MAAM,gBAAA,GAAmB,CAAC,QAAQ,KAAuB;AAC3D,IAAI,IAAI,SAAS,EAAE;AACnB,MAAM,QAAQ,EAAE;AAChB,WAAW;AACX,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC9B;AACA,GAAG;;AAEH,EAAE,OAAO,gBAAgB;AACzB;;AAEA,SAAS,OAAO;AAChB,EAAE,eAAe;AACjB,EAAqE;AACrE,EAAE,OAAO,OAAO,CAAC,eAAA,GAAoE,OAAO,CAAE,KAAI,UAAU;AAC5G;;;;;;"}
@@ -14,11 +14,12 @@ const DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS = 60000; // 60s was chosen arbitra
14
14
  class NodeClient extends core.ServerRuntimeClient {
15
15
 
16
16
  constructor(options) {
17
+ const serverName = options.serverName || global.process.env.SENTRY_NAME || os.hostname();
17
18
  const clientOptions = {
18
19
  ...options,
19
20
  platform: 'node',
20
21
  runtime: { name: 'node', version: global.process.version },
21
- serverName: options.serverName || global.process.env.SENTRY_NAME || os.hostname(),
22
+ serverName,
22
23
  };
23
24
 
24
25
  if (options.openTelemetryInstrumentations) {
@@ -34,6 +35,23 @@ class NodeClient extends core.ServerRuntimeClient {
34
35
  );
35
36
 
36
37
  super(clientOptions);
38
+
39
+ if (this.getOptions()._experiments?.enableLogs) {
40
+ this._logOnExitFlushListener = () => {
41
+ core._INTERNAL_flushLogsBuffer(this);
42
+ };
43
+
44
+ if (serverName) {
45
+ this.on('beforeCaptureLog', log => {
46
+ log.attributes = {
47
+ ...log.attributes,
48
+ 'server.address': serverName,
49
+ };
50
+ });
51
+ }
52
+
53
+ process.on('beforeExit', this._logOnExitFlushListener);
54
+ }
37
55
  }
38
56
 
39
57
  /** Get the OTEL tracer. */
@@ -78,6 +96,10 @@ class NodeClient extends core.ServerRuntimeClient {
78
96
  process.off('beforeExit', this._clientReportOnExitFlushListener);
79
97
  }
80
98
 
99
+ if (this._logOnExitFlushListener) {
100
+ process.off('beforeExit', this._logOnExitFlushListener);
101
+ }
102
+
81
103
  return super.close(timeout);
82
104
  }
83
105
 
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sources":["../../../src/sdk/client.ts"],"sourcesContent":["import * as os from 'node:os';\nimport type { Tracer } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport { registerInstrumentations } from '@opentelemetry/instrumentation';\nimport type { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';\nimport type { DynamicSamplingContext, Scope, ServerRuntimeClientOptions, TraceContext } from '@sentry/core';\nimport { SDK_VERSION, ServerRuntimeClient, applySdkMetadata, logger } from '@sentry/core';\nimport { getTraceContextForScope } from '@sentry/opentelemetry';\nimport { isMainThread, threadId } from 'worker_threads';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { NodeClientOptions } from '../types';\n\nconst DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS = 60_000; // 60s was chosen arbitrarily\n\n/** A client for using Sentry with Node & OpenTelemetry. */\nexport class NodeClient extends ServerRuntimeClient<NodeClientOptions> {\n public traceProvider: BasicTracerProvider | undefined;\n private _tracer: Tracer | undefined;\n private _clientReportInterval: NodeJS.Timeout | undefined;\n private _clientReportOnExitFlushListener: (() => void) | undefined;\n\n public constructor(options: NodeClientOptions) {\n const clientOptions: ServerRuntimeClientOptions = {\n ...options,\n platform: 'node',\n runtime: { name: 'node', version: global.process.version },\n serverName: options.serverName || global.process.env.SENTRY_NAME || os.hostname(),\n };\n\n if (options.openTelemetryInstrumentations) {\n registerInstrumentations({\n instrumentations: options.openTelemetryInstrumentations,\n });\n }\n\n applySdkMetadata(clientOptions, 'node');\n\n logger.log(\n `Initializing Sentry: process: ${process.pid}, thread: ${isMainThread ? 'main' : `worker-${threadId}`}.`,\n );\n\n super(clientOptions);\n }\n\n /** Get the OTEL tracer. */\n public get tracer(): Tracer {\n if (this._tracer) {\n return this._tracer;\n }\n\n const name = '@sentry/node';\n const version = SDK_VERSION;\n const tracer = trace.getTracer(name, version);\n this._tracer = tracer;\n\n return tracer;\n }\n\n // Eslint ignore explanation: This is already documented in super.\n // eslint-disable-next-line jsdoc/require-jsdoc\n public async flush(timeout?: number): Promise<boolean> {\n const provider = this.traceProvider;\n const spanProcessor = provider?.activeSpanProcessor;\n\n if (spanProcessor) {\n await spanProcessor.forceFlush();\n }\n\n if (this.getOptions().sendClientReports) {\n this._flushOutcomes();\n }\n\n return super.flush(timeout);\n }\n\n // Eslint ignore explanation: This is already documented in super.\n // eslint-disable-next-line jsdoc/require-jsdoc\n public close(timeout?: number | undefined): PromiseLike<boolean> {\n if (this._clientReportInterval) {\n clearInterval(this._clientReportInterval);\n }\n\n if (this._clientReportOnExitFlushListener) {\n process.off('beforeExit', this._clientReportOnExitFlushListener);\n }\n\n return super.close(timeout);\n }\n\n /**\n * Will start tracking client reports for this client.\n *\n * NOTICE: This method will create an interval that is periodically called and attach a `process.on('beforeExit')`\n * hook. To clean up these resources, call `.close()` when you no longer intend to use the client. Not doing so will\n * result in a memory leak.\n */\n // The reason client reports need to be manually activated with this method instead of just enabling them in a\n // constructor, is that if users periodically and unboundedly create new clients, we will create more and more\n // intervals and beforeExit listeners, thus leaking memory. In these situations, users are required to call\n // `client.close()` in order to dispose of the acquired resources.\n // We assume that calling this method in Sentry.init() is a sensible default, because calling Sentry.init() over and\n // over again would also result in memory leaks.\n // Note: We have experimented with using `FinalizationRegisty` to clear the interval when the client is garbage\n // collected, but it did not work, because the cleanup function never got called.\n public startClientReportTracking(): void {\n const clientOptions = this.getOptions();\n if (clientOptions.sendClientReports) {\n this._clientReportOnExitFlushListener = () => {\n this._flushOutcomes();\n };\n\n this._clientReportInterval = setInterval(() => {\n DEBUG_BUILD && logger.log('Flushing client reports based on interval.');\n this._flushOutcomes();\n }, clientOptions.clientReportFlushInterval ?? DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS)\n // Unref is critical for not preventing the process from exiting because the interval is active.\n .unref();\n\n process.on('beforeExit', this._clientReportOnExitFlushListener);\n }\n }\n\n /** Custom implementation for OTEL, so we can handle scope-span linking. */\n protected _getTraceInfoFromScope(\n scope: Scope | undefined,\n ): [dynamicSamplingContext: Partial<DynamicSamplingContext> | undefined, traceContext: TraceContext | undefined] {\n if (!scope) {\n return [undefined, undefined];\n }\n\n return getTraceContextForScope(this, scope);\n }\n}\n"],"names":["ServerRuntimeClient","registerInstrumentations","applySdkMetadata","logger","isMainThread","threadId","SDK_VERSION","trace","DEBUG_BUILD","getTraceContextForScope"],"mappings":";;;;;;;;;;AAYA,MAAM,uCAAA,GAA0C,KAAM,CAAA;;AAEtD;AACO,MAAM,UAAA,SAAmBA,wBAAmB,CAAoB;;AAMvE,GAAS,WAAW,CAAC,OAAO,EAAqB;AACjD,IAAI,MAAM,aAAa,GAA+B;AACtD,MAAM,GAAG,OAAO;AAChB,MAAM,QAAQ,EAAE,MAAM;AACtB,MAAM,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;AAChE,MAAM,UAAU,EAAE,OAAO,CAAC,UAAW,IAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,WAAY,IAAG,EAAE,CAAC,QAAQ,EAAE;AACvF,KAAK;;AAEL,IAAI,IAAI,OAAO,CAAC,6BAA6B,EAAE;AAC/C,MAAMC,wCAAwB,CAAC;AAC/B,QAAQ,gBAAgB,EAAE,OAAO,CAAC,6BAA6B;AAC/D,OAAO,CAAC;AACR;;AAEA,IAAIC,qBAAgB,CAAC,aAAa,EAAE,MAAM,CAAC;;AAE3C,IAAIC,WAAM,CAAC,GAAG;AACd,MAAM,CAAC,8BAA8B,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,EAAEC,2BAAa,GAAE,SAAS,CAAC,OAAO,EAAEC,uBAAQ,CAAC,CAAA,CAAA,CAAA,CAAA;AACA,KAAA;;AAEA,IAAA,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AACA,IAAA,IAAA,aAAA,CAAA,iBAAA,EAAA;AACA,MAAA,IAAA,CAAA,gCAAA,GAAA,MAAA;AACA,QAAA,IAAA,CAAA,cAAA,EAAA;AACA,OAAA;;AAEA,MAAA,IAAA,CAAA,qBAAA,GAAA,WAAA,CAAA,MAAA;AACA,QAAAC,sBAAA,IAAAL,WAAA,CAAA,GAAA,CAAA,4CAAA,CAAA;AACA,QAAA,IAAA,CAAA,cAAA,EAAA;AACA,OAAA,EAAA,aAAA,CAAA,yBAAA,IAAA,uCAAA;AACA;AACA,SAAA,KAAA,EAAA;;AAEA,MAAA,OAAA,CAAA,EAAA,CAAA,YAAA,EAAA,IAAA,CAAA,gCAAA,CAAA;AACA;AACA;;AAEA;AACA,GAAA,sBAAA;AACA,IAAA,KAAA;AACA,IAAA;AACA,IAAA,IAAA,CAAA,KAAA,EAAA;AACA,MAAA,OAAA,CAAA,SAAA,EAAA,SAAA,CAAA;AACA;;AAEA,IAAA,OAAAM,qCAAA,CAAA,IAAA,EAAA,KAAA,CAAA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"client.js","sources":["../../../src/sdk/client.ts"],"sourcesContent":["import * as os from 'node:os';\nimport type { Tracer } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\nimport { registerInstrumentations } from '@opentelemetry/instrumentation';\nimport type { BasicTracerProvider } from '@opentelemetry/sdk-trace-base';\nimport type { DynamicSamplingContext, Scope, ServerRuntimeClientOptions, TraceContext } from '@sentry/core';\nimport { _INTERNAL_flushLogsBuffer, SDK_VERSION, ServerRuntimeClient, applySdkMetadata, logger } from '@sentry/core';\nimport { getTraceContextForScope } from '@sentry/opentelemetry';\nimport { isMainThread, threadId } from 'worker_threads';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { NodeClientOptions } from '../types';\n\nconst DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS = 60_000; // 60s was chosen arbitrarily\n\n/** A client for using Sentry with Node & OpenTelemetry. */\nexport class NodeClient extends ServerRuntimeClient<NodeClientOptions> {\n public traceProvider: BasicTracerProvider | undefined;\n private _tracer: Tracer | undefined;\n private _clientReportInterval: NodeJS.Timeout | undefined;\n private _clientReportOnExitFlushListener: (() => void) | undefined;\n private _logOnExitFlushListener: (() => void) | undefined;\n\n public constructor(options: NodeClientOptions) {\n const serverName = options.serverName || global.process.env.SENTRY_NAME || os.hostname();\n const clientOptions: ServerRuntimeClientOptions = {\n ...options,\n platform: 'node',\n runtime: { name: 'node', version: global.process.version },\n serverName,\n };\n\n if (options.openTelemetryInstrumentations) {\n registerInstrumentations({\n instrumentations: options.openTelemetryInstrumentations,\n });\n }\n\n applySdkMetadata(clientOptions, 'node');\n\n logger.log(\n `Initializing Sentry: process: ${process.pid}, thread: ${isMainThread ? 'main' : `worker-${threadId}`}.`,\n );\n\n super(clientOptions);\n\n if (this.getOptions()._experiments?.enableLogs) {\n this._logOnExitFlushListener = () => {\n _INTERNAL_flushLogsBuffer(this);\n };\n\n if (serverName) {\n this.on('beforeCaptureLog', log => {\n log.attributes = {\n ...log.attributes,\n 'server.address': serverName,\n };\n });\n }\n\n process.on('beforeExit', this._logOnExitFlushListener);\n }\n }\n\n /** Get the OTEL tracer. */\n public get tracer(): Tracer {\n if (this._tracer) {\n return this._tracer;\n }\n\n const name = '@sentry/node';\n const version = SDK_VERSION;\n const tracer = trace.getTracer(name, version);\n this._tracer = tracer;\n\n return tracer;\n }\n\n // Eslint ignore explanation: This is already documented in super.\n // eslint-disable-next-line jsdoc/require-jsdoc\n public async flush(timeout?: number): Promise<boolean> {\n const provider = this.traceProvider;\n const spanProcessor = provider?.activeSpanProcessor;\n\n if (spanProcessor) {\n await spanProcessor.forceFlush();\n }\n\n if (this.getOptions().sendClientReports) {\n this._flushOutcomes();\n }\n\n return super.flush(timeout);\n }\n\n // Eslint ignore explanation: This is already documented in super.\n // eslint-disable-next-line jsdoc/require-jsdoc\n public close(timeout?: number | undefined): PromiseLike<boolean> {\n if (this._clientReportInterval) {\n clearInterval(this._clientReportInterval);\n }\n\n if (this._clientReportOnExitFlushListener) {\n process.off('beforeExit', this._clientReportOnExitFlushListener);\n }\n\n if (this._logOnExitFlushListener) {\n process.off('beforeExit', this._logOnExitFlushListener);\n }\n\n return super.close(timeout);\n }\n\n /**\n * Will start tracking client reports for this client.\n *\n * NOTICE: This method will create an interval that is periodically called and attach a `process.on('beforeExit')`\n * hook. To clean up these resources, call `.close()` when you no longer intend to use the client. Not doing so will\n * result in a memory leak.\n */\n // The reason client reports need to be manually activated with this method instead of just enabling them in a\n // constructor, is that if users periodically and unboundedly create new clients, we will create more and more\n // intervals and beforeExit listeners, thus leaking memory. In these situations, users are required to call\n // `client.close()` in order to dispose of the acquired resources.\n // We assume that calling this method in Sentry.init() is a sensible default, because calling Sentry.init() over and\n // over again would also result in memory leaks.\n // Note: We have experimented with using `FinalizationRegisty` to clear the interval when the client is garbage\n // collected, but it did not work, because the cleanup function never got called.\n public startClientReportTracking(): void {\n const clientOptions = this.getOptions();\n if (clientOptions.sendClientReports) {\n this._clientReportOnExitFlushListener = () => {\n this._flushOutcomes();\n };\n\n this._clientReportInterval = setInterval(() => {\n DEBUG_BUILD && logger.log('Flushing client reports based on interval.');\n this._flushOutcomes();\n }, clientOptions.clientReportFlushInterval ?? DEFAULT_CLIENT_REPORT_FLUSH_INTERVAL_MS)\n // Unref is critical for not preventing the process from exiting because the interval is active.\n .unref();\n\n process.on('beforeExit', this._clientReportOnExitFlushListener);\n }\n }\n\n /** Custom implementation for OTEL, so we can handle scope-span linking. */\n protected _getTraceInfoFromScope(\n scope: Scope | undefined,\n ): [dynamicSamplingContext: Partial<DynamicSamplingContext> | undefined, traceContext: TraceContext | undefined] {\n if (!scope) {\n return [undefined, undefined];\n }\n\n return getTraceContextForScope(this, scope);\n }\n}\n"],"names":["ServerRuntimeClient","registerInstrumentations","applySdkMetadata","logger","isMainThread","threadId","_INTERNAL_flushLogsBuffer","SDK_VERSION","trace","DEBUG_BUILD","getTraceContextForScope"],"mappings":";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AAA,CAAA,uBAAA,CAAA;AACA;;AAEA,IAAA,OAAA,KAAA,CAAA,KAAA,CAAA,OAAA,CAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAA,yBAAA,GAAA;AACA,IAAA,MAAA,aAAA,GAAA,IAAA,CAAA,UAAA,EAAA;AACA,IAAA,IAAA,aAAA,CAAA,iBAAA,EAAA;AACA,MAAA,IAAA,CAAA,gCAAA,GAAA,MAAA;AACA,QAAA,IAAA,CAAA,cAAA,EAAA;AACA,OAAA;;AAEA,MAAA,IAAA,CAAA,qBAAA,GAAA,WAAA,CAAA,MAAA;AACA,QAAAC,sBAAA,IAAAN,WAAA,CAAA,GAAA,CAAA,4CAAA,CAAA;AACA,QAAA,IAAA,CAAA,cAAA,EAAA;AACA,OAAA,EAAA,aAAA,CAAA,yBAAA,IAAA,uCAAA;AACA;AACA,SAAA,KAAA,EAAA;;AAEA,MAAA,OAAA,CAAA,EAAA,CAAA,YAAA,EAAA,IAAA,CAAA,gCAAA,CAAA;AACA;AACA;;AAEA;AACA,GAAA,sBAAA;AACA,IAAA,KAAA;AACA,IAAA;AACA,IAAA,IAAA,CAAA,KAAA,EAAA;AACA,MAAA,OAAA,CAAA,SAAA,EAAA,SAAA,CAAA;AACA;;AAEA,IAAA,OAAAO,qCAAA,CAAA,IAAA,EAAA,KAAA,CAAA;AACA;AACA;;;;"}
@@ -4,7 +4,6 @@ const core = require('@sentry/core');
4
4
  const opentelemetry = require('@sentry/opentelemetry');
5
5
  const debugBuild = require('../debug-build.js');
6
6
  const childProcess = require('../integrations/childProcess.js');
7
- const console$1 = require('../integrations/console.js');
8
7
  const context = require('../integrations/context.js');
9
8
  const contextlines = require('../integrations/contextlines.js');
10
9
  const index$1 = require('../integrations/http/index.js');
@@ -40,7 +39,7 @@ function getDefaultIntegrationsWithoutPerformance() {
40
39
  core.linkedErrorsIntegration(),
41
40
  core.requestDataIntegration(),
42
41
  // Native Wrappers
43
- console$1.consoleIntegration(),
42
+ core.consoleIntegration(),
44
43
  index$1.httpIntegration(),
45
44
  index$2.nativeNodeFetchIntegration(),
46
45
  // Global Handlers
@@ -197,6 +196,7 @@ function getClientOptions(
197
196
  release,
198
197
  tracesSampleRate,
199
198
  spotlight,
199
+ debug: envToBool.envToBool(options.debug ?? process.env.SENTRY_DEBUG),
200
200
  };
201
201
 
202
202
  const integrations = options.integrations;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/sdk/index.ts"],"sourcesContent":["import type { Integration, Options } from '@sentry/core';\nimport {\n consoleSandbox,\n functionToStringIntegration,\n getCurrentScope,\n getIntegrationsToSetup,\n hasSpansEnabled,\n inboundFiltersIntegration,\n linkedErrorsIntegration,\n logger,\n propagationContextFromHeaders,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n} from '@sentry/core';\nimport {\n enhanceDscWithOpenTelemetryRootSpanName,\n openTelemetrySetupCheck,\n setOpenTelemetryContextAsyncContextStrategy,\n setupEventContextTrace,\n} from '@sentry/opentelemetry';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { childProcessIntegration } from '../integrations/childProcess';\nimport { consoleIntegration } from '../integrations/console';\nimport { nodeContextIntegration } from '../integrations/context';\nimport { contextLinesIntegration } from '../integrations/contextlines';\nimport { httpIntegration } from '../integrations/http';\nimport { localVariablesIntegration } from '../integrations/local-variables';\nimport { modulesIntegration } from '../integrations/modules';\nimport { nativeNodeFetchIntegration } from '../integrations/node-fetch';\nimport { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception';\nimport { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection';\nimport { processSessionIntegration } from '../integrations/processSession';\nimport { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight';\nimport { getAutoPerformanceIntegrations } from '../integrations/tracing';\nimport { makeNodeTransport } from '../transports';\nimport type { NodeClientOptions, NodeOptions } from '../types';\nimport { isCjs } from '../utils/commonjs';\nimport { envToBool } from '../utils/envToBool';\nimport { defaultStackParser, getSentryRelease } from './api';\nimport { NodeClient } from './client';\nimport { initOpenTelemetry, maybeInitializeEsmLoader } from './initOtel';\n\nfunction getCjsOnlyIntegrations(): Integration[] {\n return isCjs() ? [modulesIntegration()] : [];\n}\n\n/**\n * Get default integrations, excluding performance.\n */\nexport function getDefaultIntegrationsWithoutPerformance(): Integration[] {\n return [\n // Common\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n requestDataIntegration(),\n // Native Wrappers\n consoleIntegration(),\n httpIntegration(),\n nativeNodeFetchIntegration(),\n // Global Handlers\n onUncaughtExceptionIntegration(),\n onUnhandledRejectionIntegration(),\n // Event Info\n contextLinesIntegration(),\n localVariablesIntegration(),\n nodeContextIntegration(),\n childProcessIntegration(),\n processSessionIntegration(),\n ...getCjsOnlyIntegrations(),\n ];\n}\n\n/** Get the default integrations for the Node SDK. */\nexport function getDefaultIntegrations(options: Options): Integration[] {\n return [\n ...getDefaultIntegrationsWithoutPerformance(),\n // We only add performance integrations if tracing is enabled\n // Note that this means that without tracing enabled, e.g. `expressIntegration()` will not be added\n // This means that generally request isolation will work (because that is done by httpIntegration)\n // But `transactionName` will not be set automatically\n ...(hasSpansEnabled(options) ? getAutoPerformanceIntegrations() : []),\n ];\n}\n\n/**\n * Initialize Sentry for Node.\n */\nexport function init(options: NodeOptions | undefined = {}): NodeClient | undefined {\n return _init(options, getDefaultIntegrations);\n}\n\n/**\n * Initialize Sentry for Node, without any integrations added by default.\n */\nexport function initWithoutDefaultIntegrations(options: NodeOptions | undefined = {}): NodeClient {\n return _init(options, () => []);\n}\n\n/**\n * Initialize Sentry for Node, without performance instrumentation.\n */\nfunction _init(\n _options: NodeOptions | undefined = {},\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClient {\n const options = getClientOptions(_options, getDefaultIntegrationsImpl);\n\n if (options.debug === true) {\n if (DEBUG_BUILD) {\n logger.enable();\n } else {\n // use `console.warn` rather than `logger.warn` since by non-debug bundles have all `logger.x` statements stripped\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');\n });\n }\n }\n\n if (!isCjs() && options.registerEsmLoaderHooks !== false) {\n maybeInitializeEsmLoader();\n }\n\n setOpenTelemetryContextAsyncContextStrategy();\n\n const scope = getCurrentScope();\n scope.update(options.initialScope);\n\n if (options.spotlight && !options.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {\n options.integrations.push(\n spotlightIntegration({\n sidecarUrl: typeof options.spotlight === 'string' ? options.spotlight : undefined,\n }),\n );\n }\n\n const client = new NodeClient(options);\n // The client is on the current scope, from where it generally is inherited\n getCurrentScope().setClient(client);\n\n client.init();\n\n logger.log(`Running in ${isCjs() ? 'CommonJS' : 'ESM'} mode.`);\n\n client.startClientReportTracking();\n\n updateScopeFromEnvVariables();\n\n // If users opt-out of this, they _have_ to set up OpenTelemetry themselves\n // There is no way to use this SDK without OpenTelemetry!\n if (!options.skipOpenTelemetrySetup) {\n initOpenTelemetry(client, {\n spanProcessors: options.openTelemetrySpanProcessors,\n });\n validateOpenTelemetrySetup();\n }\n\n enhanceDscWithOpenTelemetryRootSpanName(client);\n setupEventContextTrace(client);\n\n return client;\n}\n\n/**\n * Validate that your OpenTelemetry setup is correct.\n */\nexport function validateOpenTelemetrySetup(): void {\n if (!DEBUG_BUILD) {\n return;\n }\n\n const setup = openTelemetrySetupCheck();\n\n const required: ReturnType<typeof openTelemetrySetupCheck> = ['SentryContextManager', 'SentryPropagator'];\n\n if (hasSpansEnabled()) {\n required.push('SentrySpanProcessor');\n }\n\n for (const k of required) {\n if (!setup.includes(k)) {\n logger.error(\n `You have to set up the ${k}. Without this, the OpenTelemetry & Sentry integration will not work properly.`,\n );\n }\n }\n\n if (!setup.includes('SentrySampler')) {\n logger.warn(\n 'You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.',\n );\n }\n}\n\nfunction getClientOptions(\n options: NodeOptions,\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClientOptions {\n const release = getRelease(options.release);\n const spotlight =\n options.spotlight ?? envToBool(process.env.SENTRY_SPOTLIGHT, { strict: true }) ?? process.env.SENTRY_SPOTLIGHT;\n const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);\n\n const mergedOptions = {\n ...options,\n dsn: options.dsn ?? process.env.SENTRY_DSN,\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT,\n sendClientReports: options.sendClientReports ?? true,\n transport: options.transport ?? makeNodeTransport,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n release,\n tracesSampleRate,\n spotlight,\n };\n\n const integrations = options.integrations;\n const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(mergedOptions);\n\n return {\n ...mergedOptions,\n integrations: getIntegrationsToSetup({\n defaultIntegrations,\n integrations,\n }),\n };\n}\n\nfunction getRelease(release: NodeOptions['release']): string | undefined {\n if (release !== undefined) {\n return release;\n }\n\n const detectedRelease = getSentryRelease();\n if (detectedRelease !== undefined) {\n return detectedRelease;\n }\n\n return undefined;\n}\n\nfunction getTracesSampleRate(tracesSampleRate: NodeOptions['tracesSampleRate']): number | undefined {\n if (tracesSampleRate !== undefined) {\n return tracesSampleRate;\n }\n\n const sampleRateFromEnv = process.env.SENTRY_TRACES_SAMPLE_RATE;\n if (!sampleRateFromEnv) {\n return undefined;\n }\n\n const parsed = parseFloat(sampleRateFromEnv);\n return isFinite(parsed) ? parsed : undefined;\n}\n\n/**\n * Update scope and propagation context based on environmental variables.\n *\n * See https://github.com/getsentry/rfcs/blob/main/text/0071-continue-trace-over-process-boundaries.md\n * for more details.\n */\nfunction updateScopeFromEnvVariables(): void {\n if (envToBool(process.env.SENTRY_USE_ENVIRONMENT) !== false) {\n const sentryTraceEnv = process.env.SENTRY_TRACE;\n const baggageEnv = process.env.SENTRY_BAGGAGE;\n const propagationContext = propagationContextFromHeaders(sentryTraceEnv, baggageEnv);\n getCurrentScope().setPropagationContext(propagationContext);\n }\n}\n"],"names":["isCjs","modulesIntegration","inboundFiltersIntegration","functionToStringIntegration","linkedErrorsIntegration","requestDataIntegration","consoleIntegration","httpIntegration","nativeNodeFetchIntegration","onUncaughtExceptionIntegration","onUnhandledRejectionIntegration","contextLinesIntegration","localVariablesIntegration","nodeContextIntegration","childProcessIntegration","processSessionIntegration","hasSpansEnabled","getAutoPerformanceIntegrations","DEBUG_BUILD","logger","consoleSandbox","maybeInitializeEsmLoader","setOpenTelemetryContextAsyncContextStrategy","getCurrentScope","SPOTLIGHT_INTEGRATION_NAME","spotlightIntegration","client","NodeClient","initOpenTelemetry","enhanceDscWithOpenTelemetryRootSpanName","setupEventContextTrace","openTelemetrySetupCheck","envToBool","makeNodeTransport","stackParserFromStackParserOptions","defaultStackParser","getIntegrationsToSetup","getSentryRelease","propagationContextFromHeaders"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAS,sBAAsB,GAAkB;AACjD,EAAE,OAAOA,cAAK,EAAC,GAAI,CAACC,0BAAkB,EAAE,CAAA,GAAI,EAAE;AAC9C;;AAEA;AACA;AACA;AACO,SAAS,wCAAwC,GAAkB;AAC1E,EAAE,OAAO;AACT;AACA;AACA;AACA,IAAIC,8BAAyB,EAAE;AAC/B,IAAIC,gCAA2B,EAAE;AACjC,IAAIC,4BAAuB,EAAE;AAC7B,IAAIC,2BAAsB,EAAE;AAC5B;AACA,IAAIC,4BAAkB,EAAE;AACxB,IAAIC,uBAAe,EAAE;AACrB,IAAIC,kCAA0B,EAAE;AAChC;AACA,IAAIC,kDAA8B,EAAE;AACpC,IAAIC,oDAA+B,EAAE;AACrC;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,IAAIL,mBAAS,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAA,KAAM,KAAK,EAAE;AAC/D,IAAI,MAAM,cAAe,GAAE,OAAO,CAAC,GAAG,CAAC,YAAY;AACnD,IAAI,MAAM,UAAW,GAAE,OAAO,CAAC,GAAG,CAAC,cAAc;AACjD,IAAI,MAAM,qBAAqBM,kCAA6B,CAAC,cAAc,EAAE,UAAU,CAAC;AACxF,IAAIf,oBAAe,EAAE,CAAC,qBAAqB,CAAC,kBAAkB,CAAC;AAC/D;AACA;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/sdk/index.ts"],"sourcesContent":["import type { Integration, Options } from '@sentry/core';\nimport {\n consoleSandbox,\n functionToStringIntegration,\n getCurrentScope,\n getIntegrationsToSetup,\n hasSpansEnabled,\n inboundFiltersIntegration,\n linkedErrorsIntegration,\n logger,\n propagationContextFromHeaders,\n requestDataIntegration,\n stackParserFromStackParserOptions,\n consoleIntegration,\n} from '@sentry/core';\nimport {\n enhanceDscWithOpenTelemetryRootSpanName,\n openTelemetrySetupCheck,\n setOpenTelemetryContextAsyncContextStrategy,\n setupEventContextTrace,\n} from '@sentry/opentelemetry';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { childProcessIntegration } from '../integrations/childProcess';\nimport { nodeContextIntegration } from '../integrations/context';\nimport { contextLinesIntegration } from '../integrations/contextlines';\nimport { httpIntegration } from '../integrations/http';\nimport { localVariablesIntegration } from '../integrations/local-variables';\nimport { modulesIntegration } from '../integrations/modules';\nimport { nativeNodeFetchIntegration } from '../integrations/node-fetch';\nimport { onUncaughtExceptionIntegration } from '../integrations/onuncaughtexception';\nimport { onUnhandledRejectionIntegration } from '../integrations/onunhandledrejection';\nimport { processSessionIntegration } from '../integrations/processSession';\nimport { INTEGRATION_NAME as SPOTLIGHT_INTEGRATION_NAME, spotlightIntegration } from '../integrations/spotlight';\nimport { getAutoPerformanceIntegrations } from '../integrations/tracing';\nimport { makeNodeTransport } from '../transports';\nimport type { NodeClientOptions, NodeOptions } from '../types';\nimport { isCjs } from '../utils/commonjs';\nimport { envToBool } from '../utils/envToBool';\nimport { defaultStackParser, getSentryRelease } from './api';\nimport { NodeClient } from './client';\nimport { initOpenTelemetry, maybeInitializeEsmLoader } from './initOtel';\n\nfunction getCjsOnlyIntegrations(): Integration[] {\n return isCjs() ? [modulesIntegration()] : [];\n}\n\n/**\n * Get default integrations, excluding performance.\n */\nexport function getDefaultIntegrationsWithoutPerformance(): Integration[] {\n return [\n // Common\n // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n // eslint-disable-next-line deprecation/deprecation\n inboundFiltersIntegration(),\n functionToStringIntegration(),\n linkedErrorsIntegration(),\n requestDataIntegration(),\n // Native Wrappers\n consoleIntegration(),\n httpIntegration(),\n nativeNodeFetchIntegration(),\n // Global Handlers\n onUncaughtExceptionIntegration(),\n onUnhandledRejectionIntegration(),\n // Event Info\n contextLinesIntegration(),\n localVariablesIntegration(),\n nodeContextIntegration(),\n childProcessIntegration(),\n processSessionIntegration(),\n ...getCjsOnlyIntegrations(),\n ];\n}\n\n/** Get the default integrations for the Node SDK. */\nexport function getDefaultIntegrations(options: Options): Integration[] {\n return [\n ...getDefaultIntegrationsWithoutPerformance(),\n // We only add performance integrations if tracing is enabled\n // Note that this means that without tracing enabled, e.g. `expressIntegration()` will not be added\n // This means that generally request isolation will work (because that is done by httpIntegration)\n // But `transactionName` will not be set automatically\n ...(hasSpansEnabled(options) ? getAutoPerformanceIntegrations() : []),\n ];\n}\n\n/**\n * Initialize Sentry for Node.\n */\nexport function init(options: NodeOptions | undefined = {}): NodeClient | undefined {\n return _init(options, getDefaultIntegrations);\n}\n\n/**\n * Initialize Sentry for Node, without any integrations added by default.\n */\nexport function initWithoutDefaultIntegrations(options: NodeOptions | undefined = {}): NodeClient {\n return _init(options, () => []);\n}\n\n/**\n * Initialize Sentry for Node, without performance instrumentation.\n */\nfunction _init(\n _options: NodeOptions | undefined = {},\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClient {\n const options = getClientOptions(_options, getDefaultIntegrationsImpl);\n\n if (options.debug === true) {\n if (DEBUG_BUILD) {\n logger.enable();\n } else {\n // use `console.warn` rather than `logger.warn` since by non-debug bundles have all `logger.x` statements stripped\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn('[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.');\n });\n }\n }\n\n if (!isCjs() && options.registerEsmLoaderHooks !== false) {\n maybeInitializeEsmLoader();\n }\n\n setOpenTelemetryContextAsyncContextStrategy();\n\n const scope = getCurrentScope();\n scope.update(options.initialScope);\n\n if (options.spotlight && !options.integrations.some(({ name }) => name === SPOTLIGHT_INTEGRATION_NAME)) {\n options.integrations.push(\n spotlightIntegration({\n sidecarUrl: typeof options.spotlight === 'string' ? options.spotlight : undefined,\n }),\n );\n }\n\n const client = new NodeClient(options);\n // The client is on the current scope, from where it generally is inherited\n getCurrentScope().setClient(client);\n\n client.init();\n\n logger.log(`Running in ${isCjs() ? 'CommonJS' : 'ESM'} mode.`);\n\n client.startClientReportTracking();\n\n updateScopeFromEnvVariables();\n\n // If users opt-out of this, they _have_ to set up OpenTelemetry themselves\n // There is no way to use this SDK without OpenTelemetry!\n if (!options.skipOpenTelemetrySetup) {\n initOpenTelemetry(client, {\n spanProcessors: options.openTelemetrySpanProcessors,\n });\n validateOpenTelemetrySetup();\n }\n\n enhanceDscWithOpenTelemetryRootSpanName(client);\n setupEventContextTrace(client);\n\n return client;\n}\n\n/**\n * Validate that your OpenTelemetry setup is correct.\n */\nexport function validateOpenTelemetrySetup(): void {\n if (!DEBUG_BUILD) {\n return;\n }\n\n const setup = openTelemetrySetupCheck();\n\n const required: ReturnType<typeof openTelemetrySetupCheck> = ['SentryContextManager', 'SentryPropagator'];\n\n if (hasSpansEnabled()) {\n required.push('SentrySpanProcessor');\n }\n\n for (const k of required) {\n if (!setup.includes(k)) {\n logger.error(\n `You have to set up the ${k}. Without this, the OpenTelemetry & Sentry integration will not work properly.`,\n );\n }\n }\n\n if (!setup.includes('SentrySampler')) {\n logger.warn(\n 'You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.',\n );\n }\n}\n\nfunction getClientOptions(\n options: NodeOptions,\n getDefaultIntegrationsImpl: (options: Options) => Integration[],\n): NodeClientOptions {\n const release = getRelease(options.release);\n const spotlight =\n options.spotlight ?? envToBool(process.env.SENTRY_SPOTLIGHT, { strict: true }) ?? process.env.SENTRY_SPOTLIGHT;\n const tracesSampleRate = getTracesSampleRate(options.tracesSampleRate);\n\n const mergedOptions = {\n ...options,\n dsn: options.dsn ?? process.env.SENTRY_DSN,\n environment: options.environment ?? process.env.SENTRY_ENVIRONMENT,\n sendClientReports: options.sendClientReports ?? true,\n transport: options.transport ?? makeNodeTransport,\n stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n release,\n tracesSampleRate,\n spotlight,\n debug: envToBool(options.debug ?? process.env.SENTRY_DEBUG),\n };\n\n const integrations = options.integrations;\n const defaultIntegrations = options.defaultIntegrations ?? getDefaultIntegrationsImpl(mergedOptions);\n\n return {\n ...mergedOptions,\n integrations: getIntegrationsToSetup({\n defaultIntegrations,\n integrations,\n }),\n };\n}\n\nfunction getRelease(release: NodeOptions['release']): string | undefined {\n if (release !== undefined) {\n return release;\n }\n\n const detectedRelease = getSentryRelease();\n if (detectedRelease !== undefined) {\n return detectedRelease;\n }\n\n return undefined;\n}\n\nfunction getTracesSampleRate(tracesSampleRate: NodeOptions['tracesSampleRate']): number | undefined {\n if (tracesSampleRate !== undefined) {\n return tracesSampleRate;\n }\n\n const sampleRateFromEnv = process.env.SENTRY_TRACES_SAMPLE_RATE;\n if (!sampleRateFromEnv) {\n return undefined;\n }\n\n const parsed = parseFloat(sampleRateFromEnv);\n return isFinite(parsed) ? parsed : undefined;\n}\n\n/**\n * Update scope and propagation context based on environmental variables.\n *\n * See https://github.com/getsentry/rfcs/blob/main/text/0071-continue-trace-over-process-boundaries.md\n * for more details.\n */\nfunction updateScopeFromEnvVariables(): void {\n if (envToBool(process.env.SENTRY_USE_ENVIRONMENT) !== false) {\n const sentryTraceEnv = process.env.SENTRY_TRACE;\n const baggageEnv = process.env.SENTRY_BAGGAGE;\n const propagationContext = propagationContextFromHeaders(sentryTraceEnv, baggageEnv);\n getCurrentScope().setPropagationContext(propagationContext);\n }\n}\n"],"names":["isCjs","modulesIntegration","inboundFiltersIntegration","functionToStringIntegration","linkedErrorsIntegration","requestDataIntegration","consoleIntegration","httpIntegration","nativeNodeFetchIntegration","onUncaughtExceptionIntegration","onUnhandledRejectionIntegration","contextLinesIntegration","localVariablesIntegration","nodeContextIntegration","childProcessIntegration","processSessionIntegration","hasSpansEnabled","getAutoPerformanceIntegrations","DEBUG_BUILD","logger","consoleSandbox","maybeInitializeEsmLoader","setOpenTelemetryContextAsyncContextStrategy","getCurrentScope","SPOTLIGHT_INTEGRATION_NAME","spotlightIntegration","client","NodeClient","initOpenTelemetry","enhanceDscWithOpenTelemetryRootSpanName","setupEventContextTrace","openTelemetrySetupCheck","envToBool","makeNodeTransport","stackParserFromStackParserOptions","defaultStackParser","getIntegrationsToSetup","getSentryRelease","propagationContextFromHeaders"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAS,sBAAsB,GAAkB;AACjD,EAAE,OAAOA,cAAK,EAAC,GAAI,CAACC,0BAAkB,EAAE,CAAA,GAAI,EAAE;AAC9C;;AAEA;AACA;AACA;AACO,SAAS,wCAAwC,GAAkB;AAC1E,EAAE,OAAO;AACT;AACA;AACA;AACA,IAAIC,8BAAyB,EAAE;AAC/B,IAAIC,gCAA2B,EAAE;AACjC,IAAIC,4BAAuB,EAAE;AAC7B,IAAIC,2BAAsB,EAAE;AAC5B;AACA,IAAIC,uBAAkB,EAAE;AACxB,IAAIC,uBAAe,EAAE;AACrB,IAAIC,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AM,MAAO,GAAE,UAAU,CAAC,iBAAiB,CAAC;AAC9C,EAAE,OAAO,QAAQ,CAAC,MAAM,IAAI,MAAA,GAAS,SAAS;AAC9C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,2BAA2B,GAAS;AAC7C,EAAE,IAAIL,mBAAS,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAA,KAAM,KAAK,EAAE;AAC/D,IAAI,MAAM,cAAe,GAAE,OAAO,CAAC,GAAG,CAAC,YAAY;AACnD,IAAI,MAAM,UAAW,GAAE,OAAO,CAAC,GAAG,CAAC,cAAc;AACjD,IAAI,MAAM,qBAAqBM,kCAA6B,CAAC,cAAc,EAAE,UAAU,CAAC;AACxF,IAAIf,oBAAe,EAAE,CAAC,qBAAqB,CAAC,kBAAkB,CAAC;AAC/D;AACA;;;;;;;;"}
@@ -1,7 +1,6 @@
1
1
  export { httpIntegration } from './integrations/http/index.js';
2
2
  export { nativeNodeFetchIntegration } from './integrations/node-fetch/index.js';
3
3
  export { fsIntegration } from './integrations/fs.js';
4
- export { consoleIntegration } from './integrations/console.js';
5
4
  export { nodeContextIntegration } from './integrations/context.js';
6
5
  export { contextLinesIntegration } from './integrations/contextlines.js';
7
6
  export { localVariablesIntegration } from './integrations/local-variables/index.js';
@@ -32,6 +31,7 @@ export { dataloaderIntegration } from './integrations/tracing/dataloader.js';
32
31
  export { amqplibIntegration } from './integrations/tracing/amqplib.js';
33
32
  export { vercelAIIntegration } from './integrations/tracing/vercelai/index.js';
34
33
  export { childProcessIntegration } from './integrations/childProcess.js';
34
+ export { createSentryWinstonTransport } from './integrations/winston.js';
35
35
  export { SentryContextManager } from './otel/contextManager.js';
36
36
  export { generateInstrumentOnce } from './otel/instrument.js';
37
37
  export { getDefaultIntegrations, getDefaultIntegrationsWithoutPerformance, init, initWithoutDefaultIntegrations, validateOpenTelemetrySetup } from './sdk/index.js';
@@ -43,7 +43,7 @@ export { makeNodeTransport } from './transports/http.js';
43
43
  export { NodeClient } from './sdk/client.js';
44
44
  export { cron } from './cron/index.js';
45
45
  export { setOpenTelemetryContextAsyncContextStrategy as setNodeAsyncContextStrategy } from '@sentry/opentelemetry';
46
- export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleLoggingIntegration, continueTrace, createTransport, dedupeIntegration, endSession, eventFiltersIntegration, extraErrorDataIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, inboundFiltersIntegration, isInitialized, lastEventId, linkedErrorsIntegration, parameterize, profiler, requestDataIntegration, rewriteFramesIntegration, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, suppressTracing, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, zodErrorsIntegration } from '@sentry/core';
47
- import * as log from './log.js';
48
- export { log as logger };
46
+ export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleIntegration, consoleLoggingIntegration, continueTrace, createTransport, dedupeIntegration, endSession, eventFiltersIntegration, extraErrorDataIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, inboundFiltersIntegration, isInitialized, lastEventId, linkedErrorsIntegration, parameterize, profiler, requestDataIntegration, rewriteFramesIntegration, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanToBaggageHeader, spanToJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, suppressTracing, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, zodErrorsIntegration } from '@sentry/core';
47
+ import * as exports from './logs/exports.js';
48
+ export { exports as logger };
49
49
  //# sourceMappingURL=index.js.map