From 25e5ddea8a0d273f70a6ff49b1a07cb9d8e02190 Mon Sep 17 00:00:00 2001 From: Paurush Garg <62579325+PaurushGarg@users.noreply.github.com> Date: Wed, 29 Sep 2021 14:21:29 -0700 Subject: [PATCH] fix: 2389- replaced logger unformatted strings with template literals (#2499) --- CHANGELOG.md | 2 ++ .../src/grpc-js/index.ts | 2 +- .../opentelemetry-instrumentation-grpc/src/grpc/index.ts | 2 +- .../opentelemetry-instrumentation-http/src/http.ts | 4 ++-- packages/opentelemetry-exporter-jaeger/src/jaeger.ts | 4 ++-- .../src/platform/browser/util.ts | 4 ++-- .../src/platform/node/util.ts | 8 ++------ packages/opentelemetry-sdk-trace-base/src/Span.ts | 6 +----- 8 files changed, 13 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b361fd135b..cb66b2d0b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ All notable changes to this project will be documented in this file. ### :bug: (Bug Fix) +* `opentelemetry-instrumentation-grpc`, `opentelemetry-instrumentation-http`, `opentelemetry-instrumentation-jaeger`, `opentelemetry-exporter-zipkin`, `opentelemetry-sdk-trace-base` + * [#2499](https://github.com/open-telemetry/opentelemetry-js/pull/2499) fix: 2389- replaced logger unformatted strings with template literals ([@PaurushGarg](https://github.com/PaurushGarg)) * `opentelemetry-instrumentation-fetch` * [#2411](https://github.com/open-telemetry/opentelemetry-js/pull/2411) fix(instrumentation-fetch): `fetch(string, Request)` silently drops request body ([@t2t2](https://github.com/t2t2)) * `opentelemetry-sdk-trace-base` diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts index 0cf2114891..ba4f46e351 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts @@ -185,7 +185,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase { kind: SpanKind.SERVER, }; - instrumentation._diag.debug('patch func: %s', JSON.stringify(spanOptions)); + instrumentation._diag.debug(`patch func: ${JSON.stringify(spanOptions)}`); context.with( propagation.extract(ROOT_CONTEXT, call.metadata, { diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts index 87486ef157..18b649b95c 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts +++ b/experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts @@ -190,7 +190,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< kind: SpanKind.SERVER, }; - instrumentation._diag.debug('patch func: %s', JSON.stringify(spanOptions)); + instrumentation._diag.debug(`patch func: ${JSON.stringify(spanOptions)}`); context.with( propagation.extract(context.active(), call.metadata, { diff --git a/experimental/packages/opentelemetry-instrumentation-http/src/http.ts b/experimental/packages/opentelemetry-instrumentation-http/src/http.ts index b6cba079fc..6c889b4066 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/src/http.ts +++ b/experimental/packages/opentelemetry-instrumentation-http/src/http.ts @@ -377,7 +377,7 @@ export class HttpInstrumentation extends InstrumentationBase { : '/'; const method = request.method || 'GET'; - instrumentation._diag.debug('%s instrumentation incomingRequest', component); + instrumentation._diag.debug(`${component} instrumentation incomingRequest`); if ( utils.isIgnored( @@ -591,7 +591,7 @@ export class HttpInstrumentation extends InstrumentationBase { } ); - instrumentation._diag.debug('%s instrumentation outgoingRequest', component); + instrumentation._diag.debug(`${component} instrumentation outgoingRequest`); context.bind(parentContext, request); return instrumentation._traceClientRequest( request, diff --git a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts index 614871d019..319d99ce37 100644 --- a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts +++ b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts @@ -124,7 +124,7 @@ export class JaegerExporter implements SpanExporter { if (done) return done({ code: ExportResultCode.FAILED, error }); } } - diag.debug('successful append for : %s', thriftSpan.length); + diag.debug(`successful append for : ${thriftSpan.length}`); // Flush all spans on each export. No-op if span buffer is empty await this._flush(); @@ -177,7 +177,7 @@ export class JaegerExporter implements SpanExporter { if (err) { return reject(new Error(err)); } - diag.debug('successful flush for %s spans', _count); + diag.debug(`successful flush for ${_count} spans`); resolve(); }); }); diff --git a/packages/opentelemetry-exporter-zipkin/src/platform/browser/util.ts b/packages/opentelemetry-exporter-zipkin/src/platform/browser/util.ts index 2b0ef76b2e..222f138d07 100644 --- a/packages/opentelemetry-exporter-zipkin/src/platform/browser/util.ts +++ b/packages/opentelemetry-exporter-zipkin/src/platform/browser/util.ts @@ -103,7 +103,7 @@ function sendWithXhr( xhr.onreadystatechange = () => { if (xhr.readyState === XMLHttpRequest.DONE) { const statusCode = xhr.status || 0; - diag.debug('Zipkin response status code: %d, body: %s', statusCode, data); + diag.debug(`Zipkin response status code: ${statusCode}, body: ${data}`); if (xhr.status >= 200 && xhr.status < 400) { return done({ code: ExportResultCode.SUCCESS }); @@ -124,6 +124,6 @@ function sendWithXhr( }; // Issue request to remote service - diag.debug('Zipkin request payload: %s', data); + diag.debug(`Zipkin request payload: ${data}`); xhr.send(data); } diff --git a/packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts b/packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts index 1d19b8dd3d..ca0af75886 100644 --- a/packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts +++ b/packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts @@ -61,11 +61,7 @@ export function prepareSend(urlStr: string, headers?: Record): z }); res.on('end', () => { const statusCode = res.statusCode || 0; - diag.debug( - 'Zipkin response status code: %d, body: %s', - statusCode, - rawData - ); + diag.debug(`Zipkin response status code: ${statusCode}, body: ${rawData}`); // Consider 2xx and 3xx as success. if (statusCode < 400) { @@ -91,7 +87,7 @@ export function prepareSend(urlStr: string, headers?: Record): z // Issue request to remote service const payload = JSON.stringify(zipkinSpans); - diag.debug('Zipkin request payload: %s', payload); + diag.debug(`Zipkin request payload: ${payload}`); req.write(payload, 'utf8'); req.end(); }; diff --git a/packages/opentelemetry-sdk-trace-base/src/Span.ts b/packages/opentelemetry-sdk-trace-base/src/Span.ts index 429bf06e8d..c4bd66b20c 100644 --- a/packages/opentelemetry-sdk-trace-base/src/Span.ts +++ b/packages/opentelemetry-sdk-trace-base/src/Span.ts @@ -229,11 +229,7 @@ export class Span implements api.Span, ReadableSpan { private _isSpanEnded(): boolean { if (this._ended) { - api.diag.warn( - 'Can not execute the operation on ended Span {traceId: %s, spanId: %s}', - this._spanContext.traceId, - this._spanContext.spanId - ); + api.diag.warn(`Can not execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`); } return this._ended; }