telemetry

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package telemetry provides RunLore's self-instrumentation: an OpenTelemetry metric set plus a Prometheus-exporter HTTP handler. Instruments are safe to call even when no provider is configured (the global meter is a no-op), so callers never need nil checks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRuntimeGauges

func RegisterRuntimeGauges(version string, isLeader func() bool) error

RegisterRuntimeGauges registers async gauges for build info and leadership. Call once after Setup (when a real provider is installed); with the no-op provider it is a harmless no-op. isLeader may be nil (always reports standby). It exposes:

  • runlore_build_info{version} = 1 (for `absent()` liveness + version display)
  • runlore_leader = 1 when this replica is the elected leader, else 0

func Setup

func Setup(_ context.Context) (http.Handler, func(context.Context) error, error)

Setup installs a global OTel meter provider backed by a Prometheus exporter and returns an http.Handler that serves the exposition format, plus a shutdown func. Call NewMetrics AFTER Setup so instruments bind to this provider.

Types

type Metrics

type Metrics struct {
	AlertsReceived            metric.Int64Counter
	AlertsCoalesced           metric.Int64Counter
	AlertsSuppressed          metric.Int64Counter
	InvestigationsStarted     metric.Int64Counter
	InvestigationsThrottled   metric.Int64Counter
	InvestigationsDropped     metric.Int64Counter
	GitOpsFailuresDebounced   metric.Int64Counter // GitOps failures dropped as transient (cleared within the debounce window)
	ToolOutputTruncatedBytes  metric.Int64Counter
	RecallHits                metric.Int64Counter // KB cache hits, labelled by verify result
	RecallTokensSaved         metric.Int64Counter // estimated tokens saved by a recall short-circuit
	RecallRejections          metric.Int64Counter // recalls rejected before short-circuit (label: reason)
	CoalesceBatchSize         metric.Int64Histogram
	InvestigationTokens       metric.Int64Histogram
	RecallScore               metric.Float64Histogram // BM25 score at the recall decision (tunes min_score)
	CurationDedupScore        metric.Float64Histogram // catalog top-hit BM25 score at the curation dedup decision
	OutcomesOpened            metric.Int64Counter     // investigations recorded as open (label: kind)
	IncidentsResolved         metric.Int64Counter     // resolve events that matched an open investigation
	RecallOutcome             metric.Int64Counter     // resolved incidents whose open was a recall (label: result)
	IncidentResolutionSeconds metric.Float64Histogram // open→resolve duration, seconds

	InvestigationDuration   metric.Float64Histogram // wall-clock per investigation (label: result)
	InvestigationsCompleted metric.Int64Counter     // investigations finished (label: result)
	ToolCalls               metric.Int64Counter     // investigation tool calls (label: tool, result)
	ToolCallDuration        metric.Float64Histogram // tool call latency, seconds (label: tool)
	ModelRequests           metric.Int64Counter     // LLM completion requests (label: provider, result)
	ModelRequestDuration    metric.Float64Histogram // LLM completion latency, seconds (label: provider)
	ModelResponsesTruncated metric.Int64Counter     // LLM completions cut off at the output-token ceiling (label: provider)
	Curations               metric.Int64Counter     // curation outcomes (label: kind, result)
	CatalogInvalidEntries   metric.Int64Counter     // structurally-invalid entries found at catalog load
}

Metrics is the RunLore instrument set, created once and shared.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics builds the instrument set from the global meter provider.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL