Skip to content

Commit

Permalink
fix: replaced logger unformatted strings with template literals
Browse files Browse the repository at this point in the history
  • Loading branch information
Garg committed Sep 22, 2021
1 parent bebd82a commit efec01a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 19 deletions.
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 @@ -370,7 +370,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 @@ -580,7 +580,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

0 comments on commit efec01a

Please sign in to comment.