Skip to content

Commit

Permalink
Cleanup old metrics (#13129)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtso authored May 15, 2024
1 parent ea1d63b commit abeaf7f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 136 deletions.
39 changes: 1 addition & 38 deletions ecosystem/indexer-grpc/indexer-grpc-cache-worker/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,10 @@
// SPDX-License-Identifier: Apache-2.0

use aptos_metrics_core::{
register_gauge, register_int_counter, register_int_counter_vec, register_int_gauge, Gauge,
IntCounter, IntCounterVec, IntGauge,
register_int_counter, register_int_counter_vec, IntCounter, IntCounterVec,
};
use once_cell::sync::Lazy;

/// Latest processed transaction version.
pub static LATEST_PROCESSED_VERSION: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"indexer_grpc_cache_worker_latest_processed_version",
"Latest processed transaction version",
)
.unwrap()
});

/// Number of transactions that saved into cache.
pub static PROCESSED_VERSIONS_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"indexer_grpc_cache_worker_processed_versions",
"Number of transactions that have been processed by cache worker",
)
.unwrap()
});

/// Number of errors that cache worker has encountered.
pub static ERROR_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
Expand All @@ -35,24 +16,6 @@ pub static ERROR_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
.unwrap()
});

/// Data latency for cache worker based on latest processed transaction.
pub static PROCESSED_LATENCY_IN_SECS: Lazy<Gauge> = Lazy::new(|| {
register_gauge!(
"indexer_grpc_cache_worker_data_latency_in_secs",
"Latency of cache worker based on latest processed transaction",
)
.unwrap()
});

/// Number of transactions in each batch that cache worker has processed.
pub static PROCESSED_BATCH_SIZE: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"indexer_grpc_cache_worker_processed_batch_size",
"Size of latest processed batch by cache worker",
)
.unwrap()
});

/// Number of waits that cache worker has encountered for file store.
pub static WAIT_FOR_FILE_STORE_COUNTER: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

