@opentelemetry/instrumentation-fastify 0.44.2 → 0.45.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.
@@ -16,7 +16,11 @@
16
16
  */
17
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
18
  if (k2 === undefined) k2 = k;
19
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
20
24
  }) : (function(o, m, k, k2) {
21
25
  if (k2 === undefined) k2 = k;
22
26
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,yDAAuC;AACvC,0CAAwB;AACxB,oDAAkC","sourcesContent":["/*\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 * from './enums/AttributeNames';\nexport * from './types';\nexport * from './instrumentation';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAEH,yDAAuC;AACvC,0CAAwB;AACxB,oDAAkC","sourcesContent":["/*\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 * from './enums/AttributeNames';\nexport * from './types';\nexport * from './instrumentation';\n"]}
@@ -54,7 +54,7 @@ class FastifyInstrumentation extends instrumentation_1.InstrumentationBase {
54
54
  const routeName = anyRequest.routeOptions
55
55
  ? anyRequest.routeOptions.url // since fastify@4.10.0
56
56
  : request.routerPath;
57
- if (routeName && (rpcMetadata === null || rpcMetadata === void 0 ? void 0 : rpcMetadata.type) === core_1.RPCType.HTTP) {
57
+ if (routeName && rpcMetadata?.type === core_1.RPCType.HTTP) {
58
58
  rpcMetadata.route = routeName;
59
59
  }
60
60
  done();
@@ -162,15 +162,14 @@ class FastifyInstrumentation extends instrumentation_1.InstrumentationBase {
162
162
  const instrumentation = this;
163
163
  this._diag.debug('Patching fastify preHandler function');
164
164
  return function preHandler(request, reply, done) {
165
- var _a, _b;
166
165
  if (!instrumentation.isEnabled()) {
167
166
  return done();
168
167
  }
169
168
  const anyRequest = request;
170
- const handler = ((_a = anyRequest.routeOptions) === null || _a === void 0 ? void 0 : _a.handler) || ((_b = anyRequest.context) === null || _b === void 0 ? void 0 : _b.handler);
171
- const handlerName = (handler === null || handler === void 0 ? void 0 : handler.name.startsWith('bound '))
169
+ const handler = anyRequest.routeOptions?.handler || anyRequest.context?.handler;
170
+ const handlerName = handler?.name.startsWith('bound ')
172
171
  ? handler.name.substring(6)
173
- : handler === null || handler === void 0 ? void 0 : handler.name;
172
+ : handler?.name;
174
173
  const spanName = `${AttributeNames_1.FastifyNames.REQUEST_HANDLER} - ${handlerName || this.pluginName || exports.ANONYMOUS_NAME}`;
175
174
  const spanAttributes = {
176
175
  [AttributeNames_1.AttributeNames.PLUGIN_NAME]: this.pluginName,
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAAgF;AAChF,8CAA8D;AAC9D,oEAIwC;AACxC,8EAA0E;AAQ1E,2CAA+C;AAC/C,2DAIgC;AAGhC,mCAIiB;AACjB,kBAAkB;AAClB,uCAA0D;AAE7C,QAAA,cAAc,GAAG,WAAW,CAAC;AAE1C;;;;GAIG;AACH,MAAa,sBAAuB,SAAQ,qCAAiD;IAC3F,YAAY,SAAuC,EAAE;QACnD,KAAK,CAAC,sBAAY,EAAE,yBAAe,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI;QACF,OAAO;YACL,IAAI,qDAAmC,CACrC,SAAS,EACT,CAAC,YAAY,CAAC,EACd,aAAa,CAAC,EAAE;gBACd,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;YAC/C,CAAC,CACF;SACF,CAAC;IACJ,CAAC;IAEO,cAAc;QACpB,MAAM,eAAe,GAAG,IAAI,CAAC;QAC7B,OAAO,SAAS,SAAS,CACvB,OAAuB,EACvB,KAAmB,EACnB,IAA6B;YAE7B,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,EAAE;gBAChC,OAAO,IAAI,EAAE,CAAC;aACf;YACD,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;YAEnE,MAAM,UAAU,GAAG,OAAc,CAAC;YAElC,MAAM,WAAW,GAAG,IAAA,qBAAc,EAAC,aAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YACrD,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY;gBACvC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,uBAAuB;gBACrD,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;YACvB,IAAI,S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sourcesContent":["/*\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 { context, Attributes, 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 {\n HookHandlerDoneFunction,\n FastifyInstance,\n FastifyRequest,\n FastifyReply,\n FastifyErrorCodes,\n} from 'fastify';\nimport { hooksNamesToWrap } from './constants';\nimport {\n AttributeNames,\n FastifyNames,\n FastifyTypes,\n} from './enums/AttributeNames';\nimport type { HandlerOriginal, PluginFastifyReply } from './internal-types';\nimport type { FastifyInstrumentationConfig } from './types';\nimport {\n endSpan,\n safeExecuteInTheMiddleMaybePromise,\n startSpan,\n} from './utils';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\n\nexport const ANONYMOUS_NAME = 'anonymous';\n\n/**\n * Fastify instrumentation for OpenTelemetry\n * @deprecated This instrumentation is deprecated in favor of the official instrumentation package `@fastify/otel`,\n * which is maintained by the fastify authors.\n */\nexport class FastifyInstrumentation extends InstrumentationBase<FastifyInstrumentationConfig> {\n constructor(config: FastifyInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'fastify',\n ['>=3.0.0 <6'],\n moduleExports => {\n return this._patchConstructor(moduleExports);\n }\n ),\n ];\n }\n\n private _hookOnRequest() {\n const instrumentation = this;\n return function onRequest(\n request: FastifyRequest,\n reply: FastifyReply,\n done: HookHandlerDoneFunction\n ) {\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 done();\n };\n }\n\n private _wrapHandler(\n pluginName: string,\n hookName: string,\n original: (...args: unknown[]) => Promise<unknown>,\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 =\n syncFunctionWithDone &&\n (args[args.length - 1] as HookHandlerDoneFunction);\n if (origDone) {\n args[args.length - 1] = function (\n ...doneArgs: Parameters<HookHandlerDoneFunction>\n ) {\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(): (\n original: FastifyInstance['addHook']\n ) => () => FastifyInstance {\n const instrumentation = this;\n this._diag.debug('Patching fastify server.addHook function');\n\n return function (\n original: FastifyInstance['addHook']\n ): () => 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' &&\n handler.constructor.name !== 'AsyncFunction';\n\n return original.apply(this, [\n name,\n instrumentation._wrapHandler(\n pluginName,\n name,\n handler,\n syncFunctionWithDone\n ),\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 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(\n original: () => FastifyReply\n ): () => 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 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(\n this: any,\n request: FastifyRequest,\n reply: FastifyReply,\n done: HookHandlerDoneFunction\n ) {\n if (!instrumentation.isEnabled()) {\n return done();\n }\n const anyRequest = request as any;\n\n const handler =\n anyRequest.routeOptions?.handler || anyRequest.context?.handler;\n\n const handlerName = handler?.name.startsWith('bound ')\n ? handler.name.substring(6)\n : handler?.name;\n const spanName = `${FastifyNames.REQUEST_HANDLER} - ${\n handlerName || this.pluginName || ANONYMOUS_NAME\n }`;\n\n const spanAttributes: Attributes = {\n [AttributeNames.PLUGIN_NAME]: this.pluginName,\n [AttributeNames.FASTIFY_TYPE]: FastifyTypes.REQUEST_HANDLER,\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(\n reply,\n instrumentation.tracer,\n spanName,\n spanAttributes\n );\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"]}
1
+ {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAAgF;AAChF,8CAA8D;AAC9D,oEAIwC;AACxC,8EAA0E;AAQ1E,2CAA+C;AAC/C,2DAIgC;AAGhC,mCAIiB;AACjB,kBAAkB;AAClB,uCAA0D;AAE7C,QAAA,cAAc,GAAG,WAAW,CAAC;AAE1C;;;;GAIG;AACH,MAAa,sBAAuB,SAAQ,qCAAiD;IAC3F,YAAY,SAAuC,EAAE;QACnD,KAAK,CAAC,sBAAY,EAAE,yBAAe,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI;QACF,OAAO;Y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L,eAAe,CAAC,MAAM,EACtB,QAAQ,EACR,cAAc,CACf,CAAC;YAEF,MAAM,EAAE,WAAW,EAAE,GAAG,eAAe,CAAC,SAAS,EAAE,CAAC;YACpD,IAAI,WAAW,EAAE;gBACf,IAAA,wCAAsB,EACpB,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EACpC,CAAC,CAAC,EAAE;oBACF,IAAI,CAAC,EAAE;wBACL,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAC;qBACvD;gBACH,CAAC,EACD,IAAI,CACL,CAAC;aACH;YAED,OAAO,aAAO,CAAC,IAAI,CAAC,WAAK,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE;gBAC9D,IAAI,EAAE,CAAC;YACT,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;CACF;AAzPD,wDAyPC","sourcesContent":["/*\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 { context, Attributes, 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 {\n HookHandlerDoneFunction,\n FastifyInstance,\n FastifyRequest,\n FastifyReply,\n FastifyErrorCodes,\n} from 'fastify';\nimport { hooksNamesToWrap } from './constants';\nimport {\n AttributeNames,\n FastifyNames,\n FastifyTypes,\n} from './enums/AttributeNames';\nimport type { HandlerOriginal, PluginFastifyReply } from './internal-types';\nimport type { FastifyInstrumentationConfig } from './types';\nimport {\n endSpan,\n safeExecuteInTheMiddleMaybePromise,\n startSpan,\n} from './utils';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\n\nexport const ANONYMOUS_NAME = 'anonymous';\n\n/**\n * Fastify instrumentation for OpenTelemetry\n * @deprecated This instrumentation is deprecated in favor of the official instrumentation package `@fastify/otel`,\n * which is maintained by the fastify authors.\n */\nexport class FastifyInstrumentation extends InstrumentationBase<FastifyInstrumentationConfig> {\n constructor(config: FastifyInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'fastify',\n ['>=3.0.0 <6'],\n moduleExports => {\n return this._patchConstructor(moduleExports);\n }\n ),\n ];\n }\n\n private _hookOnRequest() {\n const instrumentation = this;\n return function onRequest(\n request: FastifyRequest,\n reply: FastifyReply,\n done: HookHandlerDoneFunction\n ) {\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 done();\n };\n }\n\n private _wrapHandler(\n pluginName: string,\n hookName: string,\n original: (...args: unknown[]) => Promise<unknown>,\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 =\n syncFunctionWithDone &&\n (args[args.length - 1] as HookHandlerDoneFunction);\n if (origDone) {\n args[args.length - 1] = function (\n ...doneArgs: Parameters<HookHandlerDoneFunction>\n ) {\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(): (\n original: FastifyInstance['addHook']\n ) => () => FastifyInstance {\n const instrumentation = this;\n this._diag.debug('Patching fastify server.addHook function');\n\n return function (\n original: FastifyInstance['addHook']\n ): () => 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' &&\n handler.constructor.name !== 'AsyncFunction';\n\n return original.apply(this, [\n name,\n instrumentation._wrapHandler(\n pluginName,\n name,\n handler,\n syncFunctionWithDone\n ),\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 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(\n original: () => FastifyReply\n ): () => 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 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(\n this: any,\n request: FastifyRequest,\n reply: FastifyReply,\n done: HookHandlerDoneFunction\n ) {\n if (!instrumentation.isEnabled()) {\n return done();\n }\n const anyRequest = request as any;\n\n const handler =\n anyRequest.routeOptions?.handler || anyRequest.context?.handler;\n\n const handlerName = handler?.name.startsWith('bound ')\n ? handler.name.substring(6)\n : handler?.name;\n const spanName = `${FastifyNames.REQUEST_HANDLER} - ${\n handlerName || this.pluginName || ANONYMOUS_NAME\n }`;\n\n const spanAttributes: Attributes = {\n [AttributeNames.PLUGIN_NAME]: this.pluginName,\n [AttributeNames.FASTIFY_TYPE]: FastifyTypes.REQUEST_HANDLER,\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(\n reply,\n instrumentation.tracer,\n spanName,\n spanAttributes\n );\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"]}
@@ -1,8 +1,8 @@
1
1
  import { Span } from '@opentelemetry/api';
2
2
  import type { FastifyReply } from 'fastify';
3
3
  import { spanRequestSymbol } from './constants';
4
- export declare type HandlerOriginal = (() => Promise<unknown>) & (() => void);
5
- export declare type PluginFastifyReply = FastifyReply & {
4
+ export type HandlerOriginal = (() => Promise<unknown>) & (() => void);
5
+ export type PluginFastifyReply = FastifyReply & {
6
6
  [spanRequestSymbol]?: Span[];
7
7
  };
8
8
  //# sourceMappingURL=internal-types.d.ts.map
@@ -88,10 +88,9 @@ function safeExecuteInTheMiddleMaybePromise(execute, onFinish, preventThrowingEr
88
88
  }
89
89
  exports.safeExecuteInTheMiddleMaybePromise = safeExecuteInTheMiddleMaybePromise;
90
90
  function isPromise(val) {
91
- var _a;
92
91
  return ((typeof val === 'object' &&
93
92
  val &&
94
- typeof ((_a = Object.getOwnPropertyDescriptor(val, 'then')) === null || _a === void 0 ? void 0 : _a.value) ===
93
+ typeof Object.getOwnPropertyDescriptor(val, 'then')?.value ===
95
94
  'function') ||
96
95
  false);
97
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA8E;AAC9E,2CAAgD;AAIhD;;;;;;GAMG;AACH,SAAgB,SAAS,CACvB,KAAyB,EACzB,MAAc,EACd,QAAgB,EAChB,iBAA6B,EAAE;IAE/B,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC;IAExE,MAAM,KAAK,GAAW,KAAK,CAAC,6BAAiB,CAAC,IAAI,EAAE,C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IAAC,OAAO,CAAC,EAAE;QACV,KAAK,GAAG,CAAC,CAAC;KACX;YAAS;QACR,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;YACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACxB,IAAI,KAAK,IAAI,CAAC,oBAAoB,EAAE;gBAClC,6CAA6C;gBAC7C,MAAM,KAAK,CAAC;aACb;SACF;QACD,6CAA6C;QAC7C,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AA7BD,gFA6BC;AAED,SAAS,SAAS,CAAI,GAAmB;;IACvC,OAAO,CACL,CAAC,OAAO,GAAG,KAAK,QAAQ;QACtB,GAAG;QACH,OAAO,CAAA,MAAA,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,MAAM,CAAC,0CAAE,KAAK,CAAA;YACxD,UAAU,CAAC;QACf,KAAK,CACN,CAAC;AACJ,CAAC","sourcesContent":["/*\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 { Attributes, Span, SpanStatusCode, Tracer } from '@opentelemetry/api';\nimport { spanRequestSymbol } from './constants';\n\nimport type { PluginFastifyReply } from './internal-types';\n\n/**\n * Starts Span\n * @param reply - reply function\n * @param tracer - tracer\n * @param spanName - span name\n * @param spanAttributes - span attributes\n */\nexport function startSpan(\n reply: PluginFastifyReply,\n tracer: Tracer,\n spanName: string,\n spanAttributes: Attributes = {}\n) {\n const span = tracer.startSpan(spanName, { attributes: spanAttributes });\n\n const spans: Span[] = reply[spanRequestSymbol] || [];\n spans.push(span);\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Object.defineProperty(reply, spanRequestSymbol, {\n enumerable: false,\n configurable: true,\n value: spans,\n });\n\n return span;\n}\n\n/**\n * Ends span\n * @param reply - reply function\n * @param err - error\n */\nexport function endSpan(reply: PluginFastifyReply, err?: any) {\n const spans = reply[spanRequestSymbol] || [];\n // there is no active span, or it has already ended\n if (!spans.length) {\n return;\n }\n spans.forEach(span => {\n if (err) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n span.recordException(err);\n }\n span.end();\n });\n delete reply[spanRequestSymbol];\n}\n\n// @TODO after approve add this to instrumentation package and replace usage\n// when it will be released\n\n/**\n * This function handles the missing case from instrumentation package when\n * execute can either return a promise or void. And using async is not an\n * option as it is producing unwanted side effects.\n * @param execute - function to be executed\n * @param onFinish - function called when function executed\n * @param preventThrowingError - prevent to throw error when execute\n * function fails\n */\nexport function safeExecuteInTheMiddleMaybePromise<T>(\n execute: () => Promise<T>,\n onFinish: (e: unknown, result?: T) => void,\n preventThrowingError?: boolean\n): Promise<T>;\nexport function safeExecuteInTheMiddleMaybePromise<T>(\n execute: () => T,\n onFinish: (e: unknown, result?: T) => void,\n preventThrowingError?: boolean\n): T;\nexport function safeExecuteInTheMiddleMaybePromise<T>(\n execute: () => T | Promise<T>,\n onFinish: (e: unknown, result?: T) => void,\n preventThrowingError?: boolean\n): T | Promise<T> | undefined {\n let error: unknown;\n let result: T | Promise<T> | undefined = undefined;\n try {\n result = execute();\n\n if (isPromise(result)) {\n result.then(\n res => onFinish(undefined, res),\n err => onFinish(err)\n );\n }\n } catch (e) {\n error = e;\n } finally {\n if (!isPromise(result)) {\n onFinish(error, result);\n if (error && !preventThrowingError) {\n // eslint-disable-next-line no-unsafe-finally\n throw error;\n }\n }\n // eslint-disable-next-line no-unsafe-finally\n return result;\n }\n}\n\nfunction isPromise<T>(val: T | Promise<T>): val is Promise<T> {\n return (\n (typeof val === 'object' &&\n val &&\n typeof Object.getOwnPropertyDescriptor(val, 'then')?.value ===\n 'function') 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AAC;AAjBD,0BAiBC;AAwBD,SAAgB,kCAAkC,CAChD,OAA6B,EAC7B,QAA0C,EAC1C,oBAA8B;IAE9B,IAAI,KAAc,CAAC;IACnB,IAAI,MAAM,GAA+B,SAAS,CAAC;IACnD,IAAI;QACF,MAAM,GAAG,OAAO,EAAE,CAAC;QAEnB,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE;YACrB,MAAM,CAAC,IAAI,CACT,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,EAC/B,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CACrB,CAAC;SACH;KACF;IAAC,OAAO,CAAC,EAAE;QACV,KAAK,GAAG,CAAC,CAAC;KACX;YAAS;QACR,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;YACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACxB,IAAI,KAAK,IAAI,CAAC,oBAAoB,EAAE;gBAClC,6CAA6C;gBAC7C,MAAM,KAAK,CAAC;aACb;SACF;QACD,6CAA6C;QAC7C,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AA7BD,gFA6BC;AAED,SAAS,SAAS,CAAI,GAAmB;IACvC,OAAO,CACL,CAAC,OAAO,GAAG,KAAK,QAAQ;QACtB,GAAG;QACH,OAAO,MAAM,CAAC,wBAAwB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,KAAK;YACxD,UAAU,CAAC;QACf,KAAK,CACN,CAAC;AACJ,CAAC","sourcesContent":["/*\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 { Attributes, Span, SpanStatusCode, Tracer } from '@opentelemetry/api';\nimport { spanRequestSymbol } from './constants';\n\nimport type { PluginFastifyReply } from './internal-types';\n\n/**\n * Starts Span\n * @param reply - reply function\n * @param tracer - tracer\n * @param spanName - span name\n * @param spanAttributes - span attributes\n */\nexport function startSpan(\n reply: PluginFastifyReply,\n tracer: Tracer,\n spanName: string,\n spanAttributes: Attributes = {}\n) {\n const span = tracer.startSpan(spanName, { attributes: spanAttributes });\n\n const spans: Span[] = reply[spanRequestSymbol] || [];\n spans.push(span);\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Object.defineProperty(reply, spanRequestSymbol, {\n enumerable: false,\n configurable: true,\n value: spans,\n });\n\n return span;\n}\n\n/**\n * Ends span\n * @param reply - reply function\n * @param err - error\n */\nexport function endSpan(reply: PluginFastifyReply, err?: any) {\n const spans = reply[spanRequestSymbol] || [];\n // there is no active span, or it has already ended\n if (!spans.length) {\n return;\n }\n spans.forEach(span => {\n if (err) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n span.recordException(err);\n }\n span.end();\n });\n delete reply[spanRequestSymbol];\n}\n\n// @TODO after approve add this to instrumentation package and replace usage\n// when it will be released\n\n/**\n * This function handles the missing case from instrumentation package when\n * execute can either return a promise or void. And using async is not an\n * option as it is producing unwanted side effects.\n * @param execute - function to be executed\n * @param onFinish - function called when function executed\n * @param preventThrowingError - prevent to throw error when execute\n * function fails\n */\nexport function safeExecuteInTheMiddleMaybePromise<T>(\n execute: () => Promise<T>,\n onFinish: (e: unknown, result?: T) => void,\n preventThrowingError?: boolean\n): Promise<T>;\nexport function safeExecuteInTheMiddleMaybePromise<T>(\n execute: () => T,\n onFinish: (e: unknown, result?: T) => void,\n preventThrowingError?: boolean\n): T;\nexport function safeExecuteInTheMiddleMaybePromise<T>(\n execute: () => T | Promise<T>,\n onFinish: (e: unknown, result?: T) => void,\n preventThrowingError?: boolean\n): T | Promise<T> | undefined {\n let error: unknown;\n let result: T | Promise<T> | undefined = undefined;\n try {\n result = execute();\n\n if (isPromise(result)) {\n result.then(\n res => onFinish(undefined, res),\n err => onFinish(err)\n );\n }\n } catch (e) {\n error = e;\n } finally {\n if (!isPromise(result)) {\n onFinish(error, result);\n if (error && !preventThrowingError) {\n // eslint-disable-next-line no-unsafe-finally\n throw error;\n }\n }\n // eslint-disable-next-line no-unsafe-finally\n return result;\n }\n}\n\nfunction isPromise<T>(val: T | Promise<T>): val is Promise<T> {\n return (\n (typeof val === 'object' &&\n val &&\n typeof Object.getOwnPropertyDescriptor(val, 'then')?.value ===\n 'function') ||\n false\n );\n}\n"]}
@@ -1,3 +1,3 @@
1
- export declare const PACKAGE_VERSION = "0.44.2";
1
+ export declare const PACKAGE_VERSION = "0.45.0";
2
2
  export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-fastify";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -17,6 +17,6 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.PACKAGE_VERSION = '0.44.2';
20
+ exports.PACKAGE_VERSION = '0.45.0';
21
21
  exports.PACKAGE_NAME = '@opentelemetry/instrumentation-fastify';
22
22
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,wCAAwC,CAAC","sourcesContent":["/*\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\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.44.2';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-fastify';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,wCAAwC,CAAC","sourcesContent":["/*\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\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.45.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-fastify';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-fastify",
3
- "version": "0.44.2",
3
+ "version": "0.45.0",
4
4
  "description": "OpenTelemetry instrumentation for `fastify` http web application framework",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "author": "OpenTelemetry Authors",
30
30
  "license": "Apache-2.0",
31
31
  "engines": {
32
- "node": ">=14"
32
+ "node": "^18.19.0 || >=20.6.0"
33
33
  },
34
34
  "files": [
35
35
  "build/src/**/*.js",
@@ -45,13 +45,13 @@
45
45
  "devDependencies": {
46
46
  "@fastify/express": "^3.0.0",
47
47
  "@opentelemetry/api": "^1.3.0",
48
- "@opentelemetry/context-async-hooks": "^1.8.0",
49
- "@opentelemetry/contrib-test-utils": "^0.45.1",
50
- "@opentelemetry/instrumentation-http": "^0.57.1",
51
- "@opentelemetry/sdk-trace-base": "^1.8.0",
52
- "@opentelemetry/sdk-trace-node": "^1.8.0",
48
+ "@opentelemetry/context-async-hooks": "^2.0.0",
49
+ "@opentelemetry/contrib-test-utils": "^0.46.0",
50
+ "@opentelemetry/instrumentation-http": "^0.200.0",
51
+ "@opentelemetry/sdk-trace-base": "^2.0.0",
52
+ "@opentelemetry/sdk-trace-node": "^2.0.0",
53
53
  "@types/express": "4.17.21",
54
- "@types/mocha": "7.0.2",
54
+ "@types/mocha": "10.0.10",
55
55
  "@types/node": "18.15.3",
56
56
  "@types/semver": "7.5.8",
57
57
  "fastify": "4.18.0",
@@ -59,13 +59,13 @@
59
59
  "rimraf": "5.0.10",
60
60
  "semver": "^7.5.4",
61
61
  "test-all-versions": "6.1.0",
62
- "typescript": "4.4.4"
62
+ "typescript": "5.0.4"
63
63
  },
64
64
  "dependencies": {
65
- "@opentelemetry/core": "^1.8.0",
66
- "@opentelemetry/instrumentation": "^0.57.1",
65
+ "@opentelemetry/core": "^2.0.0",
66
+ "@opentelemetry/instrumentation": "^0.200.0",
67
67
  "@opentelemetry/semantic-conventions": "^1.27.0"
68
68
  },
69
69
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-fastify#readme",
70
- "gitHead": "1eb77007669bae87fe5664d68ba6533b95275d52"
70
+ "gitHead": "32abc4c3c01d0e78e10022c74b6805b06e0e1fe7"
71
71
  }