Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm committed Oct 3, 2023
1 parent d392f10 commit d5a67bc
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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/
Expand All @@ -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') {
Expand Down

0 comments on commit d5a67bc

Please sign in to comment.