feat(sentry): Include the commit hash in the release name
This commit is contained in:
parent
a28cfd284b
commit
c0b617f4f1
3 changed files with 23 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -907,6 +907,7 @@ dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"conduwuit_admin",
|
"conduwuit_admin",
|
||||||
"conduwuit_api",
|
"conduwuit_api",
|
||||||
|
"conduwuit_build_metadata",
|
||||||
"conduwuit_core",
|
"conduwuit_core",
|
||||||
"conduwuit_database",
|
"conduwuit_database",
|
||||||
"conduwuit_router",
|
"conduwuit_router",
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,7 @@ conduwuit-core.workspace = true
|
||||||
conduwuit-database.workspace = true
|
conduwuit-database.workspace = true
|
||||||
conduwuit-router.workspace = true
|
conduwuit-router.workspace = true
|
||||||
conduwuit-service.workspace = true
|
conduwuit-service.workspace = true
|
||||||
|
conduwuit-build-metadata.workspace = true
|
||||||
|
|
||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
console-subscriber.optional = true
|
console-subscriber.optional = true
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
#![cfg(feature = "sentry_telemetry")]
|
#![cfg(feature = "sentry_telemetry")]
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
borrow::Cow,
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
sync::{Arc, OnceLock},
|
sync::{Arc, OnceLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use conduwuit_build_metadata as build;
|
||||||
use conduwuit_core::{config::Config, debug, trace};
|
use conduwuit_core::{config::Config, debug, trace};
|
||||||
use sentry::{
|
use sentry::{
|
||||||
Breadcrumb, ClientOptions, Level,
|
Breadcrumb, ClientOptions, Level,
|
||||||
|
|
@ -44,7 +46,7 @@ fn options(config: &Config) -> ClientOptions {
|
||||||
server_name,
|
server_name,
|
||||||
traces_sample_rate: config.sentry_traces_sample_rate,
|
traces_sample_rate: config.sentry_traces_sample_rate,
|
||||||
debug: cfg!(debug_assertions),
|
debug: cfg!(debug_assertions),
|
||||||
release: sentry::release_name!(),
|
release: release_name(),
|
||||||
user_agent: conduwuit_core::version::user_agent().into(),
|
user_agent: conduwuit_core::version::user_agent().into(),
|
||||||
attach_stacktrace: config.sentry_attach_stacktrace,
|
attach_stacktrace: config.sentry_attach_stacktrace,
|
||||||
before_send: Some(Arc::new(before_send)),
|
before_send: Some(Arc::new(before_send)),
|
||||||
|
|
@ -91,3 +93,21 @@ fn before_breadcrumb(crumb: Breadcrumb) -> Option<Breadcrumb> {
|
||||||
trace!("Sentry breadcrumb: {crumb:?}");
|
trace!("Sentry breadcrumb: {crumb:?}");
|
||||||
Some(crumb)
|
Some(crumb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn release_name() -> Option<Cow<'static, str>> {
|
||||||
|
static RELEASE: OnceLock<Option<String>> = OnceLock::new();
|
||||||
|
|
||||||
|
RELEASE
|
||||||
|
.get_or_init(|| {
|
||||||
|
let pkg_name = env!("CARGO_PKG_NAME");
|
||||||
|
let pkg_version = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
|
if let Some(commit_short) = build::GIT_COMMIT_HASH_SHORT {
|
||||||
|
Some(format!("{pkg_name}@{pkg_version}+{commit_short}"))
|
||||||
|
} else {
|
||||||
|
Some(format!("{pkg_name}@{pkg_version}"))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.as_ref()
|
||||||
|
.map(|s| Cow::Borrowed(s.as_str()))
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue