Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: introduce near_build_info metric with node’s release info #6680

Merged
merged 4 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Use kebab-case names for neard subcommands to make them consistent with flag names. snake_case names are still valid for existing subcommands but kebab-case will be used for new commands.
* Added `near_peer_message_received_by_type_bytes` metric [#6661](/~https://github.com/near/nearcore/pull/6661)
* Removed `near_<msg-type>_{total,bytes}` metrics in favour of `near_peer_message_received_by_type_{total,bytes}` metrics [#6661](/~https://github.com/near/nearcore/pull/6661)
* Added `near_build_info` metric which exports neard’s build information [#6680](/~https://github.com/near/nearcore/pull/6680)

## 1.25.0 [2022-03-16]

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions chain/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ near-network = { path = "../network" }
near-pool = { path = "../pool" }
near-chunks = { path = "../chunks" }
near-telemetry = { path = "../telemetry" }
near-o11y = { path = "../../core/o11y" }
near-performance-metrics = { path = "../../utils/near-performance-metrics" }
near-performance-metrics-macros = { path = "../../utils/near-performance-metrics-macros" }
delay-detector = { path = "../../tools/delay_detector" }
Expand Down
5 changes: 2 additions & 3 deletions chain/client/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use near_primitives::telemetry::{
use near_primitives::time::{Clock, Instant};
use near_primitives::types::{AccountId, BlockHeight, EpochHeight, Gas, NumBlocks, ShardId};
use near_primitives::validator_signer::ValidatorSigner;
use near_primitives::version::{Version, DB_VERSION, PROTOCOL_VERSION};
use near_primitives::version::Version;
use near_primitives::views::{CurrentEpochValidatorInfo, EpochValidatorInfo, ValidatorKickoutView};
use near_store::db::StoreStatistics;
use near_telemetry::{telemetry, TelemetryActor};
Expand Down Expand Up @@ -60,6 +60,7 @@ impl InfoHelper {
validator_signer: Option<Arc<dyn ValidatorSigner>>,
) -> Self {
set_open_files_limit(0);
metrics::export_version(&client_config.version);
InfoHelper {
nearcore_version: client_config.version.clone(),
sys: System::new(),
Expand Down Expand Up @@ -179,8 +180,6 @@ impl InfoHelper {
(metrics::AVG_TGAS_USAGE.set((avg_gas_used as f64 / TERAGAS).round() as i64));
(metrics::EPOCH_HEIGHT.set(epoch_height as i64));
(metrics::PROTOCOL_UPGRADE_BLOCK_HEIGHT.set(protocol_upgrade_block_height as i64));
(metrics::NODE_PROTOCOL_VERSION.set(PROTOCOL_VERSION as i64));
(metrics::NODE_DB_VERSION.set(DB_VERSION as i64));

// In case we can't get the list of validators for the current and the previous epoch,
// skip updating the per-validator metrics.
Expand Down
43 changes: 36 additions & 7 deletions chain/client/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ pub static PROTOCOL_UPGRADE_BLOCK_HEIGHT: Lazy<IntGauge> = Lazy::new(|| {
)
.unwrap()
});
pub static NODE_PROTOCOL_VERSION: Lazy<IntGauge> = Lazy::new(|| {
try_create_int_gauge("near_node_protocol_version", "Max protocol version supported by the node")
.unwrap()
});
pub static NODE_DB_VERSION: Lazy<IntGauge> = Lazy::new(|| {
try_create_int_gauge("near_node_db_version", "DB version used by the node").unwrap()
});
pub static CHUNK_SKIPPED_TOTAL: Lazy<IntCounterVec> = Lazy::new(|| {
try_create_int_counter_vec(
"near_chunk_skipped_total",
Expand Down Expand Up @@ -174,3 +167,39 @@ pub static CLIENT_TRIGGER_TIME_BY_TYPE: Lazy<HistogramVec> = Lazy::new(|| {
)
.unwrap()
});

static NODE_PROTOCOL_VERSION: Lazy<IntGauge> = Lazy::new(|| {
try_create_int_gauge("near_node_protocol_version", "Max protocol version supported by the node")
.unwrap()
});
static NODE_DB_VERSION: Lazy<IntGauge> = Lazy::new(|| {
try_create_int_gauge("near_node_db_version", "DB version used by the node").unwrap()
});
static NODE_BUILD_INFO: Lazy<IntCounterVec> = Lazy::new(|| {
try_create_int_counter_vec(
"near_build_info",
"Metric whose labels indicate node’s version; see \
<https://www.robustperception.io/exposing-the-software-version-to-prometheus>.",
&["release", "build", "rustc_version"],
)
.unwrap()
});

/// Exports neard, protocol and database versions via Prometheus metrics.
///
/// Defines and sets metrics which export node’s max supported protocol version,
/// used database version and build information. The latter is taken from
/// `neard_version` argument. This should be called only once at startup.
/// Subsequent calls don’t change exported values.
pub fn export_version(neard_version: &near_primitives::version::Version) {
NODE_PROTOCOL_VERSION.set(near_primitives::version::PROTOCOL_VERSION as i64);
NODE_DB_VERSION.set(near_primitives::version::DB_VERSION as i64);
NODE_BUILD_INFO.reset();
NODE_BUILD_INFO
.with_label_values(&[
&neard_version.version,
&neard_version.build,
&neard_version.rustc_version,
])
.inc();
}