import "dotenv/config"; // Load env vars before checking OTEL_ENABLED import type { NodeSDK } from "@opentelemetry/sdk-node"; import { isOtelEnabled } from "./index"; let sdk: NodeSDK | null = null; if (isOtelEnabled) { const { createNodeSDK } = require("./sdk-factory") as typeof import("./sdk-factory"); const { HttpInstrumentation } = require("@opentelemetry/instrumentation-http"); const { IORedisInstrumentation } = require("@opentelemetry/instrumentation-ioredis"); sdk = createNodeSDK({ serviceName: process.env.OTEL_SERVICE_NAME || "sase-worker", instrumentations: [new HttpInstrumentation(), new IORedisInstrumentation()], }); } else { console.log("[worker][otel] Telemetry disabled (OTEL_ENABLED !== 'true')"); } export { sdk };