Skip to content

Commit

Permalink
Remove old metric dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
akoshelev committed Oct 10, 2024
1 parent 5211ad6 commit 68b30d6
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 208 deletions.
3 changes: 0 additions & 3 deletions ipa-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ hyper-util = { version = "0.1.3", optional = true, features = ["http2"] }
http-body-util = { version = "0.1.1", optional = true }
http-body = { version = "1", optional = true }
iai = { version = "0.1.1", optional = true }
metrics = "0.21.0"
metrics-tracing-context = "0.14.0"
metrics-util = { version = "0.15.0" }
once_cell = "1.18"
pin-project = "1.0"
rand = "0.8"
Expand Down
47 changes: 0 additions & 47 deletions ipa-core/src/cli/metric_collector.rs

This file was deleted.

2 changes: 0 additions & 2 deletions ipa-core/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mod csv;
mod ipa_output;
#[cfg(feature = "web-app")]
mod keygen;
mod metric_collector;
mod paths;
#[cfg(all(feature = "test-fixture", feature = "web-app", feature = "cli"))]
pub mod playbook;
Expand All @@ -19,7 +18,6 @@ pub use csv::Serializer as CsvSerializer;
pub use ipa_output::QueryResult as IpaQueryResult;
#[cfg(feature = "web-app")]
pub use keygen::{keygen, KeygenArgs};
pub use metric_collector::{install_collector, CollectorHandle};
pub use paths::PathExt as CliPaths;
#[cfg(feature = "web-app")]
pub use test_setup::{test_setup, TestSetupArgs};
Expand Down
12 changes: 2 additions & 10 deletions ipa-core/src/cli/verbosity.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use std::io::{stderr, IsTerminal};

use clap::Parser;
use metrics_tracing_context::MetricsLayer;
use tracing::{info, metadata::LevelFilter, Level};
use tracing_subscriber::{
fmt, fmt::format::FmtSpan, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter,
};

use crate::{
cli::{install_collector, metric_collector::CollectorHandle},
error::set_global_panic_hook,
};

Expand All @@ -23,10 +21,7 @@ pub struct Verbosity {
verbose: u8,
}

pub struct LoggingHandle {
#[allow(dead_code)] // we care about handle's drop semantic so it is ok to not read it
metrics_handle: Option<CollectorHandle>,
}
pub struct LoggingHandle;

impl Verbosity {
#[must_use]
Expand All @@ -42,14 +37,11 @@ impl Verbosity {
.with(fmt_layer)
.init();

let handle = LoggingHandle {
metrics_handle: None
};
set_global_panic_hook();

info!("Logging setup at level {}", filter_layer);

handle
LoggingHandle
}

fn log_filter(&self) -> EnvFilter {
Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::{
convert::Infallible,
fmt::{Debug, Display, Formatter, Write},
fmt::{Debug, Display, Formatter},
num::NonZeroUsize,
};

Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/net/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use futures::{
future::{ready, BoxFuture, Either, Ready},
Future, FutureExt,
};
use hyper::{body::Incoming, header::HeaderName, Request, Version};
use hyper::{body::Incoming, header::HeaderName, Request};
use rustls::{server::WebPkiClientVerifier, RootCertStore};
use rustls_pki_types::CertificateDer;
#[cfg(all(feature = "shuttle", test))]
Expand Down
72 changes: 0 additions & 72 deletions ipa-core/src/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub mod labels {
}

pub mod metrics {
use metrics::{describe_counter, Unit};

pub const REQUESTS_RECEIVED: &str = "requests.received";
pub const RECORDS_SENT: &str = "records.sent";
Expand All @@ -22,7 +21,6 @@ pub mod metrics {
#[cfg(feature = "web-app")]
pub mod web {
use axum::http::Version;
use metrics::KeyName;

/// Metric that records the version of HTTP protocol used for a particular request.
pub struct RequestProtocolVersion(Version);
Expand All @@ -48,75 +46,5 @@ pub mod metrics {
RequestProtocolVersion(v)
}
}

impl From<RequestProtocolVersion> for KeyName {
fn from(v: RequestProtocolVersion) -> Self {
KeyName::from(<&'static str>::from(v))
}
}
}

/// Registers metrics used in the system with the metrics recorder.
///
/// ## Panics
/// Panic if there is no recorder installed
pub fn register() {
describe_counter!(
REQUESTS_RECEIVED,
Unit::Count,
"Total number of requests received by the web server"
);

#[cfg(feature = "web-app")]
{
use axum::http::Version;
describe_counter!(
web::RequestProtocolVersion::from(Version::HTTP_11),
Unit::Count,
"Total number of HTTP/1.1 requests received"
);

describe_counter!(
web::RequestProtocolVersion::from(Version::HTTP_2),
Unit::Count,
"Total number of HTTP/2 requests received"
);
}

describe_counter!(
RECORDS_SENT,
Unit::Count,
"Number of unique records sent from the infrastructure layer to the network"
);

describe_counter!(
BYTES_SENT,
Unit::Count,
"Bytes sent from the infrastructure layer to the network"
);

describe_counter!(
INDEXED_PRSS_GENERATED,
Unit::Count,
"Number of times shared randomness is requested by the protocols"
);

describe_counter!(
SEQUENTIAL_PRSS_GENERATED,
Unit::Count,
"Number of times PRSS is used as CPRNG to generate a random value"
);

describe_counter!(
STEP_NARROWED,
Unit::Count,
"Number of times the step is narrowed"
);

describe_counter!(
DZKP_BATCH_INCREMENTS,
Unit::Count,
"Number of DZKP Batch updates, i.e. verifications"
);
}
}
Loading

0 comments on commit 68b30d6

Please sign in to comment.