mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 04:28:01 +00:00
client/service/src/builder.rs: Add build_info metric (#5192)
* client/service/src/builder.rs: Add build_info metric Add static Prometheus metric exposing the chain name, the version and the commit. * client/service/src/builder.rs: Move node_role to static metrics The Prometheus metrics `node_role` is static and thus there is no need to keep a reference of it within `ServiceMetrics`. This follows the example of the `build_info` metric. * client/service/src/builder.rs: Adjust indentation
This commit is contained in:
@@ -61,7 +61,6 @@ struct ServiceMetrics {
|
||||
memory_usage_bytes: Gauge<U64>,
|
||||
cpu_usage_percentage: Gauge<F64>,
|
||||
network_per_sec_bytes: GaugeVec<U64>,
|
||||
node_roles: Gauge<U64>,
|
||||
database_cache: Gauge<U64>,
|
||||
state_cache: Gauge<U64>,
|
||||
state_db: GaugeVec<U64>,
|
||||
@@ -87,9 +86,6 @@ impl ServiceMetrics {
|
||||
Opts::new("network_per_sec_bytes", "Networking bytes per second"),
|
||||
&["direction"]
|
||||
)?, registry)?,
|
||||
node_roles: register(Gauge::new(
|
||||
"node_roles", "The roles the node is running as",
|
||||
)?, registry)?,
|
||||
database_cache: register(Gauge::new(
|
||||
"database_cache_bytes", "RocksDB cache size in bytes",
|
||||
)?, registry)?,
|
||||
@@ -1011,18 +1007,34 @@ ServiceBuilder<
|
||||
);
|
||||
}
|
||||
|
||||
// Prometheus metrics
|
||||
// Prometheus metrics.
|
||||
let metrics = if let Some(PrometheusConfig { port, registry }) = config.prometheus_config.clone() {
|
||||
// Set static metrics.
|
||||
register(Gauge::<U64>::with_opts(
|
||||
Opts::new(
|
||||
"build_info",
|
||||
"A metric with a constant '1' value labeled by name, version, and commit."
|
||||
)
|
||||
.const_label("name", config.impl_name)
|
||||
.const_label("version", config.impl_version)
|
||||
.const_label("commit", config.impl_commit),
|
||||
)?, ®istry)?.set(1);
|
||||
register(Gauge::<U64>::new(
|
||||
"node_roles", "The roles the node is running as",
|
||||
)?, ®istry)?.set(u64::from(config.roles.bits()));
|
||||
|
||||
let metrics = ServiceMetrics::register(®istry)?;
|
||||
metrics.node_roles.set(u64::from(config.roles.bits()));
|
||||
|
||||
spawn_handle.spawn(
|
||||
"prometheus-endpoint",
|
||||
prometheus_endpoint::init_prometheus(port, registry).map(drop)
|
||||
);
|
||||
|
||||
Some(metrics)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// Periodically notify the telemetry.
|
||||
let transaction_pool_ = transaction_pool.clone();
|
||||
let client_ = client.clone();
|
||||
|
||||
Reference in New Issue
Block a user