shridhar g kanagond
06/06/2023, 4:42 AMconst { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api')
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { ConsoleSpanExporter, InMemorySpanExporter, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { WinstonInstrumentation } = require('@opentelemetry/instrumentation-winston');
const memoryExporter = new InMemorySpanExporter();
const provider = new NodeTracerProvider();
provider.register();
const tracer = provider.getTracer('default');
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
registerInstrumentations({
instrumentations: [
new WinstonInstrumentation({
enabled: true,
logHook: (_span, record) => {
record['resource.service.name'] = 'testLogs';
},
}),
],
});
const winston = require('winston');
const logger = winston.createLogger({
transports: [
new winston.transports.Console(),
new winston.transports.Http({
host: 'localhost',
port: 3301,
path: '/api/v1/logs',
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
})
],
})
function main() {
tracer.startActiveSpan('main', (span) => {
<http://logger.info|logger.info>("Started the span, printing context");
<http://logger.info|logger.info>(span.spanContext());
<http://logger.info|logger.info>("In main main spanning");
require('./app.js')
});
<http://logger.info|logger.info>("Ended span in main");
}
main();
but not able to see the logs , is there anything i'm missing. if anyone can help me will be great. looking forward for the support from team.
running signoz with ./install.sh on localhost port 3301 and node application running on localhost port 5555Srikanth Chekuri
06/06/2023, 7:46 AM``` host: 'localhost',
port: 3301,
path: '/api/v1/logs',```This is not the correct host:port/path address. The correct one is
localhost:4318/v1/logs
. Even if that is fixed, it won’t probably work because the data has to be serialised using the OTLP protocol. I think one way you can do this is to write to file and use the filereceiver to collector logs.