Skip to content

Commit

Permalink
fix: 2389- replaced logger unformatted strings with template literals (
Browse files Browse the repository at this point in the history
  • Loading branch information
PaurushGarg committed Sep 29, 2021
1 parent b66c650 commit 25e5dde
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
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
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
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
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
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
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);
}
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
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

0 comments on commit 25e5dde

Please sign in to comment.