Skip to content

Commit

Permalink
Ingest metrics with Sentry as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Feb 5, 2024
1 parent e92858f commit 4d321c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/symbolicator-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ moka = { version = "0.12.1", features = ["future", "sync"] }
once_cell = "1.17.1"
rand = "0.8.5"
reqwest = { version = "0.11.0", features = ["gzip", "brotli", "deflate", "json", "stream", "trust-dns"] }
sentry = { version = "0.32.1", features = ["tracing"] }
sentry = { version = "0.32.1", features = ["tracing", "UNSTABLE_metrics"] }
serde = { version = "1.0.137", features = ["derive", "rc"] }
serde_json = "1.0.81"
serde_yaml = "0.9.14"
Expand Down
18 changes: 18 additions & 0 deletions crates/symbolicator-service/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ macro_rules! metric {
$(.with_tag($k, $v))*
.send();
});
::sentry::metrics::Metric::incr($id.to_string(), $value as f64)
$(.with_tag($k, $v.to_string()))*
.send();
}};
(counter($id:expr) -= $value:expr $(, $k:expr => $v:expr)* $(,)?) => {{
use $crate::metrics::prelude::*;
Expand All @@ -66,6 +69,9 @@ macro_rules! metric {
$(.with_tag($k, $v))*
.send();
});
::sentry::metrics::Metric::incr($id, -$value as f64)
$(.with_tag($k, $v))*
.send();
}};

// gauges
Expand All @@ -77,6 +83,9 @@ macro_rules! metric {
$(.with_tag($k, $v))*
.send();
});
::sentry::metrics::Metric::gauge($id, $value as f64)
$(.with_tag($k, $v.to_string()))*
.send();
}};

// timers
Expand All @@ -88,6 +97,9 @@ macro_rules! metric {
$(.with_tag($k, $v))*
.send();
});
::sentry::metrics::Metric::timing($id.to_string(), $value)
$(.with_tag($k, $v.to_string()))*
.send();
}};

// we use statsd timers to send things such as filesizes as well.
Expand All @@ -99,6 +111,9 @@ macro_rules! metric {
$(.with_tag($k, $v))*
.send();
});
::sentry::metrics::Metric::distribution($id, $value as f64)
$(.with_tag($k, $v.to_string()))*
.send();
}};

// histograms
Expand All @@ -110,5 +125,8 @@ macro_rules! metric {
$(.with_tag($k, $v))*
.send();
});
::sentry::metrics::Metric::distribution($id.to_string(), $value as f64)
$(.with_tag($k, $v.to_string()))*
.send();
}};
}

0 comments on commit 4d321c1

Please sign in to comment.