UNPKG

openlit

Version:

OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects

38 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EVAL_METRIC_ATTRIBUTES = void 0; exports.recordEvalMetrics = recordEvalMetrics; const api_1 = require("@opentelemetry/api"); exports.EVAL_METRIC_ATTRIBUTES = { verdict: 'evals.verdict', score: 'evals.score', validator: 'evals.validator', classification: 'evals.classification', explanation: 'evals.explanation', }; // Global meter and counter for eval metrics let evalCounter; function getEvalCounter() { if (!evalCounter) { // Use the global meter from OpenTelemetry API const meter = api_1.metrics.getMeter('openlit-evals', '1.0.0'); evalCounter = meter.createCounter('evals.requests', { description: 'Counter for evaluation requests', unit: '1', }); } return evalCounter; } function recordEvalMetrics(result, validator) { const counter = getEvalCounter(); const attributes = { [exports.EVAL_METRIC_ATTRIBUTES.verdict]: result.verdict, [exports.EVAL_METRIC_ATTRIBUTES.score]: result.score, [exports.EVAL_METRIC_ATTRIBUTES.validator]: validator, [exports.EVAL_METRIC_ATTRIBUTES.classification]: result.classification, [exports.EVAL_METRIC_ATTRIBUTES.explanation]: result.explanation, evaluation: result.evaluation, }; counter.add(1, attributes); } //# sourceMappingURL=metrics.js.map