Skip to content

Commit 585555f

Browse files
committed
Use instrumentation._logger instead
1 parent 24e03a1 commit 585555f

File tree

1 file changed

+8
-8
lines changed
  • packages/node/src/integrations/tracing/fastify/fastify-otel

1 file changed

+8
-8
lines changed

packages/node/src/integrations/tracing/fastify/fastify-otel/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ https://github.com/fastify/otel/releases/tag/v0.8.0
55
Tried not to modify the original code too much keeping it as a JavaScript CJS module to make it easier to update when required
66
77
Modifications include:
8-
- Removed `logger` as it created problems with TypesScript
98
- Removed reading of package.json to get the version and package name
109
1110
MIT License
@@ -36,7 +35,7 @@ SOFTWARE.
3635
/* eslint-disable max-lines */
3736
/* eslint-disable no-param-reassign */
3837
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';
4039
import { getRPCMetadata, RPCType } from '@opentelemetry/core';
4140
import { InstrumentationBase } from '@opentelemetry/instrumentation';
4241
import {
@@ -89,6 +88,7 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
8988
super(PACKAGE_NAME, PACKAGE_VERSION, config);
9089
this.servername = config?.servername ?? process.env.OTEL_SERVICE_NAME ?? 'fastify';
9190
this[kIgnorePaths] = null;
91+
this._logger = diag.createComponentLogger({ namespace: PACKAGE_NAME });
9292

9393
if (config?.ignorePaths != null || process.env.OTEL_FASTIFY_IGNORE_PATHS != null) {
9494
const ignorePaths = config?.ignorePaths ?? process.env.OTEL_FASTIFY_IGNORE_PATHS;
@@ -177,9 +177,9 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
177177

178178
instance.addHook('onRoute', function (routeOptions) {
179179
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+
);
183183
return;
184184
}
185185

@@ -254,9 +254,9 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
254254
method: request.method,
255255
}) === true
256256
) {
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+
);
260260
return hookDone();
261261
}
262262

0 commit comments

Comments
 (0)