@sentry/node 9.16.1 → 9.17.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 (64) hide show
  1. package/build/cjs/index.js +18 -18
  2. package/build/cjs/integrations/anr/index.js +1 -1
  3. package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  4. package/build/cjs/integrations/tracing/fastify/index.js +187 -0
  5. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -0
  6. package/build/cjs/integrations/tracing/fastify/v3/constants.js +23 -0
  7. package/build/cjs/integrations/tracing/fastify/v3/constants.js.map +1 -0
  8. package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
  9. package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
  10. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js +303 -0
  11. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
  12. package/build/cjs/integrations/tracing/fastify/v3/utils.js +135 -0
  13. package/build/cjs/integrations/tracing/fastify/v3/utils.js.map +1 -0
  14. package/build/cjs/integrations/tracing/index.js +11 -10
  15. package/build/cjs/integrations/tracing/index.js.map +1 -1
  16. package/build/esm/index.js +1 -1
  17. package/build/esm/integrations/anr/index.js +1 -1
  18. package/build/esm/integrations/anr/worker-script.js +2 -2
  19. package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  20. package/build/esm/integrations/local-variables/worker-script.js +2 -2
  21. package/build/esm/integrations/tracing/fastify/index.js +182 -0
  22. package/build/esm/integrations/tracing/fastify/index.js.map +1 -0
  23. package/build/esm/integrations/tracing/fastify/v3/constants.js +21 -0
  24. package/build/esm/integrations/tracing/fastify/v3/constants.js.map +1 -0
  25. package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
  26. package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
  27. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js +301 -0
  28. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
  29. package/build/esm/integrations/tracing/fastify/v3/utils.js +131 -0
  30. package/build/esm/integrations/tracing/fastify/v3/utils.js.map +1 -0
  31. package/build/esm/integrations/tracing/index.js +2 -1
  32. package/build/esm/integrations/tracing/index.js.map +1 -1
  33. package/build/esm/package.json +1 -1
  34. package/build/{types-ts3.8/integrations/tracing/fastify.d.ts → types/integrations/tracing/fastify/index.d.ts} +83 -103
  35. package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -0
  36. package/build/types/integrations/tracing/fastify/types.d.ts +25 -0
  37. package/build/types/integrations/tracing/fastify/types.d.ts.map +1 -0
  38. package/build/types/integrations/tracing/fastify/v3/constants.d.ts +3 -0
  39. package/build/types/integrations/tracing/fastify/v3/constants.d.ts.map +1 -0
  40. package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
  41. package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts.map +1 -0
  42. package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
  43. package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts.map +1 -0
  44. package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
  45. package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts.map +1 -0
  46. package/build/types/integrations/tracing/fastify/v3/types.d.ts +21 -0
  47. package/build/types/integrations/tracing/fastify/v3/types.d.ts.map +1 -0
  48. package/build/types/integrations/tracing/fastify/v3/utils.d.ts +28 -0
  49. package/build/types/integrations/tracing/fastify/v3/utils.d.ts.map +1 -0
  50. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  51. package/build/{types/integrations/tracing/fastify.d.ts → types-ts3.8/integrations/tracing/fastify/index.d.ts} +83 -103
  52. package/build/types-ts3.8/integrations/tracing/fastify/types.d.ts +25 -0
  53. package/build/types-ts3.8/integrations/tracing/fastify/v3/constants.d.ts +3 -0
  54. package/build/types-ts3.8/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
  55. package/build/types-ts3.8/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
  56. package/build/types-ts3.8/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
  57. package/build/types-ts3.8/integrations/tracing/fastify/v3/types.d.ts +21 -0
  58. package/build/types-ts3.8/integrations/tracing/fastify/v3/utils.d.ts +28 -0
  59. package/package.json +4 -4
  60. package/build/cjs/integrations/tracing/fastify.js +0 -160
  61. package/build/cjs/integrations/tracing/fastify.js.map +0 -1
  62. package/build/esm/integrations/tracing/fastify.js +0 -156
  63. package/build/esm/integrations/tracing/fastify.js.map +0 -1
  64. package/build/types/integrations/tracing/fastify.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttributeNames.js","sources":["../../../../../../../src/integrations/tracing/fastify/v3/enums/AttributeNames.ts"],"sourcesContent":["// Vendored from https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/enums/AttributeNames.ts\n//\n/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum AttributeNames {\n FASTIFY_NAME = 'fastify.name',\n FASTIFY_TYPE = 'fastify.type',\n HOOK_NAME = 'hook.name',\n PLUGIN_NAME = 'plugin.name',\n}\n\nexport enum FastifyTypes {\n MIDDLEWARE = 'middleware',\n REQUEST_HANDLER = 'request_handler',\n}\n\nexport enum FastifyNames {\n MIDDLEWARE = 'middleware',\n REQUEST_HANDLER = 'request handler',\n}\n"],"names":["AttributeNames","FastifyTypes","FastifyNames"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAE2BA,gCAAA,CAAA,CAAA,UAAA,cAAA,EAAA;AAC3B,EAAE,MAAA,YAAA,GAAe,cAAc,CAAA,CAAA,cAAA,CAAA,cAAA,CAAA,GAAA,YAAA;AAC/B,EAAE,MAAA,YAAA,GAAe,cAAc,CAAA,CAAA,cAAA,CAAA,cAAA,CAAA,GAAA,YAAA;AAC/B,EAAE,MAAA,SAAA,GAAY,WAAW,CAAA,CAAA,cAAA,CAAA,WAAA,CAAA,GAAA,SAAA;AACzB,EAAE,MAAA,WAAA,GAAc,aAAa,CAAA,CAAA,cAAA,CAAA,aAAA,CAAA,GAAA,WAAA;AAC7B,CAAA,EAAAA,sBAAA,KAAAA,sBAAA,GAAA,EAAA,CAAA,CAAA;;AAEyBC,8BAAA,CAAA,CAAA,UAAA,YAAA,EAAA;AACzB,EAAE,MAAA,UAAA,GAAa,YAAY,CAAA,CAAA,YAAA,CAAA,YAAA,CAAA,GAAA,UAAA;AAC3B,EAAE,MAAA,eAAA,GAAkB,iBAAiB,CAAA,CAAA,YAAA,CAAA,iBAAA,CAAA,GAAA,eAAA;AACrC,CAAA,EAAAA,oBAAA,KAAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;;AAEyBC,8BAAA,CAAA,CAAA,UAAA,YAAA,EAAA;AACzB,EAAE,MAAA,UAAA,GAAa,YAAY,CAAA,CAAA,YAAA,CAAA,YAAA,CAAA,GAAA,UAAA;AAC3B,EAAE,MAAA,eAAA,GAAkB,iBAAiB,CAAA,CAAA,YAAA,CAAA,iBAAA,CAAA,GAAA,eAAA;AACrC,CAAA,EAAAA,oBAAA,KAAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;;"}
