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

Metrics with service names #2908

Merged
merged 2 commits into from
Jan 6, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ jobs:
action: helm-deploy
chart_repo: https://charts.bitnami.com/bitnami
chart_name: postgresql
chart_version: 11.2.3
chart_version: 11.9.13
chart_set: |
--set=global.postgresql.auth.existingSecret=fog-recovery-postgresql
--set=global.postgresql.auth.database=fog_recovery
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion consensus/service/src/api/attested_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

//! Serves node-to-node attested gRPC requests.

use crate::SVC_COUNTERS;
use grpcio::{RpcContext, UnarySink};
use mc_attest_api::{attest::AuthMessage, attest_grpc::AttestedApi};
use mc_attest_enclave_api::{ClientSession, PeerSession, Session};
Expand All @@ -13,7 +14,6 @@ use mc_consensus_enclave::ConsensusEnclave;
use mc_util_grpc::{
check_request_chain_id, rpc_logger, rpc_permissions_error, send_result, Authenticator,
};
use mc_util_metrics::SVC_COUNTERS;
use std::sync::{Arc, Mutex};

#[derive(Clone)]
Expand Down
2 changes: 1 addition & 1 deletion consensus/service/src/api/blockchain_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

//! Serves blockchain-related API requests.

use crate::SVC_COUNTERS;
use grpcio::{RpcContext, RpcStatus, RpcStatusCode, UnarySink};
use mc_common::logger::{log, Logger};
use mc_consensus_api::{
Expand All @@ -13,7 +14,6 @@ use mc_consensus_api::{
use mc_ledger_db::Ledger;
use mc_transaction_core::{tokens::Mob, BlockVersion, FeeMap, Token};
use mc_util_grpc::{rpc_logger, send_result, Authenticator};
use mc_util_metrics::{self, SVC_COUNTERS};
use protobuf::RepeatedField;
use std::{cmp, collections::HashMap, sync::Arc};

Expand Down
2 changes: 1 addition & 1 deletion consensus/service/src/api/client_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
counters,
mint_tx_manager::MintTxManager,
tx_manager::{TxManager, TxManagerError},
SVC_COUNTERS,
};
use grpcio::{RpcContext, RpcStatus, UnarySink};
use mc_attest_api::attest::Message;
Expand All @@ -25,7 +26,6 @@ use mc_ledger_db::Ledger;
use mc_peers::ConsensusValue;
use mc_transaction_core::mint::{MintConfigTx, MintTx};
use mc_util_grpc::{check_request_chain_id, rpc_logger, send_result, Authenticator};
use mc_util_metrics::{self, SVC_COUNTERS};
use std::sync::Arc;

/// Maximum number of pending values for consensus service before rejecting
Expand Down
2 changes: 1 addition & 1 deletion consensus/service/src/api/peer_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
consensus_service::{IncomingConsensusMsg, ProposeTxCallback},
counters,
tx_manager::{TxManager, TxManagerError},
SVC_COUNTERS,
};
use grpcio::{RpcContext, RpcStatus, UnarySink};
use mc_attest_api::attest::Message;
Expand All @@ -32,7 +33,6 @@ use mc_transaction_core::tx::TxHash;
use mc_util_grpc::{
rpc_internal_error, rpc_invalid_arg_error, rpc_logger, rpc_permissions_error, send_result,
};
use mc_util_metrics::SVC_COUNTERS;
use mc_util_serial::deserialize;
use std::{str::FromStr, sync::Arc};

Expand Down
2 changes: 1 addition & 1 deletion consensus/service/src/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use mc_util_metrics::{
};

lazy_static::lazy_static! {
pub static ref OP_COUNTERS: OpMetrics = OpMetrics::new_and_registered("consensus_service");
pub static ref OP_COUNTERS: OpMetrics = OpMetrics::new_and_registered("consensus_scp");
pub static ref TX_VALIDATION_ERROR_COUNTER: TxValidationErrorMetrics = TxValidationErrorMetrics::new_and_registered();
pub static ref PENDING_VALUE_PROCESSING_TIME: Histogram = register_histogram!(
"pending_value_processing_time",
Expand Down
5 changes: 5 additions & 0 deletions consensus/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#[cfg(test)]
extern crate test;
use mc_util_metrics::ServiceMetrics;

pub mod consensus_service;
pub mod mint_tx_manager;
Expand All @@ -17,3 +18,7 @@ mod background_work_queue;
mod byzantine_ledger;
mod counters;
mod peer_keepalive;

lazy_static::lazy_static! {
pub static ref SVC_COUNTERS: ServiceMetrics = ServiceMetrics::new_and_registered("consensus_service");
}
3 changes: 1 addition & 2 deletions fog/ingest/server/src/attested_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

//! Serves node-to-node attested gRPC requests.

use crate::{controller::IngestController, error::IngestServiceError};
use crate::{controller::IngestController, error::IngestServiceError, SVC_COUNTERS};
use grpcio::{RpcContext, UnarySink};
use mc_attest_api::{attest::AuthMessage, attest_grpc::AttestedApi};
use mc_attest_net::RaClient;
use mc_common::logger::{log, Logger};
use mc_fog_recovery_db_iface::{RecoveryDb, ReportDb};
use mc_util_grpc::{rpc_logger, rpc_permissions_error, send_result};
use mc_util_metrics::SVC_COUNTERS;
use std::sync::Arc;

#[derive(Clone)]
Expand Down
3 changes: 1 addition & 2 deletions fog/ingest/server/src/ingest_peer_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//! Implement the ingest grpc API

use crate::{controller::IngestController, error::IngestServiceError};
use crate::{controller::IngestController, error::IngestServiceError, SVC_COUNTERS};
use grpcio::{RpcContext, RpcStatus, UnarySink};
use mc_attest_api::attest::Message;
use mc_attest_enclave_api::PeerSession;
Expand All @@ -20,7 +20,6 @@ use mc_util_grpc::{
rpc_internal_error, rpc_invalid_arg_error, rpc_logger, rpc_permissions_error,
rpc_precondition_error, send_result,
};
use mc_util_metrics::SVC_COUNTERS;
use std::{str::FromStr, sync::Arc};

/// Implements the Ingest Peer grpc api
Expand Down
2 changes: 1 addition & 1 deletion fog/ingest/server/src/ingest_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use crate::{
controller::IngestController,
error::{IngestServiceError as Error, PeerBackupError},
SVC_COUNTERS,
};
use grpcio::{RpcContext, RpcStatus, UnarySink};
use mc_api::external;
Expand All @@ -25,7 +26,6 @@ use mc_util_grpc::{
rpc_database_err, rpc_internal_error, rpc_invalid_arg_error, rpc_logger, rpc_permissions_error,
rpc_precondition_error, rpc_unavailable_error, send_result,
};
use mc_util_metrics::SVC_COUNTERS;
use protobuf::RepeatedField;
use std::{str::FromStr, sync::Arc};

Expand Down
6 changes: 6 additions & 0 deletions fog/ingest/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ mod worker;

use core::fmt::Display;
use itertools::Itertools;
use mc_util_metrics::ServiceMetrics;

lazy_static::lazy_static! {
/// Generates service metrics for tracking
pub static ref SVC_COUNTERS: ServiceMetrics = ServiceMetrics::new_and_registered("fog_ingest");
}

// Helper to format a sequence as a comma-separated list
// (This is used with lists of Ingest peer uris in logs,
Expand Down
2 changes: 1 addition & 1 deletion fog/ledger/server/src/block_service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2018-2022 The MobileCoin Foundation

use crate::SVC_COUNTERS;
use grpcio::{RpcContext, RpcStatus, UnarySink};
use mc_common::logger::{log, Logger};
use mc_fog_api::{
Expand All @@ -11,7 +12,6 @@ use mc_ledger_db::{self, Error as DbError, Ledger};
use mc_util_grpc::{
check_request_chain_id, rpc_database_err, rpc_logger, send_result, Authenticator,
};
use mc_util_metrics::SVC_COUNTERS;
use mc_watcher::watcher_db::WatcherDB;
use mc_watcher_api::TimestampResultCode;
use std::sync::Arc;
Expand Down
3 changes: 1 addition & 2 deletions fog/ledger/server/src/key_image_service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2018-2022 The MobileCoin Foundation
use crate::server::DbPollSharedState;
use crate::{server::DbPollSharedState, SVC_COUNTERS};
use grpcio::{RpcContext, RpcStatus, UnarySink};
use mc_attest_api::{
attest,
Expand All @@ -15,7 +15,6 @@ use mc_util_grpc::{
check_request_chain_id, rpc_internal_error, rpc_invalid_arg_error, rpc_logger,
rpc_permissions_error, send_result, Authenticator,
};
use mc_util_metrics::SVC_COUNTERS;
use mc_watcher::watcher_db::WatcherDB;
use std::sync::{Arc, Mutex};

Expand Down
6 changes: 6 additions & 0 deletions fog/ledger/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ mod merkle_proof_service;
mod server;
mod untrusted_tx_out_service;

use mc_util_metrics::ServiceMetrics;

pub use block_service::BlockService;
pub use config::LedgerServerConfig;
pub use key_image_service::KeyImageService;
pub use merkle_proof_service::MerkleProofService;
pub use server::LedgerServer;
pub use untrusted_tx_out_service::UntrustedTxOutService;

lazy_static::lazy_static! {
pub static ref SVC_COUNTERS: ServiceMetrics = ServiceMetrics::new_and_registered("fog_ledger");
}
2 changes: 1 addition & 1 deletion fog/ledger/server/src/merkle_proof_service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2018-2022 The MobileCoin Foundation

use crate::SVC_COUNTERS;
use grpcio::{RpcContext, RpcStatus, UnarySink};
use mc_attest_api::attest::{AuthMessage, Message};
use mc_attest_enclave_api::ClientSession;
Expand All @@ -14,7 +15,6 @@ use mc_util_grpc::{
check_request_chain_id, rpc_database_err, rpc_internal_error, rpc_invalid_arg_error,
rpc_logger, rpc_permissions_error, send_result, Authenticator,
};
use mc_util_metrics::SVC_COUNTERS;
use std::sync::Arc;

// Maximum number of TxOuts that may be returned for a single request.
Expand Down
2 changes: 1 addition & 1 deletion fog/ledger/server/src/untrusted_tx_out_service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2018-2022 The MobileCoin Foundation

use crate::SVC_COUNTERS;
use grpcio::{RpcContext, RpcStatus, UnarySink};
use mc_common::logger::{log, Logger};
use mc_crypto_keys::CompressedRistrettoPublic;
Expand All @@ -11,7 +12,6 @@ use mc_ledger_db::{self, Error as DbError, Ledger};
use mc_util_grpc::{
check_request_chain_id, rpc_internal_error, rpc_logger, send_result, Authenticator,
};
use mc_util_metrics::SVC_COUNTERS;
use mc_watcher::watcher_db::WatcherDB;
use mc_watcher_api::TimestampResultCode;
use std::sync::Arc;
Expand Down
1 change: 1 addition & 0 deletions fog/report/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ clap = { version = "4.0", features = ["derive", "env"] }
displaydoc = "0.2"
futures = "0.3"
grpcio = "0.12.0"
lazy_static = "1.4"
pem = "1.1"
prost = "0.11"
serde = { version = "1.0", features = ["derive"] }
Expand Down
7 changes: 7 additions & 0 deletions fog/report/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ pub use crate::{
config::{Config, Error, Materials},
server::Server,
};

use mc_util_metrics::ServiceMetrics;

lazy_static::lazy_static! {
/// Generates service metrics for tracking
pub static ref SVC_COUNTERS: ServiceMetrics = ServiceMetrics::new_and_registered("fog_report");
}
4 changes: 1 addition & 3 deletions fog/report/server/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//! Implementation of the ReportService

use crate::config::Materials;
pub use crate::{config::Materials, SVC_COUNTERS};
use displaydoc::Display;
use grpcio::{RpcContext, RpcStatus, UnarySink};
use mc_common::logger::{self, log, Logger};
Expand All @@ -16,10 +16,8 @@ use mc_fog_sig_report::Signer as ReportSigner;
use mc_util_grpc::{
check_request_chain_id, rpc_database_err, rpc_internal_error, rpc_logger, send_result,
};
use mc_util_metrics::SVC_COUNTERS;
use prost::DecodeError;
use signature::{Error as SignatureError, Signature};

#[derive(Clone)]
pub struct Service<R: ReportDb + Clone + Send + Sync> {
/// Access to the Report db is needed to retrieve the ingest report for
Expand Down
3 changes: 1 addition & 2 deletions fog/view/server/src/fog_view_service.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2018-2022 The MobileCoin Foundation

use crate::{config::MobileAcctViewConfig, server::DbPollSharedState};
use crate::{config::MobileAcctViewConfig, server::DbPollSharedState, SVC_COUNTERS};
use grpcio::{RpcContext, RpcStatus, RpcStatusCode, UnarySink};
use mc_attest_api::attest;
use mc_common::logger::{log, Logger};
Expand All @@ -13,7 +13,6 @@ use mc_util_grpc::{
check_request_chain_id, rpc_internal_error, rpc_invalid_arg_error, rpc_logger,
rpc_permissions_error, send_result, Authenticator,
};
use mc_util_metrics::SVC_COUNTERS;
use mc_util_telemetry::{tracer, Tracer};
use std::sync::{Arc, Mutex};

Expand Down
5 changes: 5 additions & 0 deletions fog/view/server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2018-2022 The MobileCoin Foundation

//! MobileCoin Fog View target
use mc_util_metrics::ServiceMetrics;

pub mod config;
pub mod error;
Expand All @@ -10,3 +11,7 @@ pub mod server;
mod block_tracker;
mod counters;
mod db_fetcher;

lazy_static::lazy_static! {
pub static ref SVC_COUNTERS: ServiceMetrics = ServiceMetrics::new_and_registered("fog_view");
}
1 change: 1 addition & 0 deletions go-grpc-gateway/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mc-util-uri = { path = "../../util/uri" }

# fog
mc-fog-report-api = { path = "../../fog/report/api" }
mc-fog-report-server = { path = "../../fog/report/server" }
mc-fog-report-types = { path = "../../fog/report/types" }

# third-party
Expand Down
2 changes: 1 addition & 1 deletion go-grpc-gateway/testing/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use mc_fog_report_api::{
report::{ReportRequest as ProtobufReportRequest, ReportResponse as ProtobufReportResponse},
report_grpc::ReportApi,
};
use mc_fog_report_server::SVC_COUNTERS;
use mc_fog_report_types::ReportResponse;
use mc_util_grpc::{check_request_chain_id, rpc_logger, send_result};
use mc_util_metrics::SVC_COUNTERS;

#[derive(Clone)]
pub struct Service {
Expand Down
3 changes: 1 addition & 2 deletions util/grpc/src/admin_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ use crate::{
admin_grpc::{create_admin_api, AdminApi},
build_info_service::get_build_info,
empty::Empty,
rpc_logger, send_result,
rpc_logger, send_result, SVC_COUNTERS,
};
use grpcio::{RpcContext, RpcStatus, RpcStatusCode, Service, UnarySink};
use mc_common::logger::{log, Logger};
use mc_util_metrics::SVC_COUNTERS;
use prometheus::{self, Encoder};
use std::{env, sync::Arc};

Expand Down
3 changes: 1 addition & 2 deletions util/grpc/src/build_info_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ use crate::{
build_info::BuildInfo,
build_info_grpc::{create_build_info_api, BuildInfoApi},
empty::Empty,
rpc_logger, send_result,
rpc_logger, send_result, SVC_COUNTERS,
};
use grpcio::{RpcContext, Service, UnarySink};
use mc_common::logger::Logger;
use mc_util_metrics::SVC_COUNTERS;

/// A service that exposes the BuildInfo of a service recorded using
/// mc_util_build_info
Expand Down
3 changes: 1 addition & 2 deletions util/grpc/src/health_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ use crate::{
PingResponse,
},
health_api_grpc::{create_health, Health},
rpc_logger, send_result,
rpc_logger, send_result, SVC_COUNTERS,
};
use futures::prelude::*;
use grpcio::{RpcContext, RpcStatus, RpcStatusCode, ServerStreamingSink, Service, UnarySink};
use mc_common::logger::{log, Logger};
use mc_util_metrics::SVC_COUNTERS;
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
Expand Down
Loading