create_histogram
Creates a new Histogram metric.The name of the registry to create the histogram in (typically “default”).
The name of the histogram metric.
A description of what the histogram measures.
A list of label names for this metric. The order matters and must match when observing values.
A list of bucket boundaries (floats) for the histogram. Values will be counted in buckets based on these boundaries.
Returns
Ok(Nil)if the histogram was created successfullyError(String)with an error message if creation failed (e.g., “Metric already exists”, “Invalid buckets”, or “No buckets were provided”)
Example
observe_histogram
Observes a value in the Histogram.The name of the registry where the histogram exists.
The name of the histogram metric to observe.
A list of label values for this observation. Must match the number and order of labels defined when creating the histogram.
The value to observe in the histogram.
Returns
Ok(Nil)if the value was observed successfullyError(String)with an error message if the operation failed (e.g., “Unknown metric” or “Invalid metric arity (labels mismatch)“)
Example
measure_histogram
Measures a function execution time in milliseconds and observes that in the Histogram.The name of the registry where the histogram exists.
The name of the histogram metric to observe the execution time in.
A list of label values for this observation. Must match the number and order of labels defined when creating the histogram.
The function to measure. Can return any type.
Returns
Ok(anything)with the return value of the function if measurement succeededError(String)with an error message if the operation failed
Examples
Using theuse syntax:
measure_histogram_seconds
Measures a function execution time in seconds and observes that in the Histogram.The name of the registry where the histogram exists.
The name of the histogram metric to observe the execution time in.
A list of label values for this observation. Must match the number and order of labels defined when creating the histogram.
The function to measure. Can return any type.
Returns
Ok(anything)with the return value of the function if measurement succeededError(String)with an error message if the operation failed
Examples
Using theuse syntax: