// OpenTelemetry auto-instrumentation. Imported FIRST in server.js. const process = require("process"); try { const { NodeSDK } = require("@opentelemetry/sdk-node"); const { getNodeAutoInstrumentations, } = require("@opentelemetry/auto-instrumentations-node"); const { OTLPTraceExporter, } = require("@opentelemetry/exporter-trace-otlp-http"); const endpointBase = process.env.SIGNOZ_OTEL_ENDPOINT || "http://100.64.0.10:4318"; const tracesEndpoint = `${endpointBase.replace(/\/$/, "")}/v1/traces`; const sdk = new NodeSDK({ serviceName: "skribbl-gartic-color", traceExporter: new OTLPTraceExporter({ url: tracesEndpoint }), instrumentations: [ getNodeAutoInstrumentations({ "@opentelemetry/instrumentation-fs": { enabled: false }, }), ], }); try { sdk.start(); console.log( `[otel] tracing initialised (endpoint=${tracesEndpoint}, service=skribbl-gartic-color)` ); } catch (err) { console.warn("[otel] sdk.start failed (continuing without tracing):", err?.message || err); } process.on("SIGTERM", () => { sdk.shutdown().catch(() => {}).finally(() => process.exit(0)); }); } catch (err) { console.warn( "[otel] tracing dependencies not available, continuing without telemetry:", err?.message || err ); }