Skip to content

Commit 25e5dde

Browse files
authored
fix: 2389- replaced logger unformatted strings with template literals (#2499)
1 parent b66c650 commit 25e5dde

File tree

8 files changed

+13
-19
lines changed

8 files changed

+13
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ All notable changes to this project will be documented in this file.
2020

2121
### :bug: (Bug Fix)
2222

23+
* `opentelemetry-instrumentation-grpc`, `opentelemetry-instrumentation-http`, `opentelemetry-instrumentation-jaeger`, `opentelemetry-exporter-zipkin`, `opentelemetry-sdk-trace-base`
24+
* [#2499](https://github.com/open-telemetry/opentelemetry-js/pull/2499) fix: 2389- replaced logger unformatted strings with template literals ([@PaurushGarg](https://github.com/PaurushGarg))
2325
* `opentelemetry-instrumentation-fetch`
2426
* [#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))
2527
* `opentelemetry-sdk-trace-base`

experimental/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase {
185185
kind: SpanKind.SERVER,
186186
};
187187

188-
instrumentation._diag.debug('patch func: %s', JSON.stringify(spanOptions));
188+
instrumentation._diag.debug(`patch func: ${JSON.stringify(spanOptions)}`);
189189

190190
context.with(
191191
propagation.extract(ROOT_CONTEXT, call.metadata, {

experimental/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase<
190190
kind: SpanKind.SERVER,
191191
};
192192

193-
instrumentation._diag.debug('patch func: %s', JSON.stringify(spanOptions));
193+
instrumentation._diag.debug(`patch func: ${JSON.stringify(spanOptions)}`);
194194

195195
context.with(
196196
propagation.extract(context.active(), call.metadata, {

experimental/packages/opentelemetry-instrumentation-http/src/http.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
377377
: '/';
378378
const method = request.method || 'GET';
379379

380-
instrumentation._diag.debug('%s instrumentation incomingRequest', component);
380+
instrumentation._diag.debug(`${component} instrumentation incomingRequest`);
381381

382382
if (
383383
utils.isIgnored(
@@ -591,7 +591,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
591591
}
592592
);
593593

594-
instrumentation._diag.debug('%s instrumentation outgoingRequest', component);
594+
instrumentation._diag.debug(`${component} instrumentation outgoingRequest`);
595595
context.bind(parentContext, request);
596596
return instrumentation._traceClientRequest(
597597
request,

packages/opentelemetry-exporter-jaeger/src/jaeger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class JaegerExporter implements SpanExporter {
124124
if (done) return done({ code: ExportResultCode.FAILED, error });
125125
}
126126
}
127-
diag.debug('successful append for : %s', thriftSpan.length);
127+
diag.debug(`successful append for : ${thriftSpan.length}`);
128128

129129
// Flush all spans on each export. No-op if span buffer is empty
130130
await this._flush();
@@ -177,7 +177,7 @@ export class JaegerExporter implements SpanExporter {
177177
if (err) {
178178
return reject(new Error(err));
179179
}
180-
diag.debug('successful flush for %s spans', _count);
180+
diag.debug(`successful flush for ${_count} spans`);
181181
resolve();
182182
});
183183
});

packages/opentelemetry-exporter-zipkin/src/platform/browser/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function sendWithXhr(
103103
xhr.onreadystatechange = () => {
104104
if (xhr.readyState === XMLHttpRequest.DONE) {
105105
const statusCode = xhr.status || 0;
106-
diag.debug('Zipkin response status code: %d, body: %s', statusCode, data);
106+
diag.debug(`Zipkin response status code: ${statusCode}, body: ${data}`);
107107

108108
if (xhr.status >= 200 && xhr.status < 400) {
109109
return done({ code: ExportResultCode.SUCCESS });
@@ -124,6 +124,6 @@ function sendWithXhr(
124124
};
125125

126126
// Issue request to remote service
127-
diag.debug('Zipkin request payload: %s', data);
127+
diag.debug(`Zipkin request payload: ${data}`);
128128
xhr.send(data);
129129
}

packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,7 @@ export function prepareSend(urlStr: string, headers?: Record<string, string>): z
6161
});
6262
res.on('end', () => {
6363
const statusCode = res.statusCode || 0;
64-
diag.debug(
65-
'Zipkin response status code: %d, body: %s',
66-
statusCode,
67-
rawData
68-
);
64+
diag.debug(`Zipkin response status code: ${statusCode}, body: ${rawData}`);
6965

7066
// Consider 2xx and 3xx as success.
7167
if (statusCode < 400) {
@@ -91,7 +87,7 @@ export function prepareSend(urlStr: string, headers?: Record<string, string>): z
9187

9288
// Issue request to remote service
9389
const payload = JSON.stringify(zipkinSpans);
94-
diag.debug('Zipkin request payload: %s', payload);
90+
diag.debug(`Zipkin request payload: ${payload}`);
9591
req.write(payload, 'utf8');
9692
req.end();
9793
};

packages/opentelemetry-sdk-trace-base/src/Span.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,7 @@ export class Span implements api.Span, ReadableSpan {
229229

230230
private _isSpanEnded(): boolean {
231231
if (this._ended) {
232-
api.diag.warn(
233-
'Can not execute the operation on ended Span {traceId: %s, spanId: %s}',
234-
this._spanContext.traceId,
235-
this._spanContext.spanId
236-
);
232+
api.diag.warn(`Can not execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);
237233
}
238234
return this._ended;
239235
}

0 commit comments

Comments
 (0)