View Source CozyTelemetry.Metrics behaviour (cozy_telemetry v0.4.3)
A behaviour for declaring metrics.
Any module that wants to exposing metrics should implement this behaviour.
defmodule MyApp.Cache do
use CozyTelemetry.Metrics
@impl CozyTelemetry.Metrics
def metrics(meta) do
[
summary("cache.duration",
unit: {:native, :second},
tags: [:type, :key]
)
]
end
end
Then, the declared metrics in above module can be loaded with following configuration:
config :my_app, CozyTelemetry,
meta: [],
metrics: [
MyApp.Cache
],
# ...
Link to this section Summary
Functions
Loads the metrics from given module.
Same as load_metrics_from_module/2
but raises if the module cannot be loaded.
Link to this section Types
@type meta() :: keyword()
Link to this section Callbacks
@callback metrics(meta()) :: [Telemetry.Metrics.t()]
Link to this section Functions
Loads the metrics from given module.
Same as load_metrics_from_module/2
but raises if the module cannot be loaded.