Skip to content

Commit

Permalink
fix(fastify): Make sure consturctor patching works with esm (#1624)
Browse files Browse the repository at this point in the history
* fix(fastify): Make sure consturctor patching works with esm

* ref: Streamline fastify wrapping

Align this with how other instrumentations wrap.

* Revert "ref: Streamline fastify wrapping"

This reverts commit cbffbc7.

* fix linting

---------

Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
Co-authored-by: Amir Blum <amirgiraffe@gmail.com>
  • Loading branch information
3 people authored Aug 29, 2023
1 parent d9cd8d7 commit 67f66d2
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ export class FastifyInstrumentation extends InstrumentationBase {
};
}

private _patchConstructor(
original: () => FastifyInstance
): () => FastifyInstance {
private _patchConstructor(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());

Expand Down

0 comments on commit 67f66d2

Please sign in to comment.