Hi All, I am able to see the logs of my service bu...
# support
s
Hi All, I am able to see the logs of my service but not able to see my service in the services tab section, what should I do differently to see this
s
They are based on the traces data.
a
Subscribing for updates.
s
how can we get that?
s
Do you use OpenTelemetry to instrument your applications?
s
using winston
s
s
Copy code
registerInstrumentations({
    instrumentations: [
        new WinstonInstrumentation({
            enabled: true,
            logHook: (_span, record) => {
                record['resource.service.name'] = 'test-service';
            },
        }),
    ],
});
I am doing this, is this what's expected?
s
You are just registering one logging instrumentation. There are a bunch of others that should be registered. The above links show how to do it.
s
let me share my entire file with you
Copy code
const { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api');
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
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'] = 'test-service';
            },
        }),
    ],
});

const winston = require('winston');

global.logger = winston.createLogger({
    transports: [
        new winston.transports.Console(),
    ],
})

function main() {
    tracer.startActiveSpan('main', (span) => {
        <http://global.logger.info|global.logger.info>("Started the span, printing context");
        <http://global.logger.info|global.logger.info>(span.spanContext());
        <http://global.logger.info|global.logger.info>("In main main spanning");
        require('./server.js');
    });
    <http://global.logger.info|global.logger.info>("Ended span in main");
}

main();
we have followed the link to get this
are we missing anything?
s
we have followed the link to get this
What link have you followed?
are we missing anything?
You are only enabling the logging. Please register all the instrumentation using auto-instrumentation https://signoz.io/blog/nodejs-opensource-application-monitoring/#set-up-opentelemetry-and-send-data-to-signoz
s
Thank you! I'll have a look
@Srikanth Chekuri I did the following but no luck
Copy code
const { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api');
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
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(({
    resource: new Resource({
      [SemanticResourceAttributes.SERVICE_NAME]: 'bot-service',
    }),
  }));
const tracer = provider.getTracer('default');
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
registerInstrumentations({
    instrumentations: [getNodeAutoInstrumentations()],
});

const winston = require('winston');

global.logger = winston.createLogger({
    transports: [
        new winston.transports.Console(),
    ],
})

function main() {
    tracer.startActiveSpan('main', (span) => {
        <http://global.logger.info|global.logger.info>("Started the span, printing context");
        <http://global.logger.info|global.logger.info>(span.spanContext());
        <http://global.logger.info|global.logger.info>("In main main spanning");
        require('./server.js');
    });
    <http://global.logger.info|global.logger.info>("Ended span in main");
}

main();
I see that now I am continuously seeing the following in the logs
Copy code
{
function_bot  |   traceId: '805f6f9bd44083e258988819acc9ca40',
function_bot  |   parentId: 'e886397ea5108622',
function_bot  |   traceState: undefined,
function_bot  |   name: 'fs statSync',
function_bot  |   id: '0eb6f165db3376df',
function_bot  |   kind: 0,
function_bot  |   timestamp: 1686203300970000,
function_bot  |   duration: 25,
function_bot  |   attributes: {},
function_bot  |   status: { code: 0 },
function_bot  |   events: [],
function_bot  |   links: []
function_bot  | }
s
Because you added the console exporter. I don’t see a console exporter in the link I shared. What did you refer to make the above changes?
s
I just made the extra changes missing in the file from the above link that you shared
I picked up the task now, that file was already there
they're using winston for logging
anyway i removed ConsoleSpanExporter, it's still not working as expected @Srikanth Chekuri
s
Sorry, I don’t follow; who is they here, and what file was already there? Please make sure to setup the instrumentation correctly. Please see our docs shared above.