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 Jan 30, 2024
1 parent 60dec6f commit 805b729
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 @@ -56,6 +56,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 @@ -65,6 +68,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 @@ -76,6 +82,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 @@ -87,6 +96,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 @@ -98,6 +110,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 @@ -109,5 +124,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 805b729

Please sign in to comment.