@@ -0,0 +1,303 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const api = require('@opentelemetry/api');
4
+ const core = require('@opentelemetry/core');
5
+ const instrumentation = require('@opentelemetry/instrumentation');
6
+ const semanticConventions = require('@opentelemetry/semantic-conventions');
7
+ const core$1 = require('@sentry/core');
8
+ const AttributeNames = require('./enums/AttributeNames.js');
9
+ const utils = require('./utils.js');
10
+
11
+ // Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts
12
+ /* eslint-disable @typescript-eslint/no-this-alias */
13
+ /* eslint-disable jsdoc/require-jsdoc */
14
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
15
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
16
+
17
+ /** @knipignore */
18
+
19
+ const PACKAGE_VERSION = '0.1.0';
20
+
21
+ const PACKAGE_NAME = '@sentry/instrumentation-fastify-v3';
22
+ const ANONYMOUS_NAME = 'anonymous';
23
+
24
+ // The instrumentation creates a span for invocations of lifecycle hook handlers
25
+ // that take `(request, reply, ...[, done])` arguments. Currently this is all
26
+ // lifecycle hooks except `onRequestAbort`.
27
+ // https://fastify.dev/docs/latest/Reference/Hooks
28
+ const hooksNamesToWrap = new Set([
29
+ 'onTimeout',
30
+ 'onRequest',
31
+ 'preParsing',
32
+ 'preValidation',
33
+ 'preSerialization',
34
+ 'preHandler',
35
+ 'onSend',
36
+ 'onResponse',
37
+ 'onError',
38
+ ]);
39
+
40
+ /**
41
+ * Fastify instrumentation for OpenTelemetry
42
+ */
43
+ class FastifyInstrumentationV3 extends instrumentation.InstrumentationBase {
44
+ constructor(config = {}) {
45
+ super(PACKAGE_NAME, PACKAGE_VERSION, config);
46
+ }
47
+
48
+ init() {
49
+ return [
50
+ new instrumentation.InstrumentationNodeModuleDefinition('fastify', ['>=3.0.0 <4'], moduleExports => {
51
+ return this._patchConstructor(moduleExports);
52
+ }),
53
+ ];
54
+ }
55
+
56
+ _hookOnRequest() {
57
+ const instrumentation = this;
58
+
59
+ return function onRequest(request, reply, done) {
60
+ if (!instrumentation.isEnabled()) {
61
+ return done();
62
+ }
63
+ instrumentation._wrap(reply, 'send', instrumentation._patchSend());
64
+
65
+ const anyRequest = request ;
66
+
67
+ const rpcMetadata = core.getRPCMetadata(api.context.active());
68
+ const routeName = anyRequest.routeOptions
69
+ ? anyRequest.routeOptions.url // since fastify@4.10.0
70
+ : request.routerPath;
71
+ if (routeName && rpcMetadata?.type === core.RPCType.HTTP) {
72
+ rpcMetadata.route = routeName;
73
+ }
74
+
75
+ const method = request.method || 'GET';
76
+
77
+ core$1.getIsolationScope().setTransactionName(`${method} ${routeName}`);
78
+ done();
79
+ };
80
+ }
81
+
82
+ _wrapHandler(
83
+ pluginName,
84
+ hookName,
85
+ original,
86
+ syncFunctionWithDone,
87
+ ) {
88
+ const instrumentation = this;
89
+ this._diag.debug('Patching fastify route.handler function');
90
+
91
+ return function ( ...args) {
92
+ if (!instrumentation.isEnabled()) {
93
+ return original.apply(this, args);
94
+ }
95
+
96
+ const name = original.name || pluginName || ANONYMOUS_NAME;
97
+ const spanName = `${AttributeNames.FastifyNames.MIDDLEWARE} - ${name}`;
98
+
99
+ const reply = args[1] ;
100
+
101
+ const span = utils.startSpan(reply, instrumentation.tracer, spanName, {
102
+ [AttributeNames.AttributeNames.FASTIFY_TYPE]: AttributeNames.FastifyTypes.MIDDLEWARE,
103
+ [AttributeNames.AttributeNames.PLUGIN_NAME]: pluginName,
104
+ [AttributeNames.AttributeNames.HOOK_NAME]: hookName,
105
+ });
106
+
107
+ const origDone = syncFunctionWithDone && (args[args.length - 1] );
108
+ if (origDone) {
109
+ args[args.length - 1] = function (...doneArgs) {
110
+ utils.endSpan(reply);
111
+ origDone.apply(this, doneArgs);
112
+ };
113
+ }
114
+
115
+ return api.context.with(api.trace.setSpan(api.context.active(), span), () => {
116
+ return utils.safeExecuteInTheMiddleMaybePromise(
117
+ () => {
118
+ return original.apply(this, args);
119
+ },
120
+ err => {
121
+ if (err instanceof Error) {
122
+ span.setStatus({
123
+ code: api.SpanStatusCode.ERROR,
124
+ message: err.message,
125
+ });
126
+ span.recordException(err);
127
+ }
128
+ // async hooks should end the span as soon as the promise is resolved
129
+ if (!syncFunctionWithDone) {
130
+ utils.endSpan(reply);
131
+ }
132
+ },
133
+ );
134
+ });
135
+ };
136
+ }
137
+
138
+ _wrapAddHook() {
139
+ const instrumentation = this;
140
+ this._diag.debug('Patching fastify server.addHook function');
141
+
142
+ // biome-ignore lint/complexity/useArrowFunction: <explanation>
143
+ return function (original) {
144
+ return function wrappedAddHook( ...args) {
145
+ const name = args[0] ;
146
+ const handler = args[1] ;
147
+ const pluginName = this.pluginName;
148
+ if (!hooksNamesToWrap.has(name)) {
149
+ return original.apply(this, args);
150
+ }
151
+
152
+ const syncFunctionWithDone =
153
+ typeof args[args.length - 1] === 'function' && handler.constructor.name !== 'AsyncFunction';
154
+
155
+ return original.apply(this, [
156
+ name,
157
+ instrumentation._wrapHandler(pluginName, name, handler, syncFunctionWithDone),
158
+ ] );
159
+ };
160
+ };
161
+ }
162
+
163
+ _patchConstructor(moduleExports
164
+
165
+ ) {
166
+ const instrumentation = this;
167
+
168
+ function fastify( ...args) {
169
+ const app = moduleExports.fastify.apply(this, args);
170
+ app.addHook('onRequest', instrumentation._hookOnRequest());
171
+ app.addHook('preHandler', instrumentation._hookPreHandler());
172
+
173
+ instrumentClient();
174
+
175
+ instrumentation._wrap(app, 'addHook', instrumentation._wrapAddHook());
176
+
177
+ return app;
178
+ }
179
+
180
+ if (moduleExports.errorCodes !== undefined) {
181
+ fastify.errorCodes = moduleExports.errorCodes;
182
+ }
183
+ fastify.fastify = fastify;
184
+ fastify.default = fastify;
185
+ return fastify;
186
+ }
187
+
188
+ _patchSend() {
189
+ const instrumentation$1 = this;
190
+ this._diag.debug('Patching fastify reply.send function');
191
+
192
+ return function patchSend(original) {
193
+ return function send( ...args) {
194
+ const maybeError = args[0];
195
+
196
+ if (!instrumentation$1.isEnabled()) {
197
+ return original.apply(this, args);
198
+ }
199
+
200
+ return instrumentation.safeExecuteInTheMiddle(
201
+ () => {
202
+ return original.apply(this, args);
203
+ },
204
+ err => {
205
+ if (!err && maybeError instanceof Error) {
206
+ // eslint-disable-next-line no-param-reassign
207
+ err = maybeError;
208
+ }
209
+ utils.endSpan(this, err);
210
+ },
211
+ );
212
+ };
213
+ };
214
+ }
215
+
216
+ _hookPreHandler() {
217
+ const instrumentation$1 = this;
218
+ this._diag.debug('Patching fastify preHandler function');
219
+
220
+ return function preHandler( request, reply, done) {
221
+ if (!instrumentation$1.isEnabled()) {
222
+ return done();
223
+ }
224
+ const anyRequest = request ;
225
+
226
+ const handler = anyRequest.routeOptions?.handler || anyRequest.context?.handler;
227
+ const handlerName = handler?.name.startsWith('bound ') ? handler.name.substring(6) : handler?.name;
228
+ const spanName = `${AttributeNames.FastifyNames.REQUEST_HANDLER} - ${handlerName || this.pluginName || ANONYMOUS_NAME}`;
229
+
230
+ const spanAttributes = {
231
+ [AttributeNames.AttributeNames.PLUGIN_NAME]: this.pluginName,
232
+ [AttributeNames.AttributeNames.FASTIFY_TYPE]: AttributeNames.FastifyTypes.REQUEST_HANDLER,
233
+ // eslint-disable-next-line deprecation/deprecation
234
+ [semanticConventions.SEMATTRS_HTTP_ROUTE]: anyRequest.routeOptions
235
+ ? anyRequest.routeOptions.url // since fastify@4.10.0
236
+ : request.routerPath,
237
+ };
238
+ if (handlerName) {
239
+ spanAttributes[AttributeNames.AttributeNames.FASTIFY_NAME] = handlerName;
240
+ }
241
+ const span = utils.startSpan(reply, instrumentation$1.tracer, spanName, spanAttributes);
242
+
243
+ addFastifyV3SpanAttributes(span);
244
+
245
+ const { requestHook } = instrumentation$1.getConfig();
246
+ if (requestHook) {
247
+ instrumentation.safeExecuteInTheMiddle(
248
+ () => requestHook(span, { request }),
249
+ e => {
250
+ if (e) {
251
+ instrumentation$1._diag.error('request hook failed', e);
252
+ }
253
+ },
254
+ true,
255
+ );
256
+ }
257
+
258
+ return api.context.with(api.trace.setSpan(api.context.active(), span), () => {
259
+ done();
260
+ });
261
+ };
262
+ }
263
+ }
264
+
265
+ function instrumentClient() {
266
+ const client = core$1.getClient();
267
+ if (client) {
268
+ client.on('spanStart', (span) => {
269
+ addFastifyV3SpanAttributes(span);
270
+ });
271
+ }
272
+ }
273
+
274
+ function addFastifyV3SpanAttributes(span) {
275
+ const attributes = core$1.spanToJSON(span).data;
276
+
277
+ // this is one of: middleware, request_handler
278
+ const type = attributes['fastify.type'];
279
+
280
+ // If this is already set, or we have no fastify span, no need to process again...
281
+ if (attributes[core$1.SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {
282
+ return;
283
+ }
284
+
285
+ span.setAttributes({
286
+ [core$1.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.fastify',
287
+ [core$1.SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.fastify`,
288
+ });
289
+
290
+ // Also update the name, we don't need to "middleware - " prefix
291
+ const name = attributes['fastify.name'] || attributes['plugin.name'] || attributes['hook.name'];
292
+ if (typeof name === 'string') {
293
+ // Try removing `fastify -> ` and `@fastify/otel -> ` prefixes
294
+ // This is a bit of a hack, and not always working for all spans
295
+ // But it's the best we can do without a proper API
296
+ const updatedName = name.replace(/^fastify -> /, '').replace(/^@fastify\/otel -> /, '');
297
+
298
+ span.updateName(updatedName);
299
+ }
300
+ }
301
+
302
+ exports.FastifyInstrumentationV3 = FastifyInstrumentationV3;
303
+ //# sourceMappingURL=instrumentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/fastify/v3/instrumentation.ts"],"sourcesContent":["// Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts\n/* eslint-disable @typescript-eslint/no-this-alias */\n/* eslint-disable jsdoc/require-jsdoc */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n\n/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Attributes, context, SpanStatusCode, trace } from '@opentelemetry/api';\nimport { getRPCMetadata, RPCType } from '@opentelemetry/core';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\nimport type { Span } from '@sentry/core';\nimport {\n getClient,\n getIsolationScope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n} from '@sentry/core';\nimport type {\n FastifyErrorCodes,\n FastifyInstance,\n FastifyReply,\n FastifyRequest,\n HandlerOriginal,\n HookHandlerDoneFunction,\n} from '../types';\nimport { AttributeNames, FastifyNames, FastifyTypes } from './enums/AttributeNames';\nimport type { PluginFastifyReply } from './internal-types';\nimport type { FastifyInstrumentationConfig } from './types';\nimport { endSpan, safeExecuteInTheMiddleMaybePromise, startSpan } from './utils';\n/** @knipignore */\n\nconst PACKAGE_VERSION = '0.1.0';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-fastify-v3';\nconst ANONYMOUS_NAME = 'anonymous';\n\n// The instrumentation creates a span for invocations of lifecycle hook handlers\n// that take `(request, reply, ...[, done])` arguments. Currently this is all\n// lifecycle hooks except `onRequestAbort`.\n// https://fastify.dev/docs/latest/Reference/Hooks\nconst hooksNamesToWrap = new Set([\n 'onTimeout',\n 'onRequest',\n 'preParsing',\n 'preValidation',\n 'preSerialization',\n 'preHandler',\n 'onSend',\n 'onResponse',\n 'onError',\n]);\n\n/**\n * Fastify instrumentation for OpenTelemetry\n */\nexport class FastifyInstrumentationV3 extends InstrumentationBase<FastifyInstrumentationConfig> {\n public constructor(config: FastifyInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n public init(): InstrumentationNodeModuleDefinition[] {\n return [\n new InstrumentationNodeModuleDefinition('fastify', ['>=3.0.0 <4'], moduleExports => {\n return this._patchConstructor(moduleExports);\n }),\n ];\n }\n\n private _hookOnRequest() {\n const instrumentation = this;\n\n return function onRequest(request: FastifyRequest, reply: FastifyReply, done: HookHandlerDoneFunction) {\n if (!instrumentation.isEnabled()) {\n return done();\n }\n instrumentation._wrap(reply, 'send', instrumentation._patchSend());\n\n const anyRequest = request as any;\n\n const rpcMetadata = getRPCMetadata(context.active());\n const routeName = anyRequest.routeOptions\n ? anyRequest.routeOptions.url // since fastify@4.10.0\n : request.routerPath;\n if (routeName && rpcMetadata?.type === RPCType.HTTP) {\n rpcMetadata.route = routeName;\n }\n\n const method = request.method || 'GET';\n\n getIsolationScope().setTransactionName(`${method} ${routeName}`);\n done();\n };\n }\n\n private _wrapHandler(\n pluginName: string,\n hookName: string,\n original: HandlerOriginal,\n syncFunctionWithDone: boolean,\n ): () => Promise<unknown> {\n const instrumentation = this;\n this._diag.debug('Patching fastify route.handler function');\n\n return function (this: any, ...args: unknown[]): Promise<unknown> {\n if (!instrumentation.isEnabled()) {\n return original.apply(this, args);\n }\n\n const name = original.name || pluginName || ANONYMOUS_NAME;\n const spanName = `${FastifyNames.MIDDLEWARE} - ${name}`;\n\n const reply = args[1] as PluginFastifyReply;\n\n const span = startSpan(reply, instrumentation.tracer, spanName, {\n [AttributeNames.FASTIFY_TYPE]: FastifyTypes.MIDDLEWARE,\n [AttributeNames.PLUGIN_NAME]: pluginName,\n [AttributeNames.HOOK_NAME]: hookName,\n });\n\n const origDone = syncFunctionWithDone && (args[args.length - 1] as HookHandlerDoneFunction);\n if (origDone) {\n args[args.length - 1] = function (...doneArgs: Parameters<HookHandlerDoneFunction>) {\n endSpan(reply);\n origDone.apply(this, doneArgs);\n };\n }\n\n return context.with(trace.setSpan(context.active(), span), () => {\n return safeExecuteInTheMiddleMaybePromise(\n () => {\n return original.apply(this, args);\n },\n err => {\n if (err instanceof Error) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n span.recordException(err);\n }\n // async hooks should end the span as soon as the promise is resolved\n if (!syncFunctionWithDone) {\n endSpan(reply);\n }\n },\n );\n });\n };\n }\n\n private _wrapAddHook(): (original: FastifyInstance['addHook']) => () => FastifyInstance {\n const instrumentation = this;\n this._diag.debug('Patching fastify server.addHook function');\n\n // biome-ignore lint/complexity/useArrowFunction: <explanation>\n return function (original: FastifyInstance['addHook']): () => FastifyInstance {\n return function wrappedAddHook(this: any, ...args: any) {\n const name = args[0] as string;\n const handler = args[1] as HandlerOriginal;\n const pluginName = this.pluginName;\n if (!hooksNamesToWrap.has(name)) {\n return original.apply(this, args);\n }\n\n const syncFunctionWithDone =\n typeof args[args.length - 1] === 'function' && handler.constructor.name !== 'AsyncFunction';\n\n return original.apply(this, [\n name,\n instrumentation._wrapHandler(pluginName, name, handler, syncFunctionWithDone),\n ] as never);\n };\n };\n }\n\n private _patchConstructor(moduleExports: {\n fastify: () => FastifyInstance;\n errorCodes: FastifyErrorCodes | undefined;\n }): () => FastifyInstance {\n const instrumentation = this;\n\n function fastify(this: FastifyInstance, ...args: any) {\n const app: FastifyInstance = moduleExports.fastify.apply(this, args);\n app.addHook('onRequest', instrumentation._hookOnRequest());\n app.addHook('preHandler', instrumentation._hookPreHandler());\n\n instrumentClient();\n\n instrumentation._wrap(app, 'addHook', instrumentation._wrapAddHook());\n\n return app;\n }\n\n if (moduleExports.errorCodes !== undefined) {\n fastify.errorCodes = moduleExports.errorCodes;\n }\n fastify.fastify = fastify;\n fastify.default = fastify;\n return fastify;\n }\n\n private _patchSend() {\n const instrumentation = this;\n this._diag.debug('Patching fastify reply.send function');\n\n return function patchSend(original: () => FastifyReply): () => FastifyReply {\n return function send(this: FastifyReply, ...args: any) {\n const maybeError: any = args[0];\n\n if (!instrumentation.isEnabled()) {\n return original.apply(this, args);\n }\n\n return safeExecuteInTheMiddle<FastifyReply>(\n () => {\n return original.apply(this, args);\n },\n err => {\n if (!err && maybeError instanceof Error) {\n // eslint-disable-next-line no-param-reassign\n err = maybeError;\n }\n endSpan(this, err);\n },\n );\n };\n };\n }\n\n private _hookPreHandler() {\n const instrumentation = this;\n this._diag.debug('Patching fastify preHandler function');\n\n return function preHandler(this: any, request: FastifyRequest, reply: FastifyReply, done: HookHandlerDoneFunction) {\n if (!instrumentation.isEnabled()) {\n return done();\n }\n const anyRequest = request as any;\n\n const handler = anyRequest.routeOptions?.handler || anyRequest.context?.handler;\n const handlerName = handler?.name.startsWith('bound ') ? handler.name.substring(6) : handler?.name;\n const spanName = `${FastifyNames.REQUEST_HANDLER} - ${handlerName || this.pluginName || ANONYMOUS_NAME}`;\n\n const spanAttributes: Attributes = {\n [AttributeNames.PLUGIN_NAME]: this.pluginName,\n [AttributeNames.FASTIFY_TYPE]: FastifyTypes.REQUEST_HANDLER,\n // eslint-disable-next-line deprecation/deprecation\n [SEMATTRS_HTTP_ROUTE]: anyRequest.routeOptions\n ? anyRequest.routeOptions.url // since fastify@4.10.0\n : request.routerPath,\n };\n if (handlerName) {\n spanAttributes[AttributeNames.FASTIFY_NAME] = handlerName;\n }\n const span = startSpan(reply, instrumentation.tracer, spanName, spanAttributes);\n\n addFastifyV3SpanAttributes(span);\n\n const { requestHook } = instrumentation.getConfig();\n if (requestHook) {\n safeExecuteInTheMiddle(\n () => requestHook(span, { request }),\n e => {\n if (e) {\n instrumentation._diag.error('request hook failed', e);\n }\n },\n true,\n );\n }\n\n return context.with(trace.setSpan(context.active(), span), () => {\n done();\n });\n };\n }\n}\n\nfunction instrumentClient(): void {\n const client = getClient();\n if (client) {\n client.on('spanStart', (span: Span) => {\n addFastifyV3SpanAttributes(span);\n });\n }\n}\n\nfunction addFastifyV3SpanAttributes(span: Span): void {\n const attributes = spanToJSON(span).data;\n\n // this is one of: middleware, request_handler\n const type = attributes['fastify.type'];\n\n // If this is already set, or we have no fastify span, no need to process again...\n if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {\n return;\n }\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.fastify',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.fastify`,\n });\n\n // Also update the name, we don't need to \"middleware - \" prefix\n const name = attributes['fastify.name'] || attributes['plugin.name'] || attributes['hook.name'];\n if (typeof name === 'string') {\n // Try removing `fastify -> ` and `@fastify/otel -> ` prefixes\n // This is a bit of a hack, and not always working for all spans\n // But it's the best we can do without a proper API\n const updatedName = name.replace(/^fastify -> /, '').replace(/^@fastify\\/otel -> /, '');\n\n span.updateName(updatedName);\n }\n}\n"],"names":["InstrumentationBase","InstrumentationNodeModuleDefinition","getRPCMetadata","context","RPCType","getIsolationScope","FastifyNames","startSpan","AttributeNames","FastifyTypes","endSpan","trace","safeExecuteInTheMiddleMaybePromise","SpanStatusCode","instrumentation","safeExecuteInTheMiddle","SEMATTRS_HTTP_ROUTE","getClient","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;;AA8CA;;AAEA,MAAM,eAAA,GAAkB,OAAO;;AAE/B,MAAM,YAAA,GAAe,oCAAoC;AACzD,MAAM,cAAA,GAAiB,WAAW;;AAElC;AACA;AACA;AACA;AACA,MAAM,gBAAiB,GAAE,IAAI,GAAG,CAAC;AACjC,EAAE,WAAW;AACb,EAAE,WAAW;AACb,EAAE,YAAY;AACd,EAAE,eAAe;AACjB,EAAE,kBAAkB;AACp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EAAA;AACA,IAAA,MAAA,CAAA,EAAA,CAAA,WAAA,EAAA,CAAA,IAAA,KAAA;AACA,MAAA,0BAAA,CAAA,IAAA,CAAA;AACA,KAAA,CAAA;AACA;AACA;;AAEA,SAAA,0BAAA,CAAA,IAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAAC,iBAAA,CAAA,IAAA,CAAA,CAAA,IAAA;;AAEA;AACA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA;;AAEA;AACA,EAAA,IAAA,UAAA,CAAAC,mCAAA,CAAA,IAAA,CAAA,IAAA,EAAA;AACA,IAAA;AACA;;AAEA,EAAA,IAAA,CAAA,aAAA,CAAA;AACA,IAAA,CAAAC,uCAAA,GAAA,wBAAA;AACA,IAAA,CAAAD,mCAAA,GAAA,CAAA,EAAA,IAAA,CAAA,QAAA,CAAA;AACA,GAAA,CAAA;;AAEA;AACA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA,IAAA,UAAA,CAAA,aAAA,CAAA,IAAA,UAAA,CAAA,WAAA,CAAA;AACA,EAAA,IAAA,OAAA,IAAA,KAAA,QAAA,EAAA;AACA;AACA;AACA;AACA,IAAA,MAAA,WAAA,GAAA,IAAA,CAAA,OAAA,CAAA,cAAA,EAAA,EAAA,CAAA,CAAA,OAAA,CAAA,qBAAA,EAAA,EAAA,CAAA;;AAEA,IAAA,IAAA,CAAA,UAAA,CAAA,WAAA,CAAA;AACA;AACA;;;;"}
@@ -0,0 +1,135 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const api = require('@opentelemetry/api');
4
+ const constants = require('./constants.js');
5
+
6
+ // Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/utils.ts
7
+ /* eslint-disable jsdoc/require-jsdoc */
8
+ /* eslint-disable @typescript-eslint/no-dynamic-delete */
9
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
10
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
11
+ /*
12
+ * Copyright The OpenTelemetry Authors
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * https://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ */
26
+
27
+
28
+ /**
29
+ * Starts Span
30
+ * @param reply - reply function
31
+ * @param tracer - tracer
32
+ * @param spanName - span name
33
+ * @param spanAttributes - span attributes
34
+ */
35
+ function startSpan(
36
+ reply,
37
+ tracer,
38
+ spanName,
39
+ spanAttributes = {},
40
+ ) {
41
+ const span = tracer.startSpan(spanName, { attributes: spanAttributes });
42
+
43
+ const spans = reply[constants.spanRequestSymbol] || [];
44
+ spans.push(span);
45
+
46
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
47
+ Object.defineProperty(reply, constants.spanRequestSymbol, {
48
+ enumerable: false,
49
+ configurable: true,
50
+ value: spans,
51
+ });
52
+
53
+ return span;
54
+ }
55
+
56
+ /**
57
+ * Ends span
58
+ * @param reply - reply function
59
+ * @param err - error
60
+ */
61
+ function endSpan(reply, err) {
62
+ const spans = reply[constants.spanRequestSymbol] || [];
63
+ // there is no active span, or it has already ended
64
+ if (!spans.length) {
65
+ return;
66
+ }
67
+ // biome-ignore lint/complexity/noForEach: <explanation>
68
+ spans.forEach((span) => {
69
+ if (err) {
70
+ span.setStatus({
71
+ code: api.SpanStatusCode.ERROR,
72
+ message: err.message,
73
+ });
74
+ span.recordException(err);
75
+ }
76
+ span.end();
77
+ });
78
+ delete reply[constants.spanRequestSymbol];
79
+ }
80
+
81
+ // @TODO after approve add this to instrumentation package and replace usage
82
+ // when it will be released
83
+
84
+ /**
85
+ * This function handles the missing case from instrumentation package when
86
+ * execute can either return a promise or void. And using async is not an
87
+ * option as it is producing unwanted side effects.
88
+ * @param execute - function to be executed
89
+ * @param onFinish - function called when function executed
90
+ * @param preventThrowingError - prevent to throw error when execute
91
+ * function fails
92
+ */
93
+
94
+ function safeExecuteInTheMiddleMaybePromise(
95
+ execute,
96
+ onFinish,
97
+ preventThrowingError,
98
+ ) {
99
+ let error;
100
+ let result = undefined;
101
+ try {
102
+ result = execute();
103
+
104
+ if (isPromise(result)) {
105
+ result.then(
106
+ res => onFinish(undefined, res),
107
+ err => onFinish(err),
108
+ );
109
+ }
110
+ } catch (e) {
111
+ error = e;
112
+ } finally {
113
+ if (!isPromise(result)) {
114
+ onFinish(error, result);
115
+ if (error && true) {
116
+ // eslint-disable-next-line no-unsafe-finally
117
+ throw error;
118
+ }
119
+ }
120
+ // eslint-disable-next-line no-unsafe-finally
121
+ return result;
122
+ }
123
+ }
124
+
125
+ function isPromise(val) {
126
+ return (
127
+ (typeof val === 'object' && val && typeof Object.getOwnPropertyDescriptor(val, 'then')?.value === 'function') ||
128
+ false
129
+ );
130
+ }
131
+
132
+ exports.endSpan = endSpan;
133
+ exports.safeExecuteInTheMiddleMaybePromise = safeExecuteInTheMiddleMaybePromise;
134
+ exports.startSpan = startSpan;
135
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/fastify/v3/utils.ts"],"sourcesContent":["// Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/utils.ts\n/* eslint-disable jsdoc/require-jsdoc */\n/* eslint-disable @typescript-eslint/no-dynamic-delete */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Attributes, type Span, type Tracer, SpanStatusCode } from '@opentelemetry/api';\nimport { spanRequestSymbol } from './constants';\nimport type { PluginFastifyReply } from './internal-types';\n\n/**\n * Starts Span\n * @param reply - reply function\n * @param tracer - tracer\n * @param spanName - span name\n * @param spanAttributes - span attributes\n */\nexport function startSpan(\n reply: PluginFastifyReply,\n tracer: Tracer,\n spanName: string,\n spanAttributes: Attributes = {},\n) {\n const span = tracer.startSpan(spanName, { attributes: spanAttributes });\n\n const spans: Span[] = reply[spanRequestSymbol] || [];\n spans.push(span);\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Object.defineProperty(reply, spanRequestSymbol, {\n enumerable: false,\n configurable: true,\n value: spans,\n });\n\n return span;\n}\n\n/**\n * Ends span\n * @param reply - reply function\n * @param err - error\n */\nexport function endSpan(reply: PluginFastifyReply, err?: any) {\n const spans = reply[spanRequestSymbol] || [];\n // there is no active span, or it has already ended\n if (!spans.length) {\n return;\n }\n // biome-ignore lint/complexity/noForEach: <explanation>\n spans.forEach((span: Span) => {\n if (err) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n span.recordException(err);\n }\n span.end();\n });\n delete reply[spanRequestSymbol];\n}\n\n// @TODO after approve add this to instrumentation package and replace usage\n// when it will be released\n\n/**\n * This function handles the missing case from instrumentation package when\n * execute can either return a promise or void. And using async is not an\n * option as it is producing unwanted side effects.\n * @param execute - function to be executed\n * @param onFinish - function called when function executed\n * @param preventThrowingError - prevent to throw error when execute\n * function fails\n */\nexport function safeExecuteInTheMiddleMaybePromise<T>(\n execute: () => Promise<T>,\n onFinish: (e: unknown, result?: T) => void,\n preventThrowingError?: boolean,\n): Promise<T>;\nexport function safeExecuteInTheMiddleMaybePromise<T>(\n execute: () => T,\n onFinish: (e: unknown, result?: T) => void,\n preventThrowingError?: boolean,\n): T;\nexport function safeExecuteInTheMiddleMaybePromise<T>(\n execute: () => T | Promise<T>,\n onFinish: (e: unknown, result?: T) => void,\n preventThrowingError?: boolean,\n): T | Promise<T> | undefined {\n let error: unknown;\n let result: T | Promise<T> | undefined = undefined;\n try {\n result = execute();\n\n if (isPromise(result)) {\n result.then(\n res => onFinish(undefined, res),\n err => onFinish(err),\n );\n }\n } catch (e) {\n error = e;\n } finally {\n if (!isPromise(result)) {\n onFinish(error, result);\n if (error && !preventThrowingError) {\n // eslint-disable-next-line no-unsafe-finally\n throw error;\n }\n }\n // eslint-disable-next-line no-unsafe-finally\n return result;\n }\n}\n\nfunction isPromise<T>(val: T | Promise<T>): val is Promise<T> {\n return (\n (typeof val === 'object' && val && typeof Object.getOwnPropertyDescriptor(val, 'then')?.value === 'function') ||\n false\n );\n}\n"],"names":["spanRequestSymbol","SpanStatusCode"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS;AACzB,EAAE,KAAK;AACP,EAAE,MAAM;AACR,EAAE,QAAQ;AACV,EAAE,cAAc,GAAe,EAAE;AACjC,EAAE;AACF,EAAE,MAAM,IAAA,GAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,cAAA,EAAgB,CAAC;;AAEzE,EAAE,MAAM,KAAK,GAAW,KAAK,CAACA,2BAAiB,CAAA,IAAK,EAAE;AACtD,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;;AAElB;AACA,EAAE,MAAM,CAAC,cAAc,CAAC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;AACP;AACA,GAAI,CAAA,OAAO,CAAC,EAAE;AACd,IAAI,KAAA,GAAQ,CAAC;AACb,YAAY;AACZ,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;AAC5B,MAAM,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;AAC7B,MAAM,IAAI,KAAA,IAAS,IAAqB,EAAE;AAC1C;AACA,QAAQ,MAAM,KAAK;AACnB;AACA;AACA;AACA,IAAI,OAAO,MAAM;AACjB;AACA;;AAEA,SAAS,SAAS,CAAI,GAAG,EAAqC;AAC9D,EAAE;AACF,IAAI,CAAC,OAAO,GAAI,KAAI,YAAY,GAAA,IAAO,OAAO,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAA,KAAU,UAAU;AAChH,IAAI;AACJ;AACA;;;;;;"}
@@ -4,10 +4,10 @@ const index = require('../http/index.js');
4
4
  const amqplib = require('./amqplib.js');
5
5
  const connect = require('./connect.js');
6
6
  const express = require('./express.js');
7
- const fastify = require('./fastify.js');
7
+ const index$1 = require('./fastify/index.js');
8
8
  const genericPool = require('./genericPool.js');
9
9
  const graphql = require('./graphql.js');
10
- const index$1 = require('./hapi/index.js');
10
+ const index$2 = require('./hapi/index.js');
11
11
  const kafka = require('./kafka.js');
12
12
  const koa = require('./koa.js');
13
13
  const lrumemoizer = require('./lrumemoizer.js');
@@ -19,7 +19,7 @@ const postgres = require('./postgres.js');
19
19
  const prisma = require('./prisma.js');
20
20
  const redis = require('./redis.js');
21
21
  const tedious = require('./tedious.js');
22
- const index$2 = require('./vercelai/index.js');
22
+ const index$3 = require('./vercelai/index.js');
23
23
 
24
24
  /**
25
25
  * With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.
@@ -27,7 +27,7 @@ const index$2 = require('./vercelai/index.js');
27
27
  function getAutoPerformanceIntegrations() {
28
28
  return [
29
29
  express.expressIntegration(),
30
- fastify.fastifyIntegration(),
30
+ index$1.fastifyIntegration(),
31
31
  graphql.graphqlIntegration(),
32
32
  mongo.mongoIntegration(),
33
33
  mongoose.mongooseIntegration(),
@@ -36,7 +36,7 @@ function getAutoPerformanceIntegrations() {
36
36
  redis.redisIntegration(),
37
37
  postgres.postgresIntegration(),
38
38
  prisma.prismaIntegration(),
39
- index$1.hapiIntegration(),
39
+ index$2.hapiIntegration(),
40
40
  koa.koaIntegration(),
41
41
  connect.connectIntegration(),
42
42
  tedious.tediousIntegration(),
@@ -44,7 +44,7 @@ function getAutoPerformanceIntegrations() {
44
44
  kafka.kafkaIntegration(),
45
45
  amqplib.amqplibIntegration(),
46
46
  lrumemoizer.lruMemoizerIntegration(),
47
- index$2.vercelAIIntegration(),
47
+ index$3.vercelAIIntegration(),
48
48
  ];
49
49
  }
50
50
 
@@ -58,8 +58,9 @@ function getOpenTelemetryInstrumentationToPreload() {
58
58
  express.instrumentExpress,
59
59
  express.instrumentExpressV5,
60
60
  connect.instrumentConnect,
61
- fastify.instrumentFastify,
62
- index$1.instrumentHapi,
61
+ index$1.instrumentFastify,
62
+ index$1.instrumentFastifyV3,
63
+ index$2.instrumentHapi,
63
64
  kafka.instrumentKafka,
64
65
  koa.instrumentKoa,
65
66
  lrumemoizer.instrumentLruMemoizer,
@@ -68,13 +69,13 @@ function getOpenTelemetryInstrumentationToPreload() {
68
69
  mysql.instrumentMysql,
69
70
  mysql2.instrumentMysql2,
70
71
  postgres.instrumentPostgres,
71
- index$1.instrumentHapi,
72
+ index$2.instrumentHapi,
72
73
  graphql.instrumentGraphql,
73
74
  redis.instrumentRedis,
74
75
  tedious.instrumentTedious,
75
76
  genericPool.instrumentGenericPool,
76
77
  amqplib.instrumentAmqplib,
77
- index$2.instrumentVercelAi,
78
+ index$3.instrumentVercelAi,
78
79
  ];
79
80
  }
80
81
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { instrumentOtelHttp } from '../http';\nimport { amqplibIntegration, instrumentAmqplib } from './amqplib';\nimport { connectIntegration, instrumentConnect } from './connect';\nimport { expressIntegration, instrumentExpress, instrumentExpressV5 } from './express';\nimport { fastifyIntegration, instrumentFastify } from './fastify';\nimport { genericPoolIntegration, instrumentGenericPool } from './genericPool';\nimport { graphqlIntegration, instrumentGraphql } from './graphql';\nimport { hapiIntegration, instrumentHapi } from './hapi';\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 { instrumentPostgres, postgresIntegration } from './postgres';\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 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 ];\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 instrumentOtelHttp,\n instrumentExpress,\n instrumentExpressV5,\n instrumentConnect,\n instrumentFastify,\n instrumentHapi,\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 ];\n}\n"],"names":["expressIntegration","fastifyIntegration","graphqlIntegration","mongoIntegration","mongooseIntegration","mysqlIntegration","mysql2Integration","redisIntegration","postgresIntegration","prismaIntegration","hapiIntegration","koaIntegration","connectIntegration","tediousIntegration","genericPoolIntegration","kafkaIntegration","amqplibIntegration","lruMemoizerIntegration","vercelAIIntegration","instrumentOtelHttp","instrumentExpress","instrumentExpressV5","instrumentConnect","instrumentFastify","instrumentHapi","instrumentKafka","instrumentKoa","instrumentLruMemoizer","instrumentMongo","instrumentMongoose","instrumentMysql","instrumentMysql2","instrumentPostgres","instrumentGraphql","instrumentRedis","instrumentTedious","instrumentGenericPool","instrumentAmqplib","instrumentVercelAi"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;AACO,SAAS,8BAA8B,GAAkB;AAChE,EAAE,OAAO;AACT,IAAIA,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,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,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAmD;AAC3G,EAAE,OAAO;AACT,IAAIC,wBAAkB;AACtB,IAAIC,yBAAiB;AACrB,IAAIC,2BAAmB;AACvB,IAAIC,yBAAiB;AACrB,IAAIC,yBAAiB;AACrB,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,IAAIR,sBAAc;AAClB,IAAIS,yBAAiB;AACrB,IAAIC,qBAAe;AACnB,IAAIC,yBAAiB;AACrB,IAAIC,iCAAqB;AACzB,IAAIC,yBAAiB;AACrB,IAAIC,0BAAkB;AACtB,GAAG;AACH;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { instrumentOtelHttp } from '../http';\nimport { amqplibIntegration, instrumentAmqplib } from './amqplib';\nimport { connectIntegration, instrumentConnect } from './connect';\nimport { expressIntegration, instrumentExpress, instrumentExpressV5 } from './express';\nimport { fastifyIntegration, instrumentFastify, instrumentFastifyV3 } from './fastify';\nimport { genericPoolIntegration, instrumentGenericPool } from './genericPool';\nimport { graphqlIntegration, instrumentGraphql } from './graphql';\nimport { hapiIntegration, instrumentHapi } from './hapi';\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 { instrumentPostgres, postgresIntegration } from './postgres';\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 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 ];\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 instrumentOtelHttp,\n instrumentExpress,\n instrumentExpressV5,\n instrumentConnect,\n instrumentFastify,\n instrumentFastifyV3,\n instrumentHapi,\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 ];\n}\n"],"names":["expressIntegration","fastifyIntegration","graphqlIntegration","mongoIntegration","mongooseIntegration","mysqlIntegration","mysql2Integration","redisIntegration","postgresIntegration","prismaIntegration","hapiIntegration","koaIntegration","connectIntegration","tediousIntegration","genericPoolIntegration","kafkaIntegration","amqplibIntegration","lruMemoizerIntegration","vercelAIIntegration","instrumentOtelHttp","instrumentExpress","instrumentExpressV5","instrumentConnect","instrumentFastify","instrumentFastifyV3","instrumentHapi","instrumentKafka","instrumentKoa","instrumentLruMemoizer","instrumentMongo","instrumentMongoose","instrumentMysql","instrumentMysql2","instrumentPostgres","instrumentGraphql","instrumentRedis","instrumentTedious","instrumentGenericPool","instrumentAmqplib","instrumentVercelAi"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;AACO,SAAS,8BAA8B,GAAkB;AAChE,EAAE,OAAO;AACT,IAAIA,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,IAAIC,0BAAkB,EAAE;AACxB,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,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAmD;AAC3G,EAAE,OAAO;AACT,IAAIC,wBAAkB;AACtB,IAAIC,yBAAiB;AACrB,IAAIC,2BAAmB;AACvB,IAAIC,yBAAiB;AACrB,IAAIC,yBAAiB;AACrB,IAAIC,2BAAmB;AACvB,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,IAAIR,sBAAc;AAClB,IAAIS,yBAAiB;AACrB,IAAIC,qBAAe;AACnB,IAAIC,yBAAiB;AACrB,IAAIC,iCAAqB;AACzB,IAAIC,yBAAiB;AACrB,IAAIC,0BAAkB;AACtB,GAAG;AACH;;;;;"}
@@ -11,7 +11,7 @@ export { onUncaughtExceptionIntegration } from './integrations/onuncaughtexcepti
11
11
  export { onUnhandledRejectionIntegration } from './integrations/onunhandledrejection.js';
12
12
  export { anrIntegration, disableAnrDetectionForCallback } from './integrations/anr/index.js';
13
13
  export { expressErrorHandler, expressIntegration, setupExpressErrorHandler } from './integrations/tracing/express.js';
14
- export { fastifyIntegration, setupFastifyErrorHandler } from './integrations/tracing/fastify.js';
14
+ export { fastifyIntegration, setupFastifyErrorHandler } from './integrations/tracing/fastify/index.js';
15
15
  export { graphqlIntegration } from './integrations/tracing/graphql.js';
16
16
  export { kafkaIntegration } from './integrations/tracing/kafka.js';
17
17
  export { lruMemoizerIntegration } from './integrations/tracing/lrumemoizer.js';