From d052a1bead492d2cae1900d7ddbb13a60d47e740 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 7 Aug 2023 09:24:30 +0200 Subject: [PATCH] fix(fastify): Make sure consturctor patching works with esm --- .../src/instrumentation.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts index fcaf3114e6..f2f51e6885 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -198,13 +198,13 @@ export class FastifyInstrumentation extends InstrumentationBase { } private _patchConstructor( - original: () => FastifyInstance - ): () => FastifyInstance { + moduleExports: { fastify: () => FastifyInstance }, + ): () => FastifyInstance { const instrumentation = this; this._diag.debug('Patching fastify constructor function'); function fastify(this: FastifyInstance, ...args: any) { - const app: FastifyInstance = original.apply(this, args); + const app: FastifyInstance = moduleExports.fastify.apply(this, args); app.addHook('onRequest', instrumentation._hookOnRequest()); app.addHook('preHandler', instrumentation._hookPreHandler());