Skip to content

Commit b40e85a

Browse files
committed
bugfix(node): Change Hono instrumentation to wrap via class extension instead of function replacement
1 parent 0ddfe17 commit b40e85a

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

packages/node/src/integrations/tracing/hono/instrumentation.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,21 @@ export class HonoInstrumentation extends InstrumentationBase {
3232
// eslint-disable-next-line @typescript-eslint/no-this-alias
3333
const instrumentation = this;
3434

35-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
36-
function Hono(this: HonoInstance, ...args: any): HonoInstance {
37-
const app: HonoInstance = moduleExports.Hono.apply(this, args);
35+
moduleExports.Hono = class HonoWrapper extends moduleExports.Hono {
36+
public constructor() {
37+
super();
3838

39-
instrumentation._wrap(app, 'get', instrumentation._patchHandler());
40-
instrumentation._wrap(app, 'post', instrumentation._patchHandler());
41-
instrumentation._wrap(app, 'put', instrumentation._patchHandler());
42-
instrumentation._wrap(app, 'delete', instrumentation._patchHandler());
43-
instrumentation._wrap(app, 'options', instrumentation._patchHandler());
44-
instrumentation._wrap(app, 'patch', instrumentation._patchHandler());
45-
instrumentation._wrap(app, 'all', instrumentation._patchHandler());
46-
instrumentation._wrap(app, 'on', instrumentation._patchOnHandler());
47-
instrumentation._wrap(app, 'use', instrumentation._patchMiddlewareHandler());
48-
49-
return app;
50-
}
51-
52-
moduleExports.Hono = Hono;
39+
instrumentation._wrap(this, 'get', instrumentation._patchHandler());
40+
instrumentation._wrap(this, 'post', instrumentation._patchHandler());
41+
instrumentation._wrap(this, 'put', instrumentation._patchHandler());
42+
instrumentation._wrap(this, 'delete', instrumentation._patchHandler());
43+
instrumentation._wrap(this, 'options', instrumentation._patchHandler());
44+
instrumentation._wrap(this, 'patch', instrumentation._patchHandler());
45+
instrumentation._wrap(this, 'all', instrumentation._patchHandler());
46+
instrumentation._wrap(this, 'on', instrumentation._patchOnHandler());
47+
instrumentation._wrap(this, 'use', instrumentation._patchMiddlewareHandler());
48+
}
49+
};
5350
return moduleExports;
5451
}
5552

packages/node/src/integrations/tracing/hono/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ export interface HonoInstance {
4747
use: MiddlewareHandlerInterface;
4848
}
4949

50-
export type Hono = () => HonoInstance;
50+
export type Hono = new () => HonoInstance;

0 commit comments

Comments
 (0)