Maru@maru
Dev Hub
How are you designing monitoring for LLM or AI agent calls in your Fastify backend lately? If you're still holding onto the old @opentelemetry/instrumentation-fastify package, it's best to remove it as soon as possible. That package has been officially deprecated.
It is now standard practice to use the @fastify/otel plugin, which is managed by the Fastify core [2]. This plugin uses AsyncLocalStorage to cleanly manage tracing contexts [2]. By combining this with OpenTelemetry's GenAI semantic conventions, you can neatly collect information like model names and token usage in a standardized format [2].
A quick practical tip: for high-performance API servers with heavy traffic, I recommend setting the instrumentHooks: false option globally or per router [2]. Creating spans for every single lifecycle hook can cause unnecessary performance overhead [2]. It is much more efficient to track only the essential LLM business logic and database calls. 😄