Skip to content

Commit

Permalink
remove some comments and old lib
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanda committed May 23, 2023
1 parent 62c4e1f commit 118a232
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 28 deletions.
11 changes: 11 additions & 0 deletions rust_snuba/Cargo.lock

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

3 changes: 1 addition & 2 deletions rust_snuba/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ pyo3 = { version = "0.18.1", features = ["chrono", "extension-module"] }
ctrlc = "3.2.5"
sentry = "0.31.0"

# these are unofficial libs. haven't validated them yet
# unofficial lib. haven't validated it yet
dogstatsd = "0.8.0"
cadence = "0.29.0"

lazy_static = "1.4.0"
9 changes: 2 additions & 7 deletions rust_snuba/rust_arroyo/src/utils/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,11 @@ mod tests {
fn test_metrics() {
init("my_host", "0.0.0.0:8125");

assert!(!METRICS_CLIENT
.read()
.clone()
.unwrap()
.should_sample(Some(0.0)),);
assert!(METRICS_CLIENT
.read()
.clone()
.unwrap()
.should_sample(Some(1.0)),);
.is_some()
);

increment(
"a",
Expand Down
5 changes: 0 additions & 5 deletions rust_snuba/src/utils/metrics/backends/abstract_backend.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use rust_arroyo::utils::metrics::MetricsClientTrait;

pub trait MetricsBackend: MetricsClientTrait {
// fn increment(&self, name: &str, value: i64, tags: &[&str]);
// fn gauge(&self, name: &str, value: f64, tags: &[&str]);
// fn timing(&self, name: &str, value: i64, tags: &[&str]);
fn events(
&self,
title: &str,
Expand All @@ -12,6 +9,4 @@ pub trait MetricsBackend: MetricsClientTrait {
priority: &str,
tags: &[&str],
);
// fn counter(&self, name: &str, value: f64, tags: &[&str]) -> Result<(), Error>;
// fn histogram(&self, name: &str, value: f64, tags: &[&str]) -> Result<(), Error>;
}
8 changes: 3 additions & 5 deletions rust_snuba/src/utils/metrics/backends/datadog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,12 @@ mod tests {

#[test]
fn test_testing_backend() {

let custom_options = Options::new("0.0.0.0:9000", "0.0.0.0:8125", "analytics", vec!(String::new()));
// let client = dogstatsd::Client::new(dogstatsd::Options::default()).unwrap();
let client = dogstatsd::Client::new(custom_options).unwrap();
// default client sends metrics to statsd daemon on localhost:8125
let client = dogstatsd::Client::new(dogstatsd::Options::default()).unwrap();
let client_tags: Vec<String> = Vec::new();
let testing_backend = DatadogMetricsBackend {
client_sd: client,
tags: client_tag
tags: client_tags
};

let mut tags: HashMap<&str, &str> = HashMap::new();
Expand Down
13 changes: 6 additions & 7 deletions rust_snuba/src/utils/metrics/backends/testing.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
use std::{collections::HashMap, sync::{Arc, Mutex}};
use std::{collections::HashMap, sync::{Mutex}};

use rust_arroyo::utils::metrics::MetricsClientTrait;

use super::abstract_backend::MetricsBackend;
use lazy_static::lazy_static;

lazy_static! {
// static ref METRICS_CLIENT: RwLock<Option<Arc<dyn MetricsClientTrait>>> = RwLock::new(None);
static ref METRICS: Mutex<HashMap<String, Vec<MetricCall>>> = {
let mut m = HashMap::new();
let m = HashMap::new();
Mutex::new(m)
};
}
// static METRICS: Arc<HashMap<String, Vec<MetricCall>>> = Arc::new(HashMap::new());


pub struct MetricCall {
value: String,
tags: Vec<String>,
}

pub struct TestingMetricsBackend {
}

Expand All @@ -36,7 +35,7 @@ impl MetricsBackend for TestingMetricsBackend {
}

impl MetricsClientTrait for TestingMetricsBackend{
fn counter(&self, name: &str, value: Option<i64>, tags: Option<HashMap<&str, &str>>, sample_rate: Option<f64>) {
fn counter(&self, name: &str, value: Option<i64>, tags: Option<HashMap<&str, &str>>, _sample_rate: Option<f64>) {
let mut tags_vec = Vec::new();
if let Some(tags) = tags {
for (k, v) in tags {
Expand All @@ -51,7 +50,7 @@ impl MetricsClientTrait for TestingMetricsBackend{
});
}

fn gauge(&self, name: &str, value: u64, tags: Option<HashMap<&str, &str>>, sample_rate: Option<f64>) {
fn gauge(&self, name: &str, value: u64, tags: Option<HashMap<&str, &str>>, _sample_rate: Option<f64>) {
let mut tags_vec = Vec::new();
if let Some(tags) = tags {
for (k, v) in tags {
Expand All @@ -67,7 +66,7 @@ impl MetricsClientTrait for TestingMetricsBackend{
});
}

fn time(&self, name: &str, value: u64, tags: Option<HashMap<&str, &str>>, sample_rate: Option<f64>) {
fn time(&self, name: &str, value: u64, tags: Option<HashMap<&str, &str>>, _sample_rate: Option<f64>) {
let mut tags_vec = Vec::new();
if let Some(tags) = tags {
for (k, v) in tags {
Expand Down
2 changes: 0 additions & 2 deletions rust_snuba/src/utils/metrics/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pub mod metrics;
pub mod backends;
pub mod metrics_wrapper;

0 comments on commit 118a232

Please sign in to comment.