exporter

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 11 Imported by: 0

README

internal/exporter

Logic overview

The exporter package bridges store snapshots into Prometheus/OpenMetrics output.

  • Snapshot data is read from a SnapshotReader.
  • Optional snapshot caching supports full or incremental refresh strategy.
  • A custom collector emits each snapshot point as a gauge sample.
  • A dedicated registry is served with promhttp and OpenMetrics enabled.

API reference

Types
  • SnapshotReader: interface with Snapshot() []store.MetricPoint used as the exporter input contract.
  • CacheConfig: cache settings (Mode, RefreshInterval, Now) for snapshot refresh behavior.
Functions
  • NewOpenMetricsHandler(reader SnapshotReader) http.Handler: builds a Prometheus registry, registers the snapshot collector, and returns an OpenMetrics-capable HTTP handler.
  • NewCachedSnapshotReader(source SnapshotReader, cfg CacheConfig) SnapshotReader: wraps a reader with refresh-based caching. In incremental mode, it uses SnapshotCursor/SnapshotDelta when supported by the source.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOpenMetricsHandler

func NewOpenMetricsHandler(reader SnapshotReader) http.Handler

NewOpenMetricsHandler returns a handler that renders store snapshots through the Prometheus OpenMetrics encoder.

Types

type CacheConfig

type CacheConfig struct {
	Mode            string
	RefreshInterval time.Duration
	Now             func() time.Time
}

CacheConfig configures the snapshot cache used by /metrics rendering.

type CacheStats

type CacheStats struct {
	RefreshDuration time.Duration
}

CacheStats contains refresh statistics for exporter cache observability.

type SnapshotReader

type SnapshotReader interface {
	Snapshot() []store.MetricPoint
}

SnapshotReader reads metric snapshots.

func NewCachedSnapshotReader

func NewCachedSnapshotReader(source SnapshotReader, cfg CacheConfig) SnapshotReader

NewCachedSnapshotReader wraps a snapshot reader with periodic cache refresh.

Jump to

Keyboard shortcuts

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