Documentation
¶
Overview ¶
Package exporter exposes a gpu.Collector as Prometheus metrics.
The Exporter is a prometheus.Collector (Describe + Collect) that wraps a gpu.Collector built lazily on the first scrape via an injected factory. Per plan R4 it:
- guards GPU reads with a sync.Mutex so overlapping scrapes never race the inner collector (bounded scrape freshness);
- holds its OWN *prometheus.Registry created via prometheus.NewRegistry so repeated instances or tests never panic on duplicate registration and the global default registry is never touched;
- emits gpu_tools_up 0 with NO device series (HTTP 200) when the backend is unavailable (ErrBackendUnavailable / ErrNoBackend);
- never returns or propagates an error to promhttp: on a read error it logs to the configured logger seam (stderr by default) and emits up 0.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter implements prometheus.Collector over a gpu.Collector.
func New ¶
New builds an Exporter over factory, logging read errors to stderr, and registers it into its own registry.
func NewWithLogger ¶
NewWithLogger is the test seam: it lets callers capture the stderr log sink.
func (*Exporter) Collect ¶
func (e *Exporter) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector. It NEVER propagates an error to promhttp (R4d): on any failure it logs and emits gpu_tools_up 0 with no device series. The whole read is mutex-guarded so overlapping scrapes never race the inner collector (R4a).
func (*Exporter) Describe ¶
func (e *Exporter) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector. Sending descriptors here keeps the registry from treating the collector as unchecked.
func (*Exporter) Registry ¶
func (e *Exporter) Registry() *prometheus.Registry
Registry returns the Exporter's own registry (R4b). Serve /metrics via promhttp.HandlerFor(exp.Registry(), ...).