openlit
Version:
OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects
44 lines • 1.96 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
const instrumentation_1 = __importDefault(require("./instrumentation"));
const config_1 = __importDefault(require("./config"));
class Tracing {
static async setup(options) {
if (options.tracer)
return options.tracer;
try {
this.traceProvider = new sdk_trace_node_1.NodeTracerProvider({
resource: options.resource,
});
config_1.default.updateConfig({
...options,
tracer: options.tracer || Tracing.traceProvider,
});
instrumentation_1.default.setup(Tracing.traceProvider, options?.disabledInstrumentations, options?.instrumentations);
const consoleSpanExporter = new sdk_trace_node_1.ConsoleSpanExporter();
// Adding span to console
this.traceProvider.addSpanProcessor(new sdk_trace_node_1.SimpleSpanProcessor(consoleSpanExporter));
this.traceExporter = new exporter_trace_otlp_http_1.OTLPTraceExporter({
url: options.otlpEndpoint,
headers: options.otlpHeaders,
});
if (options.disableBatch) {
this.traceProvider.addSpanProcessor(new sdk_trace_node_1.SimpleSpanProcessor(this.traceExporter));
}
else {
this.traceProvider.addSpanProcessor(new sdk_trace_node_1.BatchSpanProcessor(this.traceExporter));
}
this.traceProvider.register();
}
catch (e) {
return null;
}
}
}
exports.default = Tracing;
//# sourceMappingURL=tracing.js.map