feat(infra): add OTel auto-instrumentations across all services
NestJS 6 services use getNodeAutoInstrumentations(). Python 2 services use FastAPIInstrumentor. Go 2 services use otelgin.
This commit is contained in:
@@ -27,7 +27,8 @@
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.0",
|
||||
"@opentelemetry/sdk-node": "^0.55.0",
|
||||
"@opentelemetry/exporter-trace-otlp-http": "^0.55.0"
|
||||
"@opentelemetry/exporter-trace-otlp-http": "^0.55.0",
|
||||
"@opentelemetry/auto-instrumentations-node": "^0.55.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.4.0",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { NodeSDK } from '@opentelemetry/sdk-node';
|
||||
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
||||
import { env } from '../../config/env.js';
|
||||
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
||||
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
||||
import { NodeSDK } from "@opentelemetry/sdk-node";
|
||||
import { env } from "../../config/env.js";
|
||||
|
||||
let sdk: NodeSDK | null = null;
|
||||
|
||||
@@ -8,14 +9,15 @@ export function initTracer(): void {
|
||||
if (!env.OTEL_EXPORTER_OTLP_ENDPOINT) return;
|
||||
|
||||
sdk = new NodeSDK({
|
||||
serviceName: 'msg',
|
||||
serviceName: "msg",
|
||||
traceExporter: new OTLPTraceExporter({
|
||||
url: `${env.OTEL_EXPORTER_OTLP_ENDPOINT}/v1/traces`,
|
||||
}),
|
||||
instrumentations: [getNodeAutoInstrumentations()],
|
||||
});
|
||||
|
||||
sdk.start();
|
||||
console.log('Tracer initialized');
|
||||
console.log("Tracer initialized with auto-instrumentations");
|
||||
}
|
||||
|
||||
export async function shutdownTracer(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user