@@ -36,7 +36,7 @@ SOFTWARE.
36
36
/* eslint-disable max-lines */
37
37
/* eslint-disable no-param-reassign */
38
38
import dc from 'node:diagnostics_channel' ;
39
- import { context , propagation , SpanStatusCode , trace } from '@opentelemetry/api' ;
39
+ import { context , diag , propagation , SpanStatusCode , trace } from '@opentelemetry/api' ;
40
40
import { getRPCMetadata , RPCType } from '@opentelemetry/core' ;
41
41
import { InstrumentationBase } from '@opentelemetry/instrumentation' ;
42
42
import {
@@ -89,6 +89,7 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
89
89
super ( PACKAGE_NAME , PACKAGE_VERSION , config ) ;
90
90
this . servername = config ?. servername ?? process . env . OTEL_SERVICE_NAME ?? 'fastify' ;
91
91
this [ kIgnorePaths ] = null ;
92
+ this . _logger = diag . createComponentLogger ( { namespace : PACKAGE_NAME } ) ;
92
93
93
94
if ( config ?. ignorePaths != null || process . env . OTEL_FASTIFY_IGNORE_PATHS != null ) {
94
95
const ignorePaths = config ?. ignorePaths ?? process . env . OTEL_FASTIFY_IGNORE_PATHS ;
@@ -177,9 +178,9 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
177
178
178
179
instance . addHook ( 'onRoute' , function ( routeOptions ) {
179
180
if ( instrumentation [ kIgnorePaths ] ?. ( routeOptions ) === true ) {
180
- // instrumentation.logger .debug(
181
- // `Ignoring route instrumentation ${routeOptions.method} ${routeOptions.url} because it matches the ignore path`,
182
- // );
181
+ instrumentation . _logger . debug (
182
+ `Ignoring route instrumentation ${ routeOptions . method } ${ routeOptions . url } because it matches the ignore path` ,
183
+ ) ;
183
184
return ;
184
185
}
185
186
@@ -254,9 +255,9 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
254
255
method : request . method ,
255
256
} ) === true
256
257
) {
257
- // this[kInstrumentation].logger .debug(
258
- // `Ignoring request ${request.method} ${request.url} because it matches the ignore path`,
259
- // );
258
+ this [ kInstrumentation ] . _logger . debug (
259
+ `Ignoring request ${ request . method } ${ request . url } because it matches the ignore path` ,
260
+ ) ;
260
261
return hookDone ( ) ;
261
262
}
262
263
0 commit comments