use crate::metrics::{
ERROR_COUNT, LATEST_PROCESSED_VERSION as LATEST_PROCESSED_VERSION_OLD, PROCESSED_BATCH_SIZE,
PROCESSED_VERSIONS_COUNT, WAIT_FOR_FILE_STORE_COUNTER,
};
use crate::metrics::{ERROR_COUNT, WAIT_FOR_FILE_STORE_COUNTER};
use anyhow::{bail, Context, Result};
use aptos_indexer_grpc_utils::{
cache_operator::CacheOperator,
Expand Down Expand Up @@ -403,10 +400,6 @@ async fn process_streaming_response(
transaction_count += num_of_transactions;
tps_calculator.tick_now(num_of_transactions);

PROCESSED_VERSIONS_COUNT.inc_by(num_of_transactions);
// TODO: Reasses whether this metric useful
LATEST_PROCESSED_VERSION_OLD.set(current_version as i64);
PROCESSED_BATCH_SIZE.set(num_of_transactions as i64);
tasks_to_run.push(task);
},
GrpcDataStatus::StreamInit(new_version) => {
Expand Down
30 changes: 5 additions & 25 deletions ecosystem/indexer-grpc/indexer-grpc-data-service/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// SPDX-License-Identifier: Apache-2.0

use aptos_metrics_core::{
register_gauge_vec, register_histogram_vec, register_int_counter_vec, register_int_gauge_vec,
GaugeVec, HistogramVec, IntCounterVec, IntGaugeVec,
register_gauge_vec, register_int_counter_vec, register_int_gauge_vec, GaugeVec, IntCounterVec,
IntGaugeVec,
};
use once_cell::sync::Lazy;

// The `identifier` label at the time of writing (2024-04-08) is always the
// application ID, a globally unique ID.

/// Latest processed transaction version.
pub static LATEST_PROCESSED_VERSION: Lazy<IntGaugeVec> = Lazy::new(|| {
pub static LATEST_PROCESSED_VERSION_PER_PROCESSOR: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
"indexer_grpc_data_service_with_user_latest_processed_version",
"Latest processed transaction version",
Expand All @@ -21,7 +21,7 @@ pub static LATEST_PROCESSED_VERSION: Lazy<IntGaugeVec> = Lazy::new(|| {
});

/// Number of transactions that served by data service.
pub static PROCESSED_VERSIONS_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
pub static PROCESSED_VERSIONS_COUNT_PER_PROCESSOR: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"indexer_grpc_data_service_with_user_processed_versions",
"Number of transactions that have been processed by data service",
Expand All @@ -41,7 +41,7 @@ pub static ERROR_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
});

/// Data latency for data service based on latest processed transaction based on selected processor.
pub static PROCESSED_LATENCY_IN_SECS: Lazy<GaugeVec> = Lazy::new(|| {
pub static PROCESSED_LATENCY_IN_SECS_PER_PROCESSOR: Lazy<GaugeVec> = Lazy::new(|| {
register_gauge_vec!(
"indexer_grpc_data_service_with_user_latest_data_latency_in_secs",
"Latency of data service based on latest processed transaction",
Expand All @@ -50,26 +50,6 @@ pub static PROCESSED_LATENCY_IN_SECS: Lazy<GaugeVec> = Lazy::new(|| {
.unwrap()
});

/// Data latency for data service based on latest processed transaction for all processors.
pub static PROCESSED_LATENCY_IN_SECS_ALL: Lazy<HistogramVec> = Lazy::new(|| {
register_histogram_vec!(
"indexer_grpc_data_service_latest_data_latency_in_secs_all",
"Latency of data service based on latest processed transaction",
&[]
)
.unwrap()
});

/// Number of transactions in each batch that data service has processed.
pub static PROCESSED_BATCH_SIZE: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
"indexer_grpc_data_service_with_user_processed_batch_size",
"Size of latest processed batch by data service",
&["identifier", "processor"],
)
.unwrap()
});

/// Count of connections that data service has established.
pub static CONNECTION_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
Expand Down
20 changes: 5 additions & 15 deletions ecosystem/indexer-grpc/indexer-grpc-data-service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

use crate::metrics::{
BYTES_READY_TO_TRANSFER_FROM_SERVER, CONNECTION_COUNT, ERROR_COUNT,
LATEST_PROCESSED_VERSION as LATEST_PROCESSED_VERSION_OLD, PROCESSED_BATCH_SIZE,
PROCESSED_LATENCY_IN_SECS, PROCESSED_LATENCY_IN_SECS_ALL, PROCESSED_VERSIONS_COUNT,
SHORT_CONNECTION_COUNT,
LATEST_PROCESSED_VERSION_PER_PROCESSOR, PROCESSED_LATENCY_IN_SECS_PER_PROCESSOR,
PROCESSED_VERSIONS_COUNT_PER_PROCESSOR, SHORT_CONNECTION_COUNT,
};
use anyhow::{Context, Result};
use aptos_indexer_grpc_utils::{
Expand Down Expand Up @@ -535,35 +534,26 @@ async fn data_fetcher_task(
.await
{
Ok(_) => {
PROCESSED_BATCH_SIZE
.with_label_values(&[
request_metadata.request_identifier.as_str(),
request_metadata.processor_name.as_str(),
])
.set(current_batch_size as i64);
// TODO: Reasses whether this metric useful
LATEST_PROCESSED_VERSION_OLD
LATEST_PROCESSED_VERSION_PER_PROCESSOR
.with_label_values(&[
request_metadata.request_identifier.as_str(),
request_metadata.processor_name.as_str(),
])
.set(end_of_batch_version as i64);
PROCESSED_VERSIONS_COUNT
PROCESSED_VERSIONS_COUNT_PER_PROCESSOR
.with_label_values(&[
request_metadata.request_identifier.as_str(),
request_metadata.processor_name.as_str(),
])
.inc_by(current_batch_size as u64);
if let Some(data_latency_in_secs) = data_latency_in_secs {
PROCESSED_LATENCY_IN_SECS
PROCESSED_LATENCY_IN_SECS_PER_PROCESSOR
.with_label_values(&[
request_metadata.request_identifier.as_str(),
request_metadata.processor_name.as_str(),
])
.set(data_latency_in_secs);
PROCESSED_LATENCY_IN_SECS_ALL
.with_label_values(&[])
.observe(data_latency_in_secs);
}
},
Err(SendTimeoutError::Timeout(_)) => {
Expand Down
20 changes: 1 addition & 19 deletions ecosystem/indexer-grpc/indexer-grpc-file-store/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

use aptos_metrics_core::{register_int_counter, register_int_gauge, IntCounter, IntGauge};
use aptos_metrics_core::{register_int_counter, IntCounter};
use once_cell::sync::Lazy;

/// Latest version of transactions that have been stored.
pub static LATEST_PROCESSED_VERSION: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"indexer_grpc_file_store_latest_processed_version",
"Latest version of transactions that have been stored",
)
.unwrap()
});

/// Number of transactions that have been stored.
pub static PROCESSED_VERSIONS_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
Expand All @@ -22,15 +13,6 @@ pub static PROCESSED_VERSIONS_COUNT: Lazy<IntCounter> = Lazy::new(|| {
.unwrap()
});

/// Number of errors that file store has encountered.
pub static ERROR_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"indexer_grpc_file_store_errors",
"Number of errors that file store has encountered"
)
.unwrap()
});

/// Number of metadata upload failures that file store has encountered.
pub static METADATA_UPLOAD_FAILURE_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
Expand Down
30 changes: 1 addition & 29 deletions ecosystem/indexer-grpc/indexer-grpc-fullnode/src/counters.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
// Copyright © Aptos Foundation
// SPDX-License-Identifier: Apache-2.0

use aptos_metrics_core::{
register_gauge, register_int_counter, register_int_gauge_vec, Gauge, IntCounter, IntGaugeVec,
};
use aptos_metrics_core::{register_int_counter, register_int_gauge_vec, IntCounter, IntGaugeVec};
use once_cell::sync::Lazy;

pub static TRANSACTIONS_STREAMED: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"indexer_grpc_transactions_streamed_count",
"Transaction streamed via GRPC",
)
.unwrap()
});

