@@ -5,7 +5,6 @@ https://github.com/fastify/otel/releases/tag/v0.8.0
5
5
Tried not to modify the original code too much keeping it as a JavaScript CJS module to make it easier to update when required
6
6
7
7
Modifications include:
8
- - Removed `logger` as it created problems with TypesScript
9
8
- Removed reading of package.json to get the version and package name
10
9
11
10
MIT License
@@ -36,7 +35,7 @@ SOFTWARE.
36
35
/* eslint-disable max-lines */
37
36
/* eslint-disable no-param-reassign */
38
37
import dc from 'node:diagnostics_channel' ;
39
- import { context , propagation , SpanStatusCode , trace } from '@opentelemetry/api' ;
38
+ import { context , diag , propagation , SpanStatusCode , trace } from '@opentelemetry/api' ;
40
39
import { getRPCMetadata , RPCType } from '@opentelemetry/core' ;
41
40
import { InstrumentationBase } from '@opentelemetry/instrumentation' ;
42
41
import {
@@ -89,6 +88,7 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
89
88
super ( PACKAGE_NAME , PACKAGE_VERSION , config ) ;
90
89
this . servername = config ?. servername ?? process . env . OTEL_SERVICE_NAME ?? 'fastify' ;
91
90
this [ kIgnorePaths ] = null ;
91
+ this . _logger = diag . createComponentLogger ( { namespace : PACKAGE_NAME } ) ;
92
92
93
93
if ( config ?. ignorePaths != null || process . env . OTEL_FASTIFY_IGNORE_PATHS != null ) {
94
94
const ignorePaths = config ?. ignorePaths ?? process . env . OTEL_FASTIFY_IGNORE_PATHS ;
@@ -177,9 +177,9 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
177
177
178
178
instance . addHook ( 'onRoute' , function ( routeOptions ) {
179
179
if ( instrumentation [ kIgnorePaths ] ?. ( routeOptions ) === true ) {
180
- // instrumentation.logger .debug(
181
- // `Ignoring route instrumentation ${routeOptions.method} ${routeOptions.url} because it matches the ignore path`,
182
- // );
180
+ instrumentation . _logger . debug (
181
+ `Ignoring route instrumentation ${ routeOptions . method } ${ routeOptions . url } because it matches the ignore path` ,
182
+ ) ;
183
183
return ;
184
184
}
185
185
@@ -254,9 +254,9 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
254
254
method : request . method ,
255
255
} ) === true
256
256
) {
257
- // this[kInstrumentation].logger .debug(
258
- // `Ignoring request ${request.method} ${request.url} because it matches the ignore path`,
259
- // );
257
+ this [ kInstrumentation ] . _logger . debug (
258
+ `Ignoring request ${ request . method } ${ request . url } because it matches the ignore path` ,
259
+ ) ;
260
260
return hookDone ( ) ;
261
261
}
262
262
0 commit comments