Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 2389- replaced logger unformatted strings with template literals #2499

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
: '/';
const method = request.method || 'GET';

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

if (
utils.isIgnored(
Expand Down Expand Up @@ -591,7 +591,7 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
}
);

instrumentation._diag.debug('%s instrumentation outgoingRequest', component);
instrumentation._diag.debug(`${component} instrumentation outgoingRequest`);
context.bind(parentContext, request);
return instrumentation._traceClientRequest(
request,
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ export function prepareSend(urlStr: string, headers?: Record<string, string>): 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) {
Expand All @@ -91,7 +87,7 @@ export function prepareSend(urlStr: string, headers?: Record<string, string>): 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();
};
Expand Down
6 changes: 1 addition & 5 deletions packages/opentelemetry-sdk-trace-base/src/Span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down