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

Experimentally hook up statsdproxy #1384

Closed
wants to merge 1 commit into from
Closed
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
58 changes: 55 additions & 3 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion crates/symbolicator-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ aws-config = { version = "1.0.1", features = ["behavior-version-latest"] }
aws-credential-types = { version = "1.0.1", features = ["hardcoded-credentials"] }
aws-sdk-s3 = "1.4.0"
aws-types = "1.0.1"
cadence = "1.0.0"
cadence = "0.29.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to downgrade here? Because statsdproxy is still on the old version?

chrono = { version = "0.4.19", features = ["serde"] }
filetime = "0.2.16"
flate2 = "1.0.23"
Expand All @@ -34,6 +34,7 @@ serde = { version = "1.0.137", features = ["derive", "rc"] }
serde_json = "1.0.81"
serde_yaml = "0.9.14"
sha2 = "0.10.6"
statsdproxy = { version = "0.1.2", features = ["cadence-adapter"] }
symbolic = { version = "12.7.1", features = ["cfi", "common-serde", "debuginfo", "symcache"] }
symbolicator-sources = { path = "../symbolicator-sources" }
tempfile = "3.2.0"
Expand Down
25 changes: 19 additions & 6 deletions crates/symbolicator-service/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ use std::collections::BTreeMap;
use std::net::ToSocketAddrs;
use std::sync::OnceLock;

use cadence::{BufferedUdpMetricSink, QueuingMetricSink, StatsdClient};
use cadence::StatsdClient;
use statsdproxy::cadence::StatsdProxyMetricSink;
use statsdproxy::config::AggregateMetricsConfig;
use statsdproxy::middleware::aggregate::AggregateMetrics;
use statsdproxy::middleware::upstream::Upstream;

static METRICS_CLIENT: OnceLock<StatsdClient> = OnceLock::new();

Expand All @@ -18,11 +22,20 @@ pub fn configure_statsd<A: ToSocketAddrs>(prefix: &str, host: A, tags: BTreeMap<
if !addrs.is_empty() {
tracing::info!("Reporting metrics to statsd at {}", addrs[0]);
}
let socket = std::net::UdpSocket::bind("0.0.0.0:0").unwrap();
socket.set_nonblocking(true).unwrap();
let udp_sink = BufferedUdpMetricSink::from(&addrs[..], socket).unwrap();
let queuing_sink = QueuingMetricSink::from(udp_sink);
let mut builder = StatsdClient::builder(prefix, queuing_sink);
let aggregator_sink = StatsdProxyMetricSink::new(move || {
let next_step = Upstream::new(&addrs[..]).unwrap();

let config = AggregateMetricsConfig {
aggregate_counters: true,
aggregate_gauges: true,
flush_offset: 0,
flush_interval: 5,
max_map_size: None,
};
AggregateMetrics::new(config, next_step)
});

let mut builder = StatsdClient::builder(prefix, aggregator_sink);
for (key, value) in tags {
builder = builder.with_tag(key, value)
}
Expand Down
Loading