Skip to content

Commit afac5e6

Browse files
committed
Auto-register @fastify/otel plugin when instrumented.
1 parent 2cc7d07 commit afac5e6

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

packages/node/src/integrations/tracing/fastify.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const instrumentFastify = generateInstrumentOnce(INTEGRATION_NAME, () =>
119119
// FastifyOtelInstrumentation does not have a `requestHook`
120120
// so we can't use `addFastifySpanAttributes` here for now
121121
fastifyOtelInstrumentationInstance = new FastifyOtelInstrumentation({
122-
// registerOnInitialization: true,
122+
registerOnInitialization: true,
123123
});
124124
return fastifyOtelInstrumentationInstance;
125125
});
@@ -228,29 +228,6 @@ export function setupFastifyErrorHandler(fastify: Fastify, options?: Partial<Fas
228228
});
229229
}
230230

231-
// // Need to check because the @fastify/otel's plugin crashes the app in the runtime
232-
// // if the version is not supported
233-
// let fastifyVersion = fastify.version ? parseSemver(fastify.version) : undefined;
234-
235-
// if (!fastifyVersion) {
236-
// // try reading the version from the package.json
237-
// try {
238-
// // eslint-disable-next-line @typescript-eslint/no-var-requires
239-
// const pkg = require('fastify/package.json');
240-
// if (pkg?.version) {
241-
// fastifyVersion = parseSemver(pkg.version);
242-
// }
243-
// } catch {
244-
// // ignore
245-
// }
246-
// }
247-
248-
// if (fastifyOtelInstrumentationInstance?.isEnabled() && fastifyVersion?.major && fastifyVersion.major >= 4) {
249-
// // Can't use `await` here
250-
// // eslint-disable-next-line @typescript-eslint/no-floating-promises
251-
// fastify.register(fastifyOtelInstrumentationInstance?.plugin());
252-
// }
253-
254231
// eslint-disable-next-line @typescript-eslint/no-floating-promises
255232
fastify.register(plugin);
256233
}

0 commit comments

Comments
 (0)