Copyright | Copyright 2023 Shea Levy. |
---|---|
License | Apache-2.0 |
Maintainer | shea@shealevy.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Observe.Event.Render.Prometheus
Description
Synopsis
- prometheusEventBackend :: forall es s. EventMetrics es => Registry -> RenderSelectorPrometheus s es -> IO (EventBackend IO PrometheusReference s)
- class (EventMetric (Counter es), EventMetric (Gauge es), EventHistogram (Histogram es)) => EventMetrics es where
- class (Ord a, Enum a, Bounded a) => EventMetric a where
- metricName :: a -> Name
- metricLabels :: a -> Labels
- class EventMetric h => EventHistogram h where
- metricBounds :: h -> [UpperBound]
- type RenderSelectorPrometheus s es = forall f. s f -> PrometheusRendered f es
- data PrometheusRendered f es = PrometheusRendered {
- onStart :: !([f] -> EventDuration -> [MetricModification es])
- onField :: !(f -> [MetricModification es])
- onFinalize :: !(Maybe SomeException -> [f] -> [MetricModification es])
- data MetricModification es
- = ModifyCounter !CounterModification !(Counter es)
- | ModifyGauge !GaugeModification !(Gauge es)
- | ModifyHistogram !HistogramModification !(Histogram es)
- data CounterModification
- = AddCounter !Int
- | IncCounter
- data GaugeModification
- data HistogramModification = Observe !Double
- data EventDuration
- data PrometheusReference = PrometheusReference
- data NonExhaustiveMetricEnumeration = NonExhaustiveMetricEnumeration
Documentation
prometheusEventBackend :: forall es s. EventMetrics es => Registry -> RenderSelectorPrometheus s es -> IO (EventBackend IO PrometheusReference s) Source #
An EventBackend
that populates a Registry
.
All metrics are registered before the backend is returned.
class (EventMetric (Counter es), EventMetric (Gauge es), EventHistogram (Histogram es)) => EventMetrics es Source #
A specification of a collection of prometheus metrics.
Note that due to limitations in the underlying prometheus client library, summaries are not yet supported.
class (Ord a, Enum a, Bounded a) => EventMetric a where Source #
A specification of a single prometheus metric of any type
Must satisfy ∀ x : a, x `elem` [minBound .. maxBound]
Methods
metricName :: a -> Name Source #
The name of the metric
metricLabels :: a -> Labels Source #
The labels of the metric
class EventMetric h => EventHistogram h where Source #
A specification of a prometheus histogram
type RenderSelectorPrometheus s es = forall f. s f -> PrometheusRendered f es Source #
Render all events selectable by s
to prometheus metrics according to EventMetrics
es
We may want to add functionality for easily combining RenderSelectorPrometheus
s and EventMetrics
from nested selector types, possibly with additional labels layered on top.
data PrometheusRendered f es Source #
How to render a specific Event
according to EventMetrics
es
Constructors
PrometheusRendered | |
Fields
|
data MetricModification es Source #
DSL for modifying metrics specified in EventMetrics
es
Constructors
ModifyCounter !CounterModification !(Counter es) | Modify the specified counter |
ModifyGauge !GaugeModification !(Gauge es) | Modify the specified gauge |
ModifyHistogram !HistogramModification !(Histogram es) | Modify the specified histogram |
data CounterModification Source #
DSL for modifying a counter metric
Constructors
AddCounter !Int | Add a value to a counter |
IncCounter | Increment a counter |
data GaugeModification Source #
DSL for modifying a gauge metric
data HistogramModification Source #
DSL for modifying a histogram metric
data EventDuration Source #
What duration event is this?
data PrometheusReference Source #
Reference type for prometheusEventBackend
Prometheus can't make use of references, so this carries no information.
Constructors
PrometheusReference |
data NonExhaustiveMetricEnumeration Source #
Exception thrown if we encounter an element of an EventMetric
that
is not in [minBound .. maxBound]
Constructors
NonExhaustiveMetricEnumeration |