diff --git a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts index 72d8b8c9b7..0ccc2c3a44 100644 --- a/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts @@ -27,6 +27,7 @@ import type { FastifyInstance, FastifyRequest, FastifyReply, + FastifyErrorCodes, } from 'fastify'; import { hooksNamesToWrap } from './constants'; import { @@ -185,6 +186,7 @@ export class FastifyInstrumentation extends InstrumentationBase FastifyInstance; + errorCodes: FastifyErrorCodes | undefined; }): () => FastifyInstance { const instrumentation = this; @@ -198,6 +200,9 @@ export class FastifyInstrumentation extends InstrumentationBase { }, }); }); + + it('should expose errorCodes', async function () { + // errorCodes was added in v4.8.0 + // ref: https://github.com/fastify/fastify/compare/v4.7.0...v4.8.0 + if (semver.lt(fastifyVersion, '4.8.0')) { + this.skip(); + } + assert.ok(Fastify.errorCodes); + assert.strictEqual(typeof Fastify.errorCodes, 'object'); + assert.ok('FST_ERR_NOT_FOUND' in Fastify.errorCodes); + }); });