Module solana_metrics::datapoint
source · Expand description
This file defines a set of macros for reporting metrics.
To report a metric, simply calling one of the following datapoint macros with a suitable message level:
- datapoint_error!
- datapoint_warn!
- datapoint_trace!
- datapoint_info!
- datapoint_debug!
The matric macro consists of the following three main parts:
-
name: the name of the metric.
-
tags (optional): when a metric sample is reported with tags, you can use group-by when querying the reported samples. Each metric sample can be attached with zero to many tags. Each tag is of the format:
- “tag-name” => “tag-value”
-
fields (optional): fields are the main content of a metric sample. The macro supports four different types of fields: bool, i64, f64, and String. Here’re their syntax:
- (“field-name”, “field-value”, bool)
- (“field-name”, “field-value”, i64)
- (“field-name”, “field-value”, f64)
- (“field-name”, “field-value”, String)
Example:
datapoint_debug!( “name-of-the-metric”, “tag” => “tag-value”, “tag2” => “tag-value2”, (“some-bool”, false, bool), (“some-int”, 100, i64), (“some-float”, 1.05, f64), (“some-string”, “field-value”, String), );