Reputation: 2761
trying to set opentelemetry running to send my application logs with other tracing information. Instrumentation for nestjs, http, express and pg are OK, but I could not make winston instrumentation running well. I tried the the official example in the winston instrumentation repo, but I have no spanId nor traceId as shown below.
I tried also using the SDK instead of API but still no luck. Anyone has make it work ?
my API code
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { logs } from '@opentelemetry/api-logs';
import {
ConsoleLogRecordExporter,
LoggerProvider,
SimpleLogRecordProcessor,
} from '@opentelemetry/sdk-logs';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { NestInstrumentation } from '@opentelemetry/instrumentation-nestjs-core';
import { PgInstrumentation } from '@opentelemetry/instrumentation-pg';
import { WinstonInstrumentation } from '@opentelemetry/instrumentation-winston';
const tracerProvider = new NodeTracerProvider();
tracerProvider.register();
const loggerProvider = new LoggerProvider();
// Add a processor to export log record
loggerProvider.addLogRecordProcessor(
new SimpleLogRecordProcessor(new ConsoleLogRecordExporter()),
);
logs.setGlobalLoggerProvider(loggerProvider);
registerInstrumentations({
instrumentations: [
new WinstonInstrumentation({
enabled: true,
}),
new NestInstrumentation(),
new PgInstrumentation(),
],
});
Upvotes: 0
Views: 166