mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-12-04 07:26:31 +00:00
refactor: drop unused cadence
metrics (#243)
This commit is contained in:
parent
c27c8ea184
commit
ab2a38efb2
4 changed files with 2 additions and 38 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -470,15 +470,6 @@ dependencies = [
|
|||
"bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cadence"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62fd689c825a93386a2ac05a46f88342c6df9ec3e79416f665650614e92e7475"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "camino"
|
||||
version = "1.1.9"
|
||||
|
@ -3575,7 +3566,6 @@ dependencies = [
|
|||
"actix-web-lab",
|
||||
"anyhow",
|
||||
"badge",
|
||||
"cadence",
|
||||
"crates-index",
|
||||
"derive_more 1.0.0",
|
||||
"dotenvy",
|
||||
|
|
|
@ -17,7 +17,6 @@ badge = { path = "./libs/badge" }
|
|||
actix-web = "4"
|
||||
actix-web-lab = "0.23"
|
||||
anyhow = "1"
|
||||
cadence = "1"
|
||||
crates-index = { version = "3", default-features = false, features = ["git"] }
|
||||
derive_more = { version = "1", features = ["display", "error", "from"] }
|
||||
dotenvy = "0.15"
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
use std::{
|
||||
collections::HashSet,
|
||||
panic::RefUnwindSafe,
|
||||
sync::{Arc, LazyLock},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use actix_web::dev::Service;
|
||||
use anyhow::{anyhow, Error};
|
||||
use cadence::{MetricSink, NopMetricSink, StatsdClient};
|
||||
use futures_util::{
|
||||
future::try_join_all,
|
||||
stream::{self, LocalBoxStream},
|
||||
|
@ -39,7 +37,6 @@ use self::fut::{analyze_dependencies, crawl_manifest};
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Engine {
|
||||
metrics: Arc<StatsdClient>,
|
||||
query_crate: Cache<QueryCrate, CrateName>,
|
||||
get_popular_crates: Cache<GetPopularCrates, ()>,
|
||||
get_popular_repos: Cache<GetPopularRepos, ()>,
|
||||
|
@ -49,8 +46,6 @@ pub struct Engine {
|
|||
|
||||
impl Engine {
|
||||
pub fn new(client: reqwest::Client, index: ManagedIndex) -> Engine {
|
||||
let metrics = Arc::new(StatsdClient::from_sink("engine", NopMetricSink));
|
||||
|
||||
let query_crate = Cache::new(QueryCrate::new(index), Duration::from_secs(10), 500);
|
||||
let get_popular_crates = Cache::new(
|
||||
GetPopularCrates::new(client.clone()),
|
||||
|
@ -70,7 +65,6 @@ impl Engine {
|
|||
);
|
||||
|
||||
Engine {
|
||||
metrics,
|
||||
query_crate,
|
||||
get_popular_crates,
|
||||
get_popular_repos,
|
||||
|
@ -78,10 +72,6 @@ impl Engine {
|
|||
fetch_advisory_db,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_metrics<M: MetricSink + Send + Sync + RefUnwindSafe + 'static>(&mut self, sink: M) {
|
||||
self.metrics = Arc::new(StatsdClient::from_sink("engine", sink));
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -1,18 +1,13 @@
|
|||
#![deny(rust_2018_idioms)]
|
||||
#![warn(missing_debug_implementations)]
|
||||
|
||||
use std::{
|
||||
env,
|
||||
net::{Ipv4Addr, UdpSocket},
|
||||
time::Duration,
|
||||
};
|
||||
use std::{env, net::Ipv4Addr, time::Duration};
|
||||
|
||||
use actix_web::{
|
||||
middleware::Logger,
|
||||
web::{self, ThinData},
|
||||
};
|
||||
use actix_web_lab::middleware::NormalizePath;
|
||||
use cadence::{QueuingMetricSink, UdpMetricSink};
|
||||
use reqwest::redirect::Policy as RedirectPolicy;
|
||||
|
||||
mod engine;
|
||||
|
@ -26,14 +21,6 @@ use self::{engine::Engine, utils::index::ManagedIndex};
|
|||
|
||||
const DEPS_RS_UA: &str = "deps.rs";
|
||||
|
||||
fn init_metrics() -> QueuingMetricSink {
|
||||
let socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
socket.set_nonblocking(true).unwrap();
|
||||
let host = ("127.0.0.1", 8125);
|
||||
let sink = UdpMetricSink::from(host, socket).unwrap();
|
||||
QueuingMetricSink::from(sink)
|
||||
}
|
||||
|
||||
fn init_tracing_subscriber() {
|
||||
use tracing::level_filters::LevelFilter;
|
||||
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
||||
|
@ -57,7 +44,6 @@ fn init_tracing_subscriber() {
|
|||
async fn main() {
|
||||
dotenvy::dotenv().ok();
|
||||
init_tracing_subscriber();
|
||||
let metrics = init_metrics();
|
||||
|
||||
let client = reqwest::Client::builder()
|
||||
.user_agent(DEPS_RS_UA)
|
||||
|
@ -81,8 +67,7 @@ async fn main() {
|
|||
});
|
||||
}
|
||||
|
||||
let mut engine = Engine::new(client.clone(), index);
|
||||
engine.set_metrics(metrics);
|
||||
let engine = Engine::new(client.clone(), index);
|
||||
|
||||
let server = actix_web::HttpServer::new(move || {
|
||||
actix_web::App::new()
|
||||
|
|
Loading…
Reference in a new issue