/// Number of times the indexer has been unable to fetch a transaction. Ideally zero.
pub static UNABLE_TO_FETCH_TRANSACTION: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
Expand All @@ -23,24 +13,6 @@ pub static UNABLE_TO_FETCH_TRANSACTION: Lazy<IntCounter> = Lazy::new(|| {
.unwrap()
});

/// Number of times the indexer has been able to fetch a transaction
pub static FETCHED_TRANSACTION: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"indexer_grpc_fetched_transaction_count",
"Number of times the indexer has been able to fetch a transaction from storage"
)
.unwrap()
});

/// Data latency for fullnode fetched the data from storage.
pub static FETCHED_LATENCY_IN_SECS: Lazy<Gauge> = Lazy::new(|| {
register_gauge!(
"indexer_grpc_fullnode_fetched_data_latency_in_secs",
"Latency of fullnode fetched the data from storage",
)
.unwrap()
});

/// Channel size
pub static CHANNEL_SIZE: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::{
convert::convert_transaction,
counters::{FETCHED_TRANSACTION, UNABLE_TO_FETCH_TRANSACTION},
counters::UNABLE_TO_FETCH_TRANSACTION,
runtime::{DEFAULT_NUM_RETRIES, RETRY_TIME_MILLIS},
};
use aptos_api::context::Context;
Expand Down Expand Up @@ -449,7 +449,6 @@ impl IndexerStreamCoordinator {
"[Indexer Fullnode] Successfully converted transactions",
);

FETCHED_TRANSACTION.inc();
transactions
}

Expand Down

0 comments on commit abeaf7f

Please sign in to comment.