Skip to content

Commit

Permalink
drop considering passing through a includeTraceContext option
Browse files Browse the repository at this point in the history
open-telemetry/opentelemetry-js#3817 seems
to have mostly dropped that.
  • Loading branch information
trentm committed Oct 3, 2023
1 parent d5a67bc commit 4ffc91e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import type * as BunyanLogger from 'bunyan';
const DEFAULT_CONFIG: BunyanInstrumentationConfig = {
enableLogsBridge: true,
enableInjection: true,
includeTraceContext: true,
};

export class BunyanInstrumentation extends InstrumentationBase<
Expand Down Expand Up @@ -130,11 +129,9 @@ export class BunyanInstrumentation extends InstrumentationBase<
}

const record = args[0] as Record<string, string>;
if (config.includeTraceContext) {
record['trace_id'] = spanContext.traceId;
record['span_id'] = spanContext.spanId;
record['trace_flags'] = `0${spanContext.traceFlags.toString(16)}`;
}
record['trace_id'] = spanContext.traceId;
record['span_id'] = spanContext.spanId;
record['trace_flags'] = `0${spanContext.traceFlags.toString(16)}`;

instrumentation._callHook(span, record);

Expand All @@ -147,6 +144,7 @@ export class BunyanInstrumentation extends InstrumentationBase<
return (original: (...args: unknown[]) => void) => {
const instrumentation = this;
return function patchedCreateLogger(...args: unknown[]) {
// XXX type error here on not using spread, but no complaint from same above. Wassup?
const logger = original.apply(null, args);
instrumentation._addStream(logger);
return logger;
Expand All @@ -160,7 +158,7 @@ export class BunyanInstrumentation extends InstrumentationBase<
return;
}
this._diag.debug('Adding OpenTelemetryBunyanStream to logger');
// XXX includeTraceContext pass in, and test
// XXX pass in any args to the stream?
logger.addStream({ type: 'raw', stream: new OpenTelemetryBunyanStream() });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,4 @@ export interface BunyanInstrumentationConfig extends InstrumentationConfig {
* span context. It requires both `enableInjection` to be true.
*/
logHook?: LogHookFunction;

/**
* Whether to include trace-context in (a) fields injected into log records
* (see `enableInjection`); and (b) in records from the OpenTelemetry Bunyan
* stream (see `enableLogsBridge`).
* @default true
*/
includeTraceContext?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ describe('BunyanInstrumentation', () => {
span.end();
});
});

// XXX test includeTraceContext=false
});

describe('disabled instrumentation', () => {
Expand Down

0 comments on commit 4ffc91e

Please sign in to comment.