Documentation
¶
Overview ¶
Package obs wires Prometheus metrics for docsiq. One registry per process (exposed via obs.Default). Metric families are grouped by subject (HTTP, pipeline, embed, LLM, workq, build-info) so handlers record through a thin typed API — callers never touch raw collectors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Default = prometheus.NewRegistry() HTTP *HTTPMetrics Pipeline *PipelineMetrics Embed *EmbedMetrics LLM *LLMMetrics Workq *WorkqMetrics Build *BuildInfoMetric )
Default is the process-wide registry. Tests construct their own prometheus.NewRegistry() to avoid Register-twice panics.
Functions ¶
func NewProductionHandler ¶
NewProductionHandler wraps an inner slog.Handler and strips a leading emoji + trailing space from each record's Message. docsiq uses emoji prefixes (OK KO WARN etc.) as visual cues in dev text format; in JSON these collide with log-aggregator indexing (Elasticsearch tokeniser, fluentd grep rules) and obscure the actual message string. The handler mutates only Message — attrs pass through.
Types ¶
type BuildInfoMetric ¶
type BuildInfoMetric struct {
Info *prometheus.GaugeVec
}
BuildInfoMetric wraps the docsiq_build_info gauge used for {version, commit} labels on dashboards.
func NewBuildInfoMetric ¶
func NewBuildInfoMetric(reg prometheus.Registerer) *BuildInfoMetric
NewBuildInfoMetric constructs + registers the build-info gauge.
func (*BuildInfoMetric) Set ¶
func (m *BuildInfoMetric) Set(version, commit string)
Set publishes the current build metadata. Subsequent Set calls overwrite rather than accumulate labels.
type EmbedMetrics ¶
type EmbedMetrics struct {
Latency *prometheus.HistogramVec
}
EmbedMetrics bundles the embed-latency histogram.
func NewEmbedMetrics ¶
func NewEmbedMetrics(reg prometheus.Registerer) *EmbedMetrics
NewEmbedMetrics constructs + registers the embed-latency family.
type HTTPMetrics ¶
type HTTPMetrics struct {
Requests *prometheus.CounterVec
Duration *prometheus.HistogramVec
}
HTTPMetrics bundles the request counter + duration histogram.
func NewHTTPMetrics ¶
func NewHTTPMetrics(reg prometheus.Registerer) *HTTPMetrics
NewHTTPMetrics constructs and registers the HTTP metric family on reg.
type LLMMetrics ¶
type LLMMetrics struct {
Tokens *prometheus.CounterVec
}
LLMMetrics bundles the token-counter family.
func NewLLMMetrics ¶
func NewLLMMetrics(reg prometheus.Registerer) *LLMMetrics
NewLLMMetrics constructs + registers the LLM-tokens family.
func (*LLMMetrics) RecordTokens ¶
func (m *LLMMetrics) RecordTokens(provider, kind string, n int)
RecordTokens increments the counter by n. Use kind="prompt", "completion", or "total" (when the provider cannot split usage). Non-positive n is ignored so callers don't have to guard.
type PipelineMetrics ¶
type PipelineMetrics struct {
StageDuration *prometheus.HistogramVec
}
PipelineMetrics bundles the pipeline-stage histogram.
func NewPipelineMetrics ¶
func NewPipelineMetrics(reg prometheus.Registerer) *PipelineMetrics
NewPipelineMetrics constructs + registers the pipeline-stage family.
type WorkqMetrics ¶
type WorkqMetrics struct {
// contains filtered or unexported fields
}
WorkqMetrics wraps the workq gauges/counters; the actual values are read via a late-bound provider function so the pool can be swapped in after registration without re-registering collectors.
func NewWorkqMetrics ¶
func NewWorkqMetrics(reg prometheus.Registerer) *WorkqMetrics
NewWorkqMetrics registers the workq collectors. The provider is a no-op until BindStatsProvider is called; Prometheus scrapes before binding will see Depth=0, Rejected=0 (safe defaults).
func (*WorkqMetrics) BindStatsProvider ¶
func (m *WorkqMetrics) BindStatsProvider(p WorkqStatsProvider)
BindStatsProvider wires a live snapshot source. Call from cmd/serve.go after the pool is created, before starting the HTTP server.
type WorkqStats ¶
WorkqStats is the snapshot surface the obs layer needs from workq. Workq owns the concrete Pool.Stats() method; obs only reads.
type WorkqStatsProvider ¶
type WorkqStatsProvider func() WorkqStats
WorkqStatsProvider is a closure over pool.Stats(). Injected from cmd/serve.go after the pool is constructed, so the obs package does not take a hard dep on internal/workq (keeps the import DAG acyclic).