From d5a67bc575940c834b716395b7c6a4b805e9a470 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Wed, 27 Sep 2023 14:46:22 -0700 Subject: [PATCH] typing --- .../src/OpenTelemetryBunyanStream.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/src/OpenTelemetryBunyanStream.ts b/plugins/node/opentelemetry-instrumentation-bunyan/src/OpenTelemetryBunyanStream.ts index 7597dde0b1..180664213f 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/src/OpenTelemetryBunyanStream.ts +++ b/plugins/node/opentelemetry-instrumentation-bunyan/src/OpenTelemetryBunyanStream.ts @@ -42,7 +42,7 @@ Object.keys(levelFromName).forEach(function (name) { nameFromLevel[levelFromName[name as BunyanLogger.LogLevelString]] = name; }); -const OTEL_SEV_NUM_FROM_BUNYAN_LEVEL = { +const OTEL_SEV_NUM_FROM_BUNYAN_LEVEL: { [level: number]: number } = { [TRACE]: SeverityNumber.TRACE, [DEBUG]: SeverityNumber.DEBUG, [INFO]: SeverityNumber.INFO, @@ -68,8 +68,7 @@ export class OpenTelemetryBunyanStream { // metrics where the `getTracer()` and `getMeter()` calls are more // exposed to the app developer. // For starters, let's expose it here, but *not* on BunyanInstrumentation. - // XXX Is this call signature a pain if one just wants to set `includeTraceContext: false`? - // Requirement: can pass in falsey values for name/version to get the defaults. + // XXX TODO test can pass in falsey values for name/version to get the defaults. constructor( name: string = DEFAULT_INSTRUMENTATION_SCOPE_NAME, version: string = DEFAULT_INSTRUMENTATION_SCOPE_VERSION, @@ -78,6 +77,7 @@ export class OpenTelemetryBunyanStream { this._otelLogger = logs.getLogger(name, version, options); } + // XXX lint warning about 'any' here. What else would I use? write(rec: any) { // Convert from https://github.com/trentm/node-bunyan#log-record-fields // to https://opentelemetry.io/docs/specs/otel/logs/data-model/ @@ -91,6 +91,7 @@ export class OpenTelemetryBunyanStream { // pid -> process.pid // However, AFAIK there isn't a way to influence the LoggerProvider's // `resource` from here. + // XXX lint warning about unused v. Is policy/best-practice to add a eslint-ignore-lint directive? const { time, level, msg, v, ...fields } = rec; let timestamp = undefined; if (typeof time.getTime === 'function') {