Nestjs - signoz no logs #5027
adelpro
started this conversation in
Externship
Replies: 1 comment
-
Hey - have you had a look at this blog - https://signoz.io/blog/opentelemetry-nextjs/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi , i tried signoz self-hosted (docker), im using nestjs, but i cant see any thing in my signoz.
// tracer.ts
'use strict';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
import { Resource } from '@opentelemetry/resources';
import { formattedLogger } from './utils/formatedLogger';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { ConfigService } from '@nestjs/config';
import { NodeSDK } from '@opentelemetry/sdk-node';
const logger = formattedLogger('Signoz');
/* const configService = new ConfigService();
const TRACE_ENABLED = configService.getOrThrow('TRACE_ENABLED');
logger.debug('TRACE_ENABLED: ' + TRACE_ENABLED);
if (!TRACE_ENABLED) {
return;
} */
// Configure the SDK to export telemetry data to SigNoz
const exporterOptions = {
url: 'http://adelpro.duckdns.org:4318/v1/traces',
};
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new NodeSDK({
traceExporter,
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-nestjs-core': { enabled: true },
}),
],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'imcoder-backend',
}),
});
sdk.start();
// Gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk
.shutdown()
.then(() => logger.log('Tracing terminated'))
.catch((error) => logger.error('Error terminating tracing: ' + error))
.finally(() => process.exit(0));
});
process.on('SIGINT', () => {
sdk
.shutdown()
.then(() => logger.log('Tracing terminated'))
.catch((error) => logger.error('Error terminating tracing:' + error))
.finally(() => process.exit(0));
});
export default sdk;
// main.ts
...
tracer.start()
...
Beta Was this translation helpful? Give feedback.
All reactions