@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,182 @@
1
+ import * as diagnosticsChannel from 'node:diagnostics_channel';
2
+ import { FastifyOtelInstrumentation } from '@fastify/otel';
3
+ import { defineIntegration, captureException, logger, getClient, getIsolationScope, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
4
+ import { DEBUG_BUILD } from '../../../debug-build.js';
5
+ import { generateInstrumentOnce } from '../../../otel/instrument.js';
6
+ import { FastifyInstrumentationV3 } from './v3/instrumentation.js';
7
+
8
+ const INTEGRATION_NAME = 'Fastify';
9
+ const INTEGRATION_NAME_V3 = 'Fastify-V3';
10
+
11
+ const instrumentFastifyV3 = generateInstrumentOnce(INTEGRATION_NAME_V3, () => new FastifyInstrumentationV3());
12
+
13
+ const instrumentFastify = generateInstrumentOnce(INTEGRATION_NAME, () => {
14
+ const fastifyOtelInstrumentationInstance = new FastifyOtelInstrumentation();
15
+ const plugin = fastifyOtelInstrumentationInstance.plugin();
16
+
17
+ // This message handler works for Fastify versions 3, 4 and 5
18
+ diagnosticsChannel.subscribe('fastify.initialization', message => {
19
+ const fastifyInstance = (message ).fastify;
20
+
21
+ fastifyInstance?.register(plugin).after(err => {
22
+ if (err) {
23
+ DEBUG_BUILD && logger.error('Failed to setup Fastify instrumentation', err);
24
+ } else {
25
+ instrumentClient();
26
+
27
+ if (fastifyInstance) {
28
+ instrumentOnRequest(fastifyInstance);
29
+ }
30
+ }
31
+ });
32
+ });
33
+
34
+ // Returning this as unknown not to deal with the internal types of the FastifyOtelInstrumentation
35
+ return fastifyOtelInstrumentationInstance ;
36
+ });
37
+
38
+ const _fastifyIntegration = (() => {
39
+ return {
40
+ name: INTEGRATION_NAME,
41
+ setupOnce() {
42
+ instrumentFastifyV3();
43
+ instrumentFastify();
44
+ },
45
+ };
46
+ }) ;
47
+
48
+ /**
49
+ * Adds Sentry tracing instrumentation for [Fastify](https://fastify.dev/).
50
+ *
51
+ * If you also want to capture errors, you need to call `setupFastifyErrorHandler(app)` after you set up your Fastify server.
52
+ *
53
+ * For more information, see the [fastify documentation](https://docs.sentry.io/platforms/javascript/guides/fastify/).
54
+ *
55
+ * @example
56
+ * ```javascript
57
+ * const Sentry = require('@sentry/node');
58
+ *
59
+ * Sentry.init({
60
+ * integrations: [Sentry.fastifyIntegration()],
61
+ * })
62
+ * ```
63
+ */
64
+ const fastifyIntegration = defineIntegration(_fastifyIntegration);
65
+
66
+ /**
67
+ * Default function to determine if an error should be sent to Sentry
68
+ *
69
+ * 3xx and 4xx errors are not sent by default.
70
+ */
71
+ function defaultShouldHandleError(_error, _request, reply) {
72
+ const statusCode = reply.statusCode;
73
+ // 3xx and 4xx errors are not sent by default.
74
+ return statusCode >= 500 || statusCode <= 299;
75
+ }
76
+
77
+ /**
78
+ * Add an Fastify error handler to capture errors to Sentry.
79
+ *
80
+ * @param fastify The Fastify instance to which to add the error handler
81
+ * @param options Configuration options for the handler
82
+ *
83
+ * @example
84
+ * ```javascript
85
+ * const Sentry = require('@sentry/node');
86
+ * const Fastify = require("fastify");
87
+ *
88
+ * const app = Fastify();
89
+ *
90
+ * Sentry.setupFastifyErrorHandler(app);
91
+ *
92
+ * // Add your routes, etc.
93
+ *
94
+ * app.listen({ port: 3000 });
95
+ * ```
96
+ */
97
+ function setupFastifyErrorHandler(fastify, options) {
98
+ const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;
99
+
100
+ const plugin = Object.assign(
101
+ function (fastify, _options, done) {
102
+ fastify.addHook('onError', async (request, reply, error) => {
103
+ if (shouldHandleError(error, request, reply)) {
104
+ captureException(error);
105
+ }
106
+ });
107
+
108
+ done();
109
+ },
110
+ {
111
+ [Symbol.for('skip-override')]: true,
112
+ [Symbol.for('fastify.display-name')]: 'sentry-fastify-error-handler',
113
+ },
114
+ );
115
+
116
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
117
+ fastify.register(plugin);
118
+ }
119
+
120
+ function addFastifySpanAttributes(span) {
121
+ const spanJSON = spanToJSON(span);
122
+ const spanName = spanJSON.description;
123
+ const attributes = spanJSON.data;
124
+
125
+ const type = attributes['fastify.type'];
126
+
127
+ const isHook = type === 'hook';
128
+ const isHandler = type === spanName?.startsWith('handler -');
129
+ // In @fastify/otel `request-handler` is separated by dash, not underscore
130
+ const isRequestHandler = spanName === 'request' || type === 'request-handler';
131
+
132
+ // If this is already set, or we have no fastify span, no need to process again...
133
+ if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || (!isHandler && !isRequestHandler && !isHook)) {
134
+ return;
135
+ }
136
+
137
+ const opPrefix = isHook ? 'hook' : isHandler ? 'middleware' : isRequestHandler ? 'request-handler' : '<unknown>';
138
+
139
+ span.setAttributes({
140
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.fastify',
141
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${opPrefix}.fastify`,
142
+ });
143
+
144
+ const attrName = attributes['fastify.name'] || attributes['plugin.name'] || attributes['hook.name'];
145
+ if (typeof attrName === 'string') {
146
+ // Try removing `fastify -> ` and `@fastify/otel -> ` prefixes
147
+ // This is a bit of a hack, and not always working for all spans
148
+ // But it's the best we can do without a proper API
149
+ const updatedName = attrName.replace(/^fastify -> /, '').replace(/^@fastify\/otel -> /, '');
150
+
151
+ span.updateName(updatedName);
152
+ }
153
+ }
154
+
155
+ function instrumentClient() {
156
+ const client = getClient();
157
+ if (client) {
158
+ client.on('spanStart', (span) => {
159
+ addFastifySpanAttributes(span);
160
+ });
161
+ }
162
+ }
163
+
164
+ function instrumentOnRequest(fastify) {
165
+ fastify.addHook('onRequest', async (request, _reply) => {
166
+ if (request.opentelemetry) {
167
+ const { span } = request.opentelemetry();
168
+
169
+ if (span) {
170
+ addFastifySpanAttributes(span);
171
+ }
172
+ }
173
+
174
+ const routeName = request.routeOptions?.url;
175
+ const method = request.method || 'GET';
176
+
177
+ getIsolationScope().setTransactionName(`${method} ${routeName}`);
178
+ });
179
+ }
180
+
181
+ export { fastifyIntegration, instrumentFastify, instrumentFastifyV3, setupFastifyErrorHandler };
182
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/fastify/index.ts"],"sourcesContent":["import * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { FastifyOtelInstrumentation } from '@fastify/otel';\nimport type { Instrumentation, InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n captureException,\n defineIntegration,\n getClient,\n getIsolationScope,\n logger,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport { generateInstrumentOnce } from '../../../otel/instrument';\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from './types';\nimport { FastifyInstrumentationV3 } from './v3/instrumentation';\n\ninterface FastifyHandlerOptions {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n *\n * @param error Captured Fastify error\n * @param request Fastify request (or any object containing at least method, routeOptions.url, and routerPath)\n * @param reply Fastify reply (or any object containing at least statusCode)\n *\n * @example\n *\n * ```javascript\n * setupFastifyErrorHandler(app, {\n * shouldHandleError(_error, _request, reply) {\n * return reply.statusCode >= 400;\n * },\n * });\n * ```\n *\n * If using TypeScript, you can cast the request and reply to get full type safety.\n *\n * ```typescript\n * import type { FastifyRequest, FastifyReply } from 'fastify';\n *\n * setupFastifyErrorHandler(app, {\n * shouldHandleError(error, minimalRequest, minimalReply) {\n * const request = minimalRequest as FastifyRequest;\n * const reply = minimalReply as FastifyReply;\n * return reply.statusCode >= 500;\n * },\n * });\n * ```\n */\n shouldHandleError: (error: Error, request: FastifyRequest, reply: FastifyReply) => boolean;\n}\n\nconst INTEGRATION_NAME = 'Fastify';\nconst INTEGRATION_NAME_V3 = 'Fastify-V3';\n\nexport const instrumentFastifyV3 = generateInstrumentOnce(INTEGRATION_NAME_V3, () => new FastifyInstrumentationV3());\n\nexport const instrumentFastify = generateInstrumentOnce(INTEGRATION_NAME, () => {\n const fastifyOtelInstrumentationInstance = new FastifyOtelInstrumentation();\n const plugin = fastifyOtelInstrumentationInstance.plugin();\n\n // This message handler works for Fastify versions 3, 4 and 5\n diagnosticsChannel.subscribe('fastify.initialization', message => {\n const fastifyInstance = (message as { fastify?: FastifyInstance }).fastify;\n\n fastifyInstance?.register(plugin).after(err => {\n if (err) {\n DEBUG_BUILD && logger.error('Failed to setup Fastify instrumentation', err);\n } else {\n instrumentClient();\n\n if (fastifyInstance) {\n instrumentOnRequest(fastifyInstance);\n }\n }\n });\n });\n\n // Returning this as unknown not to deal with the internal types of the FastifyOtelInstrumentation\n return fastifyOtelInstrumentationInstance as Instrumentation<InstrumentationConfig>;\n});\n\nconst _fastifyIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentFastifyV3();\n instrumentFastify();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for [Fastify](https://fastify.dev/).\n *\n * If you also want to capture errors, you need to call `setupFastifyErrorHandler(app)` after you set up your Fastify server.\n *\n * For more information, see the [fastify documentation](https://docs.sentry.io/platforms/javascript/guides/fastify/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.fastifyIntegration()],\n * })\n * ```\n */\nexport const fastifyIntegration = defineIntegration(_fastifyIntegration);\n\n/**\n * Default function to determine if an error should be sent to Sentry\n *\n * 3xx and 4xx errors are not sent by default.\n */\nfunction defaultShouldHandleError(_error: Error, _request: FastifyRequest, reply: FastifyReply): boolean {\n const statusCode = reply.statusCode;\n // 3xx and 4xx errors are not sent by default.\n return statusCode >= 500 || statusCode <= 299;\n}\n\n/**\n * Add an Fastify error handler to capture errors to Sentry.\n *\n * @param fastify The Fastify instance to which to add the error handler\n * @param options Configuration options for the handler\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const Fastify = require(\"fastify\");\n *\n * const app = Fastify();\n *\n * Sentry.setupFastifyErrorHandler(app);\n *\n * // Add your routes, etc.\n *\n * app.listen({ port: 3000 });\n * ```\n */\nexport function setupFastifyErrorHandler(fastify: FastifyInstance, options?: Partial<FastifyHandlerOptions>): void {\n const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;\n\n const plugin = Object.assign(\n function (fastify: FastifyInstance, _options: unknown, done: () => void): void {\n fastify.addHook('onError', async (request, reply, error) => {\n if (shouldHandleError(error, request, reply)) {\n captureException(error);\n }\n });\n\n done();\n },\n {\n [Symbol.for('skip-override')]: true,\n [Symbol.for('fastify.display-name')]: 'sentry-fastify-error-handler',\n },\n );\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n fastify.register(plugin);\n}\n\nfunction addFastifySpanAttributes(span: Span): void {\n const spanJSON = spanToJSON(span);\n const spanName = spanJSON.description;\n const attributes = spanJSON.data;\n\n const type = attributes['fastify.type'];\n\n const isHook = type === 'hook';\n const isHandler = type === spanName?.startsWith('handler -');\n // In @fastify/otel `request-handler` is separated by dash, not underscore\n const isRequestHandler = spanName === 'request' || type === 'request-handler';\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] || (!isHandler && !isRequestHandler && !isHook)) {\n return;\n }\n\n const opPrefix = isHook ? 'hook' : isHandler ? 'middleware' : isRequestHandler ? 'request-handler' : '<unknown>';\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.fastify',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${opPrefix}.fastify`,\n });\n\n const attrName = attributes['fastify.name'] || attributes['plugin.name'] || attributes['hook.name'];\n if (typeof attrName === '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 = attrName.replace(/^fastify -> /, '').replace(/^@fastify\\/otel -> /, '');\n\n span.updateName(updatedName);\n }\n}\n\nfunction instrumentClient(): void {\n const client = getClient();\n if (client) {\n client.on('spanStart', (span: Span) => {\n addFastifySpanAttributes(span);\n });\n }\n}\n\nfunction instrumentOnRequest(fastify: FastifyInstance): void {\n fastify.addHook('onRequest', async (request: FastifyRequest & { opentelemetry?: () => { span?: Span } }, _reply) => {\n if (request.opentelemetry) {\n const { span } = request.opentelemetry();\n\n if (span) {\n addFastifySpanAttributes(span);\n }\n }\n\n const routeName = request.routeOptions?.url;\n const method = request.method || 'GET';\n\n getIsolationScope().setTransactionName(`${method} ${routeName}`);\n });\n}\n"],"names":[],"mappings":";;;;;;;AAsDA,MAAM,gBAAA,GAAmB,SAAS;AAClC,MAAM,mBAAA,GAAsB,YAAY;;AAE3B,MAAA,mBAAA,GAAsB,sBAAsB,CAAC,mBAAmB,EAAE,MAAM,IAAI,wBAAwB,EAAE;;AAE5G,MAAM,oBAAoB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM;AAChF,EAAE,MAAM,kCAAmC,GAAE,IAAI,0BAA0B,EAAE;AAC7E,EAAE,MAAM,MAAO,GAAE,kCAAkC,CAAC,MAAM,EAAE;;AAE5D;AACA,EAAE,kBAAkB,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A;;AAEA,IAAA,iBAAA,EAAA,CAAA,kBAAA,CAAA,CAAA,EAAA,MAAA,CAAA,CAAA,EAAA,SAAA,CAAA,CAAA,CAAA;AACA,GAAA,CAAA;AACA;;;;"}
@@ -0,0 +1,21 @@
1
+ // Vendored from https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/constants.ts
2
+ /*
3
+ * Copyright The OpenTelemetry Authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ const spanRequestSymbol = Symbol('opentelemetry.instrumentation.fastify.request_active_span');
19
+
20
+ export { spanRequestSymbol };
21
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../../../../src/integrations/tracing/fastify/v3/constants.ts"],"sourcesContent":["// Vendored from https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/constants.ts\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 const spanRequestSymbol = Symbol('opentelemetry.instrumentation.fastify.request_active_span');\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\nexport const hooksNamesToWrap = new Set([\n 'onTimeout',\n 'onRequest',\n 'preParsing',\n 'preValidation',\n 'preSerialization',\n 'preHandler',\n 'onSend',\n 'onResponse',\n 'onError',\n]);\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;MAEa,iBAAkB,GAAE,MAAM,CAAC,2DAA2D;;;;"}
@@ -0,0 +1,37 @@
1
+ // Vendored from https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/enums/AttributeNames.ts
2
+ //
3
+ /*
4
+ * Copyright The OpenTelemetry Authors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * https://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ var AttributeNames; (function (AttributeNames) {
20
+ const FASTIFY_NAME = 'fastify.name'; AttributeNames["FASTIFY_NAME"] = FASTIFY_NAME;
21
+ const FASTIFY_TYPE = 'fastify.type'; AttributeNames["FASTIFY_TYPE"] = FASTIFY_TYPE;
22
+ const HOOK_NAME = 'hook.name'; AttributeNames["HOOK_NAME"] = HOOK_NAME;
23
+ const PLUGIN_NAME = 'plugin.name'; AttributeNames["PLUGIN_NAME"] = PLUGIN_NAME;
24
+ })(AttributeNames || (AttributeNames = {}));
25
+
26
+ var FastifyTypes; (function (FastifyTypes) {
27
+ const MIDDLEWARE = 'middleware'; FastifyTypes["MIDDLEWARE"] = MIDDLEWARE;
28
+ const REQUEST_HANDLER = 'request_handler'; FastifyTypes["REQUEST_HANDLER"] = REQUEST_HANDLER;
29
+ })(FastifyTypes || (FastifyTypes = {}));
30
+
31
+ var FastifyNames; (function (FastifyNames) {
32
+ const MIDDLEWARE = 'middleware'; FastifyNames["MIDDLEWARE"] = MIDDLEWARE;
33
+ const REQUEST_HANDLER = 'request handler'; FastifyNames["REQUEST_HANDLER"] = REQUEST_HANDLER;
34
+ })(FastifyNames || (FastifyNames = {}));
35
+
36
+ export { AttributeNames, FastifyNames, FastifyTypes };
37
+ //# sourceMappingURL=AttributeNames.js.map
@@ -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":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAE2B,IAAA,eAAA,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,EAAA,cAAA,KAAA,cAAA,GAAA,EAAA,CAAA,CAAA;;AAEyB,IAAA,aAAA,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,EAAA,YAAA,KAAA,YAAA,GAAA,EAAA,CAAA,CAAA;;AAEyB,IAAA,aAAA,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,EAAA,YAAA,KAAA,YAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -0,0 +1,301 @@
1
+ import { context, trace, SpanStatusCode } from '@opentelemetry/api';
2
+ import { getRPCMetadata, RPCType } from '@opentelemetry/core';
3
+ import { InstrumentationBase, InstrumentationNodeModuleDefinition, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';
4
+ import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';
5
+ import { getIsolationScope, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getClient } from '@sentry/core';
6
+ import { FastifyNames, AttributeNames, FastifyTypes } from './enums/AttributeNames.js';
7
+ import { startSpan, endSpan, safeExecuteInTheMiddleMaybePromise } from './utils.js';
8
+
9
+ // Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts
10
+ /* eslint-disable @typescript-eslint/no-this-alias */
11
+ /* eslint-disable jsdoc/require-jsdoc */
12
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
13
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
14
+
15
+ /** @knipignore */
16
+
17
+ const PACKAGE_VERSION = '0.1.0';
18
+
19
+ const PACKAGE_NAME = '@sentry/instrumentation-fastify-v3';
20
+ const ANONYMOUS_NAME = 'anonymous';
21
+
22
+ // The instrumentation creates a span for invocations of lifecycle hook handlers
23
+ // that take `(request, reply, ...[, done])` arguments. Currently this is all
24
+ // lifecycle hooks except `onRequestAbort`.
25
+ // https://fastify.dev/docs/latest/Reference/Hooks
26
+ const hooksNamesToWrap = new Set([
27
+ 'onTimeout',
28
+ 'onRequest',
29
+ 'preParsing',
30
+ 'preValidation',
31
+ 'preSerialization',
32
+ 'preHandler',
33
+ 'onSend',
34
+ 'onResponse',
35
+ 'onError',
36
+ ]);
37
+
38
+ /**
39
+ * Fastify instrumentation for OpenTelemetry
40
+ */
41
+ class FastifyInstrumentationV3 extends InstrumentationBase {
42
+ constructor(config = {}) {
43
+ super(PACKAGE_NAME, PACKAGE_VERSION, config);
44
+ }
45
+
46
+ init() {
47
+ return [
48
+ new InstrumentationNodeModuleDefinition('fastify', ['>=3.0.0 <4'], moduleExports => {
49
+ return this._patchConstructor(moduleExports);
50
+ }),
51
+ ];
52
+ }
53
+
54
+ _hookOnRequest() {
55
+ const instrumentation = this;
56
+
57
+ return function onRequest(request, reply, done) {
58
+ if (!instrumentation.isEnabled()) {
59
+ return done();
60
+ }
61
+ instrumentation._wrap(reply, 'send', instrumentation._patchSend());
62
+
63
+ const anyRequest = request ;
64
+
65
+ const rpcMetadata = getRPCMetadata(context.active());
66
+ const routeName = anyRequest.routeOptions
67
+ ? anyRequest.routeOptions.url // since fastify@4.10.0
68
+ : request.routerPath;
69
+ if (routeName && rpcMetadata?.type === RPCType.HTTP) {
70
+ rpcMetadata.route = routeName;
71
+ }
72
+
73
+ const method = request.method || 'GET';
74
+
75
+ getIsolationScope().setTransactionName(`${method} ${routeName}`);
76
+ done();
77
+ };
78
+ }
79
+
80
+ _wrapHandler(
81
+ pluginName,
82
+ hookName,
83
+ original,
84
+ syncFunctionWithDone,
85
+ ) {
86
+ const instrumentation = this;
87
+ this._diag.debug('Patching fastify route.handler function');
88
+
89
+ return function ( ...args) {
90
+ if (!instrumentation.isEnabled()) {
91
+ return original.apply(this, args);
92
+ }
93
+
94
+ const name = original.name || pluginName || ANONYMOUS_NAME;
95
+ const spanName = `${FastifyNames.MIDDLEWARE} - ${name}`;
96
+
97
+ const reply = args[1] ;
98
+
99
+ const span = startSpan(reply, instrumentation.tracer, spanName, {
100
+ [AttributeNames.FASTIFY_TYPE]: FastifyTypes.MIDDLEWARE,
101
+ [AttributeNames.PLUGIN_NAME]: pluginName,
102
+ [AttributeNames.HOOK_NAME]: hookName,
103
+ });
104
+
105
+ const origDone = syncFunctionWithDone && (args[args.length - 1] );
106
+ if (origDone) {
107
+ args[args.length - 1] = function (...doneArgs) {
108
+ endSpan(reply);
109
+ origDone.apply(this, doneArgs);
110
+ };
111
+ }
112
+
113
+ return context.with(trace.setSpan(context.active(), span), () => {
114
+ return safeExecuteInTheMiddleMaybePromise(
115
+ () => {
116
+ return original.apply(this, args);
117
+ },
118
+ err => {
119
+ if (err instanceof Error) {
120
+ span.setStatus({
121
+ code: SpanStatusCode.ERROR,
122
+ message: err.message,
123
+ });
124
+ span.recordException(err);
125
+ }
126
+ // async hooks should end the span as soon as the promise is resolved
127
+ if (!syncFunctionWithDone) {
128
+ endSpan(reply);
129
+ }
130
+ },
131
+ );
132
+ });
133
+ };
134
+ }
135
+
136
+ _wrapAddHook() {
137
+ const instrumentation = this;
138
+ this._diag.debug('Patching fastify server.addHook function');
139
+
140
+ // biome-ignore lint/complexity/useArrowFunction: <explanation>
141
+ return function (original) {
142
+ return function wrappedAddHook( ...args) {
143
+ const name = args[0] ;
144
+ const handler = args[1] ;
145
+ const pluginName = this.pluginName;
146
+ if (!hooksNamesToWrap.has(name)) {
147
+ return original.apply(this, args);
148
+ }
149
+
150
+ const syncFunctionWithDone =
151
+ typeof args[args.length - 1] === 'function' && handler.constructor.name !== 'AsyncFunction';
152
+
153
+ return original.apply(this, [
154
+ name,
155
+ instrumentation._wrapHandler(pluginName, name, handler, syncFunctionWithDone),
156
+ ] );
157
+ };
158
+ };
159
+ }
160
+
161
+ _patchConstructor(moduleExports
162
+
163
+ ) {
164
+ const instrumentation = this;
165
+
166
+ function fastify( ...args) {
167
+ const app = moduleExports.fastify.apply(this, args);
168
+ app.addHook('onRequest', instrumentation._hookOnRequest());
169
+ app.addHook('preHandler', instrumentation._hookPreHandler());
170
+
171
+ instrumentClient();
172
+
173
+ instrumentation._wrap(app, 'addHook', instrumentation._wrapAddHook());
174
+
175
+ return app;
176
+ }
177
+
178
+ if (moduleExports.errorCodes !== undefined) {
179
+ fastify.errorCodes = moduleExports.errorCodes;
180
+ }
181
+ fastify.fastify = fastify;
182
+ fastify.default = fastify;
183
+ return fastify;
184
+ }
185
+
186
+ _patchSend() {
187
+ const instrumentation = this;
188
+ this._diag.debug('Patching fastify reply.send function');
189
+
190
+ return function patchSend(original) {
191
+ return function send( ...args) {
192
+ const maybeError = args[0];
193
+
194
+ if (!instrumentation.isEnabled()) {
195
+ return original.apply(this, args);
196
+ }
197
+
198
+ return safeExecuteInTheMiddle(
199
+ () => {
200
+ return original.apply(this, args);
201
+ },
202
+ err => {
203
+ if (!err && maybeError instanceof Error) {
204
+ // eslint-disable-next-line no-param-reassign
205
+ err = maybeError;
206
+ }
207
+ endSpan(this, err);
208
+ },
209
+ );
210
+ };
211
+ };
212
+ }
213
+
214
+ _hookPreHandler() {
215
+ const instrumentation = this;
216
+ this._diag.debug('Patching fastify preHandler function');
217
+
218
+ return function preHandler( request, reply, done) {
219
+ if (!instrumentation.isEnabled()) {
220
+ return done();
221
+ }
222
+ const anyRequest = request ;
223
+
224
+ const handler = anyRequest.routeOptions?.handler || anyRequest.context?.handler;
225
+ const handlerName = handler?.name.startsWith('bound ') ? handler.name.substring(6) : handler?.name;
226
+ const spanName = `${FastifyNames.REQUEST_HANDLER} - ${handlerName || this.pluginName || ANONYMOUS_NAME}`;
227
+
228
+ const spanAttributes = {
229
+ [AttributeNames.PLUGIN_NAME]: this.pluginName,
230
+ [AttributeNames.FASTIFY_TYPE]: FastifyTypes.REQUEST_HANDLER,
231
+ // eslint-disable-next-line deprecation/deprecation
232
+ [SEMATTRS_HTTP_ROUTE]: anyRequest.routeOptions
233
+ ? anyRequest.routeOptions.url // since fastify@4.10.0
234
+ : request.routerPath,
235
+ };
236
+ if (handlerName) {
237
+ spanAttributes[AttributeNames.FASTIFY_NAME] = handlerName;
238
+ }
239
+ const span = startSpan(reply, instrumentation.tracer, spanName, spanAttributes);
240
+
241
+ addFastifyV3SpanAttributes(span);
242
+
243
+ const { requestHook } = instrumentation.getConfig();
244
+ if (requestHook) {
245
+ safeExecuteInTheMiddle(
246
+ () => requestHook(span, { request }),
247
+ e => {
248
+ if (e) {
249
+ instrumentation._diag.error('request hook failed', e);
250
+ }
251
+ },
252
+ true,
253
+ );
254
+ }
255
+
256
+ return context.with(trace.setSpan(context.active(), span), () => {
257
+ done();
258
+ });
259
+ };
260
+ }
261
+ }
262
+
263
+ function instrumentClient() {
264
+ const client = getClient();
265
+ if (client) {
266
+ client.on('spanStart', (span) => {
267
+ addFastifyV3SpanAttributes(span);
268
+ });
269
+ }
270
+ }
271
+
272
+ function addFastifyV3SpanAttributes(span) {
273
+ const attributes = spanToJSON(span).data;
274
+
275
+ // this is one of: middleware, request_handler
276
+ const type = attributes['fastify.type'];
277
+
278
+ // If this is already set, or we have no fastify span, no need to process again...
279
+ if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {
280
+ return;
281
+ }
282
+
283
+ span.setAttributes({
284
+ [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.fastify',
285
+ [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.fastify`,
286
+ });
287
+
288
+ // Also update the name, we don't need to "middleware - " prefix
289
+ const name = attributes['fastify.name'] || attributes['plugin.name'] || attributes['hook.name'];
290
+ if (typeof name === 'string') {
291
+ // Try removing `fastify -> ` and `@fastify/otel -> ` prefixes
292
+ // This is a bit of a hack, and not always working for all spans
293
+ // But it's the best we can do without a proper API
294
+ const updatedName = name.replace(/^fastify -> /, '').replace(/^@fastify\/otel -> /, '');
295
+
296
+ span.updateName(updatedName);
297
+ }
298
+ }
299
+
300
+ export { FastifyInstrumentationV3 };
301
+ //# 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":[],"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;AACpB,EAAE,YAAY;AACd,EAAE,QAAQ;AACV,EAAE,YAAY;AACd,EAAE,SAAS;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACO,MAAM,wBAAA,SAAiC,mBAAmB,CAA+B;AAChG,GAAS,WAAW,CAAC,MAAM,GAAiC,EAAE,EAAE;AAChE,IAAI,KAAK,CAAC,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC;AAChD;;AAEA,GAAS,IAAI,GAA0C;AACvD,IAAI,OAAO;AACX,MAAM,IA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