"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initTracing = initTracing;
const sdk_node_1 = require("@opentelemetry/sdk-node");
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
const auto_instrumentations_node_1 = require("@opentelemetry/auto-instrumentations-node");
const resources_1 = require("@opentelemetry/resources");
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
let sdk = null;
async function initTracing() {
    if (sdk) {
        return;
    }
    const traceExporter = new exporter_trace_otlp_http_1.OTLPTraceExporter();
    sdk = new sdk_node_1.NodeSDK({
        resource: new resources_1.Resource({
            [semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]: 'repoburg-backend',
        }),
        traceExporter,
        instrumentations: [
            (0, auto_instrumentations_node_1.getNodeAutoInstrumentations)({
                '@opentelemetry/instrumentation-fs': {
                    enabled: false,
                },
            }),
        ],
    });
    try {
        await sdk.start();
    }
    catch (error) {
    }
    process.on('SIGTERM', () => {
        sdk
            ?.shutdown()
            .catch(() => { })
            .finally(() => process.exit(0));
    });
}
//# sourceMappingURL=tracing.js.map