"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initOpenTelemetry = initOpenTelemetry;
const sdk_node_1 = require("@opentelemetry/sdk-node");
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
const chalk_1 = __importDefault(require("chalk"));
const util_js_1 = require("../../core/util.js");
const http_exporter_js_1 = __importDefault(require("../exporter/http-exporter.js"));
async function initOpenTelemetry({ dbPath, exportFn, }) {
    const traceExporter = new http_exporter_js_1.default({ dbPath, exportFn });
    const spanProcessor = new sdk_trace_base_1.SimpleSpanProcessor(traceExporter);
    const sdk = new sdk_node_1.NodeSDK({
        spanProcessor,
        instrumentations: [],
    });
    await sdk.start();
    if (!util_js_1.isBlocklet) {
        console.log(`Install the CLI first with: ${chalk_1.default.greenBright("npm install -g @aigne/cli")}, then run ${chalk_1.default.greenBright("aigne observe")} to start the observability server.`);
    }
    return traceExporter;
}
