mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-04-04 15:55:23 +00:00
* feat(x/metrics): add module for emiting custom chain metrics (#1668)
* initialize x/metrics with metrics collection
* include global labels in x/metrics metrics
* add x/metrics spec
* add x/metrics test coverage
* update changelog
(cherry picked from commit
|
||
|---|---|---|
| .. | ||
| README.md | ||
metrics
Abstract
x/metrics is a stateless module that does not affect consensus. It captures chain metrics and emits them when the instrumentation.prometheus option is enabled in config.toml.
Precision
The metrics emitted by x/metrics are float64s. They use github.com/go-kit/kit/metrics Prometheus gauges. Cosmos-sdk's telemetry package was not used because, at the time of writing, it only supports float32s and so does not maintain accurate representations of ints larger than ~16.8M. With float64s, integers may be accurately represented up to ~9e15.
Metrics
The following metrics are defined:
cometbft_blocksync_latest_block_height- this emulates the blocksynclatest_block_heightmetric in CometBFT v0.38+. Thecometbftnamespace comes from theinstrumentation.namespaceconfig.toml value.
Metric Labels
All metrics emitted have the labels defined in app.toml's telemetry.global-labels field. This is the same field used by cosmos-sdk's telemetry package.
example:
# app.toml
[telemetry]
global-labels = [
["chain_id", "kava_2222-10"],
["my_label", "my_value"],
]