@sentry/node 9.16.0 → 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 (80) 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/http/index.js +0 -18
  4. package/build/cjs/integrations/http/index.js.map +1 -1
  5. package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  6. package/build/cjs/integrations/tracing/fastify/index.js +187 -0
  7. package/build/cjs/integrations/tracing/fastify/index.js.map +1 -0
  8. package/build/cjs/integrations/tracing/fastify/v3/constants.js +23 -0
  9. package/build/cjs/integrations/tracing/fastify/v3/constants.js.map +1 -0
  10. package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
  11. package/build/cjs/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
  12. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js +303 -0
  13. package/build/cjs/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
  14. package/build/cjs/integrations/tracing/fastify/v3/utils.js +135 -0
  15. package/build/cjs/integrations/tracing/fastify/v3/utils.js.map +1 -0
  16. package/build/cjs/integrations/tracing/index.js +11 -10
  17. package/build/cjs/integrations/tracing/index.js.map +1 -1
  18. package/build/esm/index.js +1 -1
  19. package/build/esm/integrations/anr/index.js +1 -1
  20. package/build/esm/integrations/anr/worker-script.js +2 -2
  21. package/build/esm/integrations/http/index.js +0 -18
  22. package/build/esm/integrations/http/index.js.map +1 -1
  23. package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  24. package/build/esm/integrations/local-variables/worker-script.js +2 -2
  25. package/build/esm/integrations/tracing/fastify/index.js +182 -0
  26. package/build/esm/integrations/tracing/fastify/index.js.map +1 -0
  27. package/build/esm/integrations/tracing/fastify/v3/constants.js +21 -0
  28. package/build/esm/integrations/tracing/fastify/v3/constants.js.map +1 -0
  29. package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js +37 -0
  30. package/build/esm/integrations/tracing/fastify/v3/enums/AttributeNames.js.map +1 -0
  31. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js +301 -0
  32. package/build/esm/integrations/tracing/fastify/v3/instrumentation.js.map +1 -0
  33. package/build/esm/integrations/tracing/fastify/v3/utils.js +131 -0
  34. package/build/esm/integrations/tracing/fastify/v3/utils.js.map +1 -0
  35. package/build/esm/integrations/tracing/index.js +2 -1
  36. package/build/esm/integrations/tracing/index.js.map +1 -1
  37. package/build/esm/package.json +1 -1
  38. package/build/types/integrations/http/index.d.ts.map +1 -1
  39. package/build/{types-ts3.8/integrations/tracing/fastify.d.ts → types/integrations/tracing/fastify/index.d.ts} +83 -103
  40. package/build/types/integrations/tracing/fastify/index.d.ts.map +1 -0
  41. package/build/types/integrations/tracing/fastify/types.d.ts +25 -0
  42. package/build/types/integrations/tracing/fastify/types.d.ts.map +1 -0
  43. package/build/types/integrations/tracing/fastify/v3/constants.d.ts +3 -0
  44. package/build/types/integrations/tracing/fastify/v3/constants.d.ts.map +1 -0
  45. package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
  46. package/build/types/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts.map +1 -0
  47. package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
  48. package/build/types/integrations/tracing/fastify/v3/instrumentation.d.ts.map +1 -0
  49. package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
  50. package/build/types/integrations/tracing/fastify/v3/internal-types.d.ts.map +1 -0
  51. package/build/types/integrations/tracing/fastify/v3/types.d.ts +21 -0
  52. package/build/types/integrations/tracing/fastify/v3/types.d.ts.map +1 -0
  53. package/build/types/integrations/tracing/fastify/v3/utils.d.ts +28 -0
  54. package/build/types/integrations/tracing/fastify/v3/utils.d.ts.map +1 -0
  55. package/build/types/integrations/tracing/index.d.ts.map +1 -1
  56. package/build/{types/integrations/tracing/fastify.d.ts → types-ts3.8/integrations/tracing/fastify/index.d.ts} +83 -103
  57. package/build/types-ts3.8/integrations/tracing/fastify/types.d.ts +25 -0
  58. package/build/types-ts3.8/integrations/tracing/fastify/v3/constants.d.ts +3 -0
  59. package/build/types-ts3.8/integrations/tracing/fastify/v3/enums/AttributeNames.d.ts +15 -0
  60. package/build/types-ts3.8/integrations/tracing/fastify/v3/instrumentation.d.ts +16 -0
  61. package/build/types-ts3.8/integrations/tracing/fastify/v3/internal-types.d.ts +7 -0
  62. package/build/types-ts3.8/integrations/tracing/fastify/v3/types.d.ts +21 -0
  63. package/build/types-ts3.8/integrations/tracing/fastify/v3/utils.d.ts +28 -0
  64. package/package.json +4 -4
  65. package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js +0 -136
  66. package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +0 -1
  67. package/build/cjs/integrations/http/utils.js +0 -44
  68. package/build/cjs/integrations/http/utils.js.map +0 -1
  69. package/build/cjs/integrations/tracing/fastify.js +0 -160
  70. package/build/cjs/integrations/tracing/fastify.js.map +0 -1
  71. package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js +0 -134
  72. package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +0 -1
  73. package/build/esm/integrations/http/utils.js +0 -42
  74. package/build/esm/integrations/http/utils.js.map +0 -1
  75. package/build/esm/integrations/tracing/fastify.js +0 -156
  76. package/build/esm/integrations/tracing/fastify.js.map +0 -1
  77. package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +0 -17
  78. package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts.map +0 -1
  79. package/build/types/integrations/tracing/fastify.d.ts.map +0 -1
  80. package/build/types-ts3.8/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +0 -20
@@ -0,0 +1,187 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ const diagnosticsChannel = require('node:diagnostics_channel');
4
+ const otel = require('@fastify/otel');
5
+ const core = require('@sentry/core');
6
+ const debugBuild = require('../../../debug-build.js');
7
+ const instrument = require('../../../otel/instrument.js');
8
+ const instrumentation = require('./v3/instrumentation.js');
9
+
10
+ const INTEGRATION_NAME = 'Fastify';
11
+ const INTEGRATION_NAME_V3 = 'Fastify-V3';
12
+
13
+ const instrumentFastifyV3 = instrument.generateInstrumentOnce(INTEGRATION_NAME_V3, () => new instrumentation.FastifyInstrumentationV3());
14
+
15
+ const instrumentFastify = instrument.generateInstrumentOnce(INTEGRATION_NAME, () => {
16
+ const fastifyOtelInstrumentationInstance = new otel.FastifyOtelInstrumentation();
17
+ const plugin = fastifyOtelInstrumentationInstance.plugin();
18
+
19
+ // This message handler works for Fastify versions 3, 4 and 5
20
+ diagnosticsChannel.subscribe('fastify.initialization', message => {
21
+ const fastifyInstance = (message ).fastify;
22
+
23
+ fastifyInstance?.register(plugin).after(err => {
24
+ if (err) {
25
+ debugBuild.DEBUG_BUILD && core.logger.error('Failed to setup Fastify instrumentation', err);
26
+ } else {
27
+ instrumentClient();
28
+
29
+ if (fastifyInstance) {
30
+ instrumentOnRequest(fastifyInstance);
31
+ }
32
+ }
33
+ });
34
+ });
35
+
36
+ // Returning this as unknown not to deal with the internal types of the FastifyOtelInstrumentation
37
+ return fastifyOtelInstrumentationInstance ;
38
+ });
39
+
40
+ const _fastifyIntegration = (() => {
41
+ return {
42
+ name: INTEGRATION_NAME,
43
+ setupOnce() {
44
+ instrumentFastifyV3();
45
+ instrumentFastify();
46
+ },
47
+ };
48
+ }) ;
49
+
50
+ /**
51
+ * Adds Sentry tracing instrumentation for [Fastify](https://fastify.dev/).
52
+ *
53
+ * If you also want to capture errors, you need to call `setupFastifyErrorHandler(app)` after you set up your Fastify server.
54
+ *
55
+ * For more information, see the [fastify documentation](https://docs.sentry.io/platforms/javascript/guides/fastify/).
56
+ *
57
+ * @example
58
+ * ```javascript
59
+ * const Sentry = require('@sentry/node');
60
+ *
61
+ * Sentry.init({
62
+ * integrations: [Sentry.fastifyIntegration()],
63
+ * })
64
+ * ```
65
+ */
66
+ const fastifyIntegration = core.defineIntegration(_fastifyIntegration);
67
+
68
+ /**
69
+ * Default function to determine if an error should be sent to Sentry
70
+ *
71
+ * 3xx and 4xx errors are not sent by default.
72
+ */
73
+ function defaultShouldHandleError(_error, _request, reply) {
74
+ const statusCode = reply.statusCode;
75
+ // 3xx and 4xx errors are not sent by default.
76
+ return statusCode >= 500 || statusCode <= 299;
77
+ }
78
+
79
+ /**
80
+ * Add an Fastify error handler to capture errors to Sentry.
81
+ *
82
+ * @param fastify The Fastify instance to which to add the error handler
83
+ * @param options Configuration options for the handler
84
+ *
85
+ * @example
86
+ * ```javascript
87
+ * const Sentry = require('@sentry/node');
88
+ * const Fastify = require("fastify");
89
+ *
90
+ * const app = Fastify();
91
+ *
92
+ * Sentry.setupFastifyErrorHandler(app);
93
+ *
94
+ * // Add your routes, etc.
95
+ *
96
+ * app.listen({ port: 3000 });
97
+ * ```
98
+ */
99
+ function setupFastifyErrorHandler(fastify, options) {
100
+ const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;
101
+
102
+ const plugin = Object.assign(
103
+ function (fastify, _options, done) {
104
+ fastify.addHook('onError', async (request, reply, error) => {
105
+ if (shouldHandleError(error, request, reply)) {
106
+ core.captureException(error);
107
+ }
108
+ });
109
+
110
+ done();
111
+ },
112
+ {
113
+ [Symbol.for('skip-override')]: true,
114
+ [Symbol.for('fastify.display-name')]: 'sentry-fastify-error-handler',
115
+ },
116
+ );
117
+
118
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
119
+ fastify.register(plugin);
120
+ }
121
+
122
+ function addFastifySpanAttributes(span) {
123
+ const spanJSON = core.spanToJSON(span);
124
+ const spanName = spanJSON.description;
125
+ const attributes = spanJSON.data;
126
+
127
+ const type = attributes['fastify.type'];
128
+
129
+ const isHook = type === 'hook';
130
+ const isHandler = type === spanName?.startsWith('handler -');
131
+ // In @fastify/otel `request-handler` is separated by dash, not underscore
132
+ const isRequestHandler = spanName === 'request' || type === 'request-handler';
133
+
134
+ // If this is already set, or we have no fastify span, no need to process again...
135
+ if (attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_OP] || (!isHandler && !isRequestHandler && !isHook)) {
136
+ return;
137
+ }
138
+
139
+ const opPrefix = isHook ? 'hook' : isHandler ? 'middleware' : isRequestHandler ? 'request-handler' : '<unknown>';
140
+
141
+ span.setAttributes({
142
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.fastify',
143
+ [core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${opPrefix}.fastify`,
144
+ });
145
+
146
+ const attrName = attributes['fastify.name'] || attributes['plugin.name'] || attributes['hook.name'];
147
+ if (typeof attrName === 'string') {
148
+ // Try removing `fastify -> ` and `@fastify/otel -> ` prefixes
149
+ // This is a bit of a hack, and not always working for all spans
150
+ // But it's the best we can do without a proper API
151
+ const updatedName = attrName.replace(/^fastify -> /, '').replace(/^@fastify\/otel -> /, '');
152
+
153
+ span.updateName(updatedName);
154
+ }
155
+ }
156
+
157
+ function instrumentClient() {
158
+ const client = core.getClient();
159
+ if (client) {
160
+ client.on('spanStart', (span) => {
161
+ addFastifySpanAttributes(span);
162
+ });
163
+ }
164
+ }
165
+
166
+ function instrumentOnRequest(fastify) {
167
+ fastify.addHook('onRequest', async (request, _reply) => {
168
+ if (request.opentelemetry) {
169
+ const { span } = request.opentelemetry();
170
+
171
+ if (span) {
172
+ addFastifySpanAttributes(span);
173
+ }
174
+ }
175
+
176
+ const routeName = request.routeOptions?.url;
177
+ const method = request.method || 'GET';
178
+
179
+ core.getIsolationScope().setTransactionName(`${method} ${routeName}`);
180
+ });
181
+ }
182
+
183
+ exports.fastifyIntegration = fastifyIntegration;
184
+ exports.instrumentFastify = instrumentFastify;
185
+ exports.instrumentFastifyV3 = instrumentFastifyV3;
186
+ exports.setupFastifyErrorHandler = setupFastifyErrorHandler;
187
+ //# 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":["generateInstrumentOnce","FastifyInstrumentationV3","FastifyOtelInstrumentation","DEBUG_BUILD","logger","defineIntegration","captureException","spanToJSON","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","getClient","getIsolationScope"],"mappings":";;;;;;;;;AAsDA,MAAM,gBAAA,GAAmB,SAAS;AAClC,MAAM,mBAAA,GAAsB,YAAY;;AAE3B,MAAA,mBAAA,GAAsBA,iCAAsB,CAAC,mBAAmB,EAAE,MAAM,IAAIC,wCAAwB,EAAE;;AAE5G,MAAM,oBAAoBD,iCAAsB,CAAC,gBAAgB,EAAE,MAAM;AAChF,EAAE,MAAM,kCAAmC,GAAE,IAAIE,+BAA0B,EAAE;AAC7E,EAAE,MAAM,MAAO,GAAE,kCAAkC,CAAC,MAAM,EAAE;;AAE5D;AACA,EAAE,kBAAkB,CAAC,SAAS,CAAC,wBAAwB,EAAE,WAAW;AACpE,IAAI,MAAM,eAAgB,GAAE,CAAC,OAAQ,GAAkC,OAAO;;AAE9E,IAAI,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAA,IAAO;AACnD,MAAM,IAAI,GAAG,EAAE;AACf,QAAQC,sBAAA,IAAeC,WAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,GAAG,CAAC;AACnF,aAAa;AACb,QAAQ,gBAAgB,EAAE;;AAE1B,QAAQ,IAAI,eA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AA,CAAA;AACA,EAAA,IAAA,OAAA,QAAA,KAAA,QAAA,EAAA;AACA;AACA;AACA;AACA,IAAA,MAAA,WAAA,GAAA,QAAA,CAAA,OAAA,CAAA,cAAA,EAAA,EAAA,CAAA,CAAA,OAAA,CAAA,qBAAA,EAAA,EAAA,CAAA;;AAEA,IAAA,IAAA,CAAA,UAAA,CAAA,WAAA,CAAA;AACA;AACA;;AAEA,SAAA,gBAAA,GAAA;AACA,EAAA,MAAA,MAAA,GAAAE,cAAA,EAAA;AACA,EAAA,IAAA,MAAA,EAAA;AACA,IAAA,MAAA,CAAA,EAAA,CAAA,WAAA,EAAA,CAAA,IAAA,KAAA;AACA,MAAA,wBAAA,CAAA,IAAA,CAAA;AACA,KAAA,CAAA;AACA;AACA;;AAEA,SAAA,mBAAA,CAAA,OAAA,EAAA;AACA,EAAA,OAAA,CAAA,OAAA,CAAA,WAAA,EAAA,OAAA,OAAA,EAAA,MAAA,KAAA;AACA,IAAA,IAAA,OAAA,CAAA,aAAA,EAAA;AACA,MAAA,MAAA,EAAA,IAAA,EAAA,GAAA,OAAA,CAAA,aAAA,EAAA;;AAEA,MAAA,IAAA,IAAA,EAAA;AACA,QAAA,wBAAA,CAAA,IAAA,CAAA;AACA;AACA;;AAEA,IAAA,MAAA,SAAA,GAAA,OAAA,CAAA,YAAA,EAAA,GAAA;AACA,IAAA,MAAA,MAAA,GAAA,OAAA,CAAA,MAAA,IAAA,KAAA;;AAEA,IAAAC,sBAAA,EAAA,CAAA,kBAAA,CAAA,CAAA,EAAA,MAAA,CAAA,CAAA,EAAA,SAAA,CAAA,CAAA,CAAA;AACA,GAAA,CAAA;AACA;;;;;;;"}
@@ -0,0 +1,23 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ // Vendored from https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/constants.ts
4
+ /*
5
+ * Copyright The OpenTelemetry Authors
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * https://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ const spanRequestSymbol = Symbol('opentelemetry.instrumentation.fastify.request_active_span');
21
+
22
+ exports.spanRequestSymbol = spanRequestSymbol;
23
+ //# 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
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ // Vendored from https://github.com/open-telemetry/opentelemetry-js-contrib/blob/407f61591ba69a39a6908264379d4d98a48dbec4/plugins/node/opentelemetry-instrumentation-fastify/src/enums/AttributeNames.ts
4
+ //
5
+ /*
6
+ * Copyright The OpenTelemetry Authors
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * https://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ */
20
+
21
+ exports.AttributeNames = void 0; (function (AttributeNames) {
22
+ const FASTIFY_NAME = 'fastify.name'; AttributeNames["FASTIFY_NAME"] = FASTIFY_NAME;
23
+ const FASTIFY_TYPE = 'fastify.type'; AttributeNames["FASTIFY_TYPE"] = FASTIFY_TYPE;
24
+ const HOOK_NAME = 'hook.name'; AttributeNames["HOOK_NAME"] = HOOK_NAME;
25
+ const PLUGIN_NAME = 'plugin.name'; AttributeNames["PLUGIN_NAME"] = PLUGIN_NAME;
26
+ })(exports.AttributeNames || (exports.AttributeNames = {}));
27
+
28
+ exports.FastifyTypes = void 0; (function (FastifyTypes) {
29
+ const MIDDLEWARE = 'middleware'; FastifyTypes["MIDDLEWARE"] = MIDDLEWARE;
30
+ const REQUEST_HANDLER = 'request_handler'; FastifyTypes["REQUEST_HANDLER"] = REQUEST_HANDLER;
31
+ })(exports.FastifyTypes || (exports.FastifyTypes = {}));
32
+
33
+ exports.FastifyNames = void 0; (function (FastifyNames) {
34
+ const MIDDLEWARE = 'middleware'; FastifyNames["MIDDLEWARE"] = MIDDLEWARE;
35
+ const REQUEST_HANDLER = 'request handler'; FastifyNames["REQUEST_HANDLER"] = REQUEST_HANDLER;
36
+ })(exports.FastifyNames || (exports.FastifyNames = {}));
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":["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;AACpB,EAAE,YAAY;AACd,EAAE,QAAQ;AACV,EAAE,YAAY;AACd,EAAE,SAAS;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACO,MAAM,wBAAA,SAAiCA,mCAAmB,CAA+B;AAChG,GAAS,WAAW,CAAC,MAAM,GAAiC,E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