Expand description
A lightweight metrics facade used in CKB.
The ckb-metrics crate is a set of tools for metrics.
The crate ckb-metrics-service is the runtime which handles the metrics data in CKB.
Modules§
- core
- Core traits and types.
- local
- Unsync local metrics, provides better performance.
- proto
- Protocol buffers format of metrics.
Macros§
- histogram_
opts - Create a
HistogramOpts. - labels
- Create labels with specified name-value pairs.
- opts
- Create an
Opts. - register_
counter - Create a
Counterand registers to default registry. - register_
counter_ vec - Create a
CounterVecand registers to default registry. - register_
counter_ vec_ with_ registry - Create a
CounterVecand registers to a custom registry. - register_
counter_ with_ registry - Create a
Counterand registers to a custom registry. - register_
gauge - Create a
Gaugeand registers to default registry. - register_
gauge_ vec - Create a
GaugeVecand registers to default registry. - register_
gauge_ vec_ with_ registry - Create a
GaugeVecand registers to a custom registry. - register_
gauge_ with_ registry - Create a
Gaugeand registers to a custom registry. - register_
histogram - Create a
Histogramand registers to default registry. - register_
histogram_ vec - Create a
HistogramVecand registers to default registry. - register_
histogram_ vec_ with_ registry - Create a
HistogramVecand registers to default registry. - register_
histogram_ with_ registry - Create a
Histogramand registers to a custom registry. - register_
int_ counter - Create an
IntCounterand registers to default registry. - register_
int_ counter_ vec - Create an
IntCounterVecand registers to default registry. - register_
int_ counter_ vec_ with_ registry - Create an
IntCounterVecand registers to a custom registry. - register_
int_ counter_ with_ registry - Create an
IntCounterand registers to a custom registry. - register_
int_ gauge - Create an
IntGaugeand registers to default registry. - register_
int_ gauge_ vec - Create an
IntGaugeVecand registers to default registry. - register_
int_ gauge_ vec_ with_ registry - Create an
IntGaugeVecand registers to a custom registry. - register_
int_ gauge_ with_ registry - Create an
IntGaugeand registers to a custom registry.
Structs§
- Histogram
- A
Metriccounts individual observations from an event or sample stream in configurable buckets. Similar to aSummary, it also provides a sum of observations and an observation count. - Histogram
Opts - A struct that bundles the options for creating a
Histogrammetric. It is mandatory to set Name and Help to a non-empty string. All other fields are optional and can safely be left at their zero value. - Histogram
Timer - Timer to measure and record the duration of an event.
- Metrics
- Opts
- A struct that bundles the options for creating most
Metrictypes. - Protobuf
Encoder - An implementation of an
Encoderthat converts aMetricFamilyproto message into the binary wire format of protobuf. - Pulling
Gauge - A Gauge that returns the value from a provided function on every collect run.
- Registry
- A struct for registering Prometheus collectors, collecting their metrics, and gathering
them into
MetricFamiliesfor exposition. - Text
Encoder - An implementation of an
Encoderthat converts aMetricFamilyproto message into text format.
Enums§
- Error
- The error types for prometheus.
Constants§
- DEFAULT_
BUCKETS - The default
Histogrambuckets. The default buckets are tailored to broadly measure the response time (in seconds) of a network service. Most likely, however, you will be required to define buckets customized to your use case. - PROTOBUF_
FORMAT - The protocol buffer format of metric family.
- TEXT_
FORMAT - The text format of metric family.
Statics§
- METRICS_
SERVICE_ ENABLED - Indicate whether the metrics service is enabled. This value will set by ckb-metrics-service
Traits§
- Encoder
- An interface for encoding metric families into an underlying wire protocol.
Functions§
- default_
registry - Default registry (global static).
- exponential_
buckets - Create
countbuckets, where the lowest bucket has an upper bound ofstartand each following bucket’s upper bound isfactortimes the previous bucket’s upper bound. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field ofHistogramOpts. - gather
- handle
- if metrics service is enabled,
handle()will returnSome(&'static METRICS)else will returnNone - linear_
buckets - Create
countbuckets, eachwidthwide, where the lowest bucket has an upper bound ofstart. The final +Inf bucket is not counted and not included in the returned slice. The returned slice is meant to be used for the Buckets field ofHistogramOpts. - register
- Registers a new
Collectorto be included in metrics collection. It returns an error if the descriptors provided by theCollectorare invalid or if they - in combination with descriptors of already registered Collectors - do not fulfill the consistency and uniqueness criteria described in theDescdocumentation. - unregister
- Unregisters the
Collectorthat equals theCollectorpassed in as an argument. (Two Collectors are considered equal if their Describe method yields the same set of descriptors.) The function returns an error if aCollectorwas not registered.
Type Aliases§
- Counter
- A
Metricrepresents a single numerical value that only ever goes up. - Counter
Vec - A
Collectorthat bundles a set ofCounters that all share the sameDesc, but have different values for their variable labels. This is used if you want to count the same thing partitioned by various dimensions (e.g. number of HTTP requests, partitioned by response code and method). - Gauge
- A
Metricrepresents a single numerical value that can arbitrarily go up and down. - Gauge
Vec - A
Collectorthat bundles a set ofGauges that all share the sameDesc, but have different values for their variable labels. This is used if you want to count the same thing partitioned by various dimensions (e.g. number of operations queued, partitioned by user and operation type). - Histogram
Vec - A
Collectorthat bundles a set of Histograms that all share the sameDesc, but have different values for their variable labels. This is used if you want to count the same thing partitioned by various dimensions (e.g. HTTP request latencies, partitioned by status code and method). - IntCounter
- The integer version of
Counter. Provides better performance if metric values are all positive integers (natural numbers). - IntCounter
Vec - The integer version of
CounterVec. Provides better performance if metric are all positive integers (natural numbers). - IntGauge
- The integer version of
Gauge. Provides better performance if metric values are all integers. - IntGauge
Vec - The integer version of
GaugeVec. Provides better performance if metric values are all integers. - Result
- A specialized Result type for prometheus.