// engine/observability/metrics.ts — Custom metric definitions (SPEC-165)
// Defines the Planu-specific metrics that instruments record.
import { getTracer } from './tracer.js';
// ---------------------------------------------------------------------------
// Metric catalog
// ---------------------------------------------------------------------------
/** All custom metrics exposed by the Planu observability module. */
export const PLANU_METRICS = [
    {
        name: 'spec_created_total',
        kind: 'counter',
        description: 'Total number of specs created.',
        unit: '{spec}',
    },
    {
        name: 'spec_drift_detected_total',
        kind: 'counter',
        description: 'Total number of drift events detected.',
        unit: '{event}',
    },
    {
        name: 'spec_coverage_percent',
        // Recorded via recordHistogram — 'histogram' is consistent with the recording call below.
        // Semantically this is a gauge (point-in-time snapshot), but since the Tracer interface
        // only exposes recordHistogram for numeric observations, 'histogram' is the correct kind here.
        kind: 'histogram',
        description: 'Current spec coverage percentage for a project (sampled as histogram observation).',
        unit: '%',
    },
    {
        name: 'tool_call_duration_seconds',
        kind: 'histogram',
        description: 'Duration of each tool call in seconds.',
        unit: 's',
    },
];
// ---------------------------------------------------------------------------
// Convenience recording functions
// ---------------------------------------------------------------------------
/** Records a spec_created_total counter increment. */
export function recordSpecCreated(projectId) {
    getTracer().recordCounter('spec_created_total', 1, { 'project.id': projectId });
}
/** Records a spec_drift_detected_total counter increment. */
export function recordDriftDetected(projectId, specId) {
    getTracer().recordCounter('spec_drift_detected_total', 1, {
        'project.id': projectId,
        'spec.id': specId,
    });
}
/** Records the current spec coverage percentage as a gauge observation. */
export function recordSpecCoverage(projectId, percent) {
    getTracer().recordHistogram('spec_coverage_percent', percent, { 'project.id': projectId });
}
/** Records a tool call duration in seconds. */
export function recordToolDuration(toolName, durationMs) {
    getTracer().recordHistogram('tool_call_duration_seconds', durationMs / 1000, {
        'tool.name': toolName,
    });
}
//# sourceMappingURL=metrics.js.map