ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Telemetry.Record

Description

The metric-recording ports: the abstract interfaces the core serve path and mirror worker record through, decoupled from any telemetry backend.

Ecluse.Core.Telemetry.Metrics defines what the ecluse.* catalogue is (the names and the closed set of bounded labels). This module defines the recording interfaces over that catalogue as records of IO functions (the Handle pattern, as Ecluse.Core.Registry and Ecluse.Core.Queue use): one field per signal a consumer emits, each taking only the bounded label values its metric carries. A consumer records through its port and never names an OpenTelemetry instrument; the application supplies the OTel-backed implementations behind them (see Ecluse.Telemetry.Instruments). A test supplies an inert or recording double.

Two ports are defined: MetricsPort for the serve path (serve decisions, the rule gate, the data-plane upstream fetch, the metadata cache, and mirror enqueue) and WorkerMetricsPort for the mirror worker (jobs processed, publish latency). The credential signals stay in the application instrument set; each port carries exactly the signals its consumer emits.

Synopsis

The serve-path recording port

data MetricsPort Source #

The metric-recording port -- a record of functions over a backend whose closure captures its instruments. Each field records one ecluse.* signal under exactly the bounded labels that signal carries; the closed label vocabularies come from Ecluse.Core.Telemetry.Metrics, so the bounded-cardinality discipline is enforced at the call site by the types. All fields return IO, so a backend (and the core code recording through it) stays decoupled from the application's effect stack.

Constructors

MetricsPort 

Fields

The worker recording port

data WorkerMetricsPort Source #

The mirror worker's metric-recording port -- the worker analogue of MetricsPort, kept a separate record so the worker records exactly its own signals and the serve path exactly its own (the two consumers share no field). Both fields return IO, so the worker loop records through the port without naming a telemetry backend; the application supplies the OTel-backed implementation (see Ecluse.Telemetry.Instruments) and a test an inert or recording double.

Constructors

WorkerMetricsPort 

Fields

Timing

timedSeconds :: MonadIO m => m a -> m (a, Double) Source #

Run an action and return its result alongside the wall-clock seconds it took, measured on the monotonic clock so a system-clock step never yields a negative or absurd duration. The seconds are what the latency histograms record (through mpRuleEvalDuration / mpUpstreamFetch). Pure of any backend, so it lives beside the port the durations feed.