ppdm

package
v1.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package ppdm holds the PPDM metric model, snapshot store, modular collectors, and the Prometheus + OTLP export paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activities

type Activities struct {
	Lookback time.Duration
	PerJob   bool
}

Activities aggregates PPDM job outcome counts and total bytes within a lookback window. When PerJob is set it also emits per-job detail metrics (opt-in; higher cardinality).

func (Activities) Collect

func (a Activities) Collect(ctx context.Context, c ppdmclient.Client) ([]Sample, error)

func (Activities) Name

func (Activities) Name() string

type Assets

type Assets struct {
	AgeThreshold time.Duration
	// contains filtered or unexported fields
}

Assets aggregates protection rollups plus a bounded per-asset SLA-age series. AgeThreshold gates the per-asset emission; now is injectable for tests (defaults to time.Now).

func (Assets) Collect

func (a Assets) Collect(ctx context.Context, c ppdmclient.Client) ([]Sample, error)

func (Assets) Name

func (Assets) Name() string

type Capacity

type Capacity struct{}

Capacity collects storage-unit (MTree) and storage-system capacity in bytes.

func (Capacity) Collect

func (Capacity) Collect(ctx context.Context, c ppdmclient.Client) ([]Sample, error)

func (Capacity) Name

func (Capacity) Name() string

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector runs the background loop: every interval it polls all servers in parallel and publishes a fresh Snapshot. One server's failure never blocks others.

func NewCollector

func NewCollector(clients []ppdmclient.Client, collectors []ResourceCollector, store *SnapshotStore, interval, timeout time.Duration) *Collector

NewCollector wires the loop.

func (*Collector) CollectOnce

func (c *Collector) CollectOnce(ctx context.Context) *Snapshot

CollectOnce runs a single cycle, stores, and returns the snapshot.

func (*Collector) Run

func (c *Collector) Run(ctx context.Context)

Run loops until ctx is cancelled (assumes CollectOnce already primed the store).

type Health

type Health struct{}

Health collects PPDM health-entity status and alert counts.

func (Health) Collect

func (Health) Collect(ctx context.Context, c ppdmclient.Client) ([]Sample, error)

func (Health) Name

func (Health) Name() string

type Label

type Label struct {
	Key   string
	Value string
}

Label is a single Prometheus label key/value.

type OTLPExporter

type OTLPExporter struct {
	// contains filtered or unexported fields
}

OTLPExporter pushes the snapshot's metrics via OTLP using asynchronous observable gauges. A periodic reader drives collection: on each cycle every registered instrument's callback reads the latest snapshot and observes its samples.

func NewOTLPExporter

func NewOTLPExporter(ctx context.Context, endpoint string, insecure bool, interval string, store *SnapshotStore, serviceVersion string) (*OTLPExporter, error)

NewOTLPExporter creates an exporter that pushes metrics to an OTLP gRPC endpoint.

func (*OTLPExporter) EnsureInstruments

func (e *OTLPExporter) EnsureInstruments() error

EnsureInstruments registers an observable gauge for every metric name in the current snapshot that does not already have one. Idempotent; safe to call after reloads.

func (*OTLPExporter) Shutdown

func (e *OTLPExporter) Shutdown(ctx context.Context) error

Shutdown flushes and stops the meter provider.

type PromCollector

type PromCollector struct {
	// contains filtered or unexported fields
}

PromCollector is an unchecked Prometheus collector: Describe emits nothing so the metric-name set can vary per snapshot. Collect reads the latest snapshot.

func NewPromCollector

func NewPromCollector(store *SnapshotStore) *PromCollector

NewPromCollector wraps the snapshot store as a prometheus.Collector.

func (*PromCollector) Collect

func (p *PromCollector) Collect(ch chan<- prometheus.Metric)

Collect turns every snapshot sample into a gauge metric.

func (*PromCollector) Describe

func (p *PromCollector) Describe(chan<- *prometheus.Desc)

Describe sends nothing (unchecked collector).

type ResourceCollector

type ResourceCollector interface {
	Name() string
	Collect(ctx context.Context, c ppdmclient.Client) ([]Sample, error)
}

ResourceCollector collects one metric domain from a single PPDM server. It returns server-agnostic samples; the loop stamps the `server` label. Implementations own their endpoint path and JSON struct so provisional-API risk is localized.

func Registry

func Registry(lookback, assetAgeThreshold time.Duration, perJobActivities bool) []ResourceCollector

Registry is the ordered set of collectors run for every server.

type Sample

type Sample struct {
	Name   string
	Labels []Label
	Value  float64
}

Sample is one metric data point: a name, an ordered label set, and a value.

func (Sample) LabelValue

func (s Sample) LabelValue(key string) string

LabelValue returns the value of the named label, or "" if absent.

func (Sample) WithServer

func (s Sample) WithServer(name string) Sample

WithServer returns a copy with a leading {server=name} label. Collectors emit server-agnostic samples; the collection loop stamps the server identity.

type ServerSnapshot

type ServerSnapshot struct {
	Server     string
	LastScrape time.Time
	OK         bool   // server reachable & authenticated
	Err        string // top-level failure (auth/unreachable); empty when OK
	Samples    []Sample
}

ServerSnapshot is one PPDM server's result for a single collection cycle.

type Snapshot

type Snapshot struct {
	BuiltAt time.Time
	Servers []*ServerSnapshot
}

Snapshot is an immutable, point-in-time view across all servers.

func (*Snapshot) MetricNames

func (s *Snapshot) MetricNames() []string

MetricNames returns the sorted, de-duplicated set of metric names in the snapshot.

func (*Snapshot) SamplesByName

func (s *Snapshot) SamplesByName(name string) []Sample

SamplesByName returns every sample with the given metric name across all servers.

type SnapshotStore

type SnapshotStore struct {
	// contains filtered or unexported fields
}

SnapshotStore holds the latest Snapshot behind an RWMutex pointer-swap.

func NewSnapshotStore

func NewSnapshotStore() *SnapshotStore

NewSnapshotStore returns a store pre-populated with an empty snapshot so readers never see nil before the first collection cycle.

func (*SnapshotStore) Load

func (s *SnapshotStore) Load() *Snapshot

Load returns the current snapshot (never nil).

func (*SnapshotStore) Store

func (s *SnapshotStore) Store(snap *Snapshot)

Store atomically swaps in a new snapshot.

Jump to

Keyboard shortcuts

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