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

Output 'noPluginName' in trace-api log messages where pluginName is undefined #958

Merged
merged 2 commits into from
Jan 23, 2019
Merged
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
14 changes: 8 additions & 6 deletions src/trace-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class StackdriverTracer implements Tracer {

private enabled = false;
private pluginName: string;
private pluginNameToLog: string;
private logger: Logger|null = null;
private config: StackdriverTracerConfig|null = null;
private policy: TracePolicy|null = null;
Expand All @@ -102,6 +103,7 @@ export class StackdriverTracer implements Tracer {
*/
constructor(name: string) {
this.pluginName = name;
this.pluginNameToLog = this.pluginName ? this.pluginName : 'no-plugin-name';
this.disable(); // disable immediately
}

Expand Down Expand Up @@ -167,7 +169,7 @@ export class StackdriverTracer implements Tracer {
const rootSpan = cls.get().getContext();
if (rootSpan.type === SpanType.ROOT && !rootSpan.span.endTime) {
this.logger!.warn(`TraceApi#runInRootSpan: [${
this.pluginName}] Cannot create nested root spans.`);
this.pluginNameToLog}] Cannot create nested root spans.`);
return fn(UNCORRELATED_ROOT_SPAN);
}

Expand Down Expand Up @@ -271,7 +273,7 @@ export class StackdriverTracer implements Tracer {
// seems to have some value, but isn't representable. The user probably
// needs a custom outer span that encompasses the entirety of work.
this.logger!.warn(`TraceApi#createChildSpan: [${
this.pluginName}] Creating phantom child span [${
this.pluginNameToLog}] Creating phantom child span [${
options.name}] because root span [${
rootSpan.span.name}] was already closed.`);
return UNCORRELATED_CHILD_SPAN;
Expand All @@ -281,7 +283,7 @@ export class StackdriverTracer implements Tracer {
// spans suggests a memory leak stemming from context confusion. This
// is likely due to userspace task queues or Promise implementations.
this.logger!.error(`TraceApi#createChildSpan: [${
this.pluginName}] Creating phantom child span [${
this.pluginNameToLog}] Creating phantom child span [${
options.name}] because the trace with root span [${
rootSpan.span.name}] has reached a limit of ${
this.config!
Expand All @@ -303,7 +305,7 @@ export class StackdriverTracer implements Tracer {
// checks equality -- this is OK because no automatic tracing plugin
// uses the RootSpanData API directly.
this.logger!.error(`TraceApi#createChildSpan: [${
this.pluginName}] Adding child span [${
this.pluginNameToLog}] Adding child span [${
options.name}] will cause the trace with root span [${
rootSpan.span.name}] to contain more than ${
this.config!
Expand All @@ -320,7 +322,7 @@ export class StackdriverTracer implements Tracer {
skipFrames: options.skipFrames ? options.skipFrames + 1 : 1
});
this.logger!.info(`TraceApi#createChildSpan: [${
this.pluginName}] Created child span [${options.name}]`);
this.pluginNameToLog}] Created child span [${options.name}]`);
return childContext;
} else if (rootSpan.type === SpanType.UNTRACED) {
// Context wasn't lost, but there's no root span, indicating that this
Expand All @@ -329,7 +331,7 @@ export class StackdriverTracer implements Tracer {
} else {
// Context was lost.
this.logger!.warn(`TraceApi#createChildSpan: [${
this.pluginName}] Creating phantom child span [${
this.pluginNameToLog}] Creating phantom child span [${
options.name}] because there is no root span.`);
return UNCORRELATED_CHILD_SPAN;
}
Expand Down