Skip to content
Merged
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
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion engine/packages/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ edition.workspace = true
anyhow.workspace = true
rivet-config.workspace = true
sentry.workspace = true
serde_json.workspace = true
uuid.workspace = true
46 changes: 32 additions & 14 deletions engine/packages/telemetry/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rivet_config::config::{CacheDriver, Database, PubSub};
use uuid::Uuid;

const SENTRY_URL: &str = "https://7602663e43cb9dee8c42d1e5e70293f8@o4504307129188352.ingest.us.sentry.io/4509962797252608";
Expand All @@ -16,24 +17,41 @@ pub fn init(config: &rivet_config::Config) -> Option<sentry::ClientInitGuard> {
},
));

sentry::configure_scope(|scope| {
if let Ok(db) = serde_json::to_string(config.database()) {
scope.set_tag("database", db);
}
if let Ok(ps) = serde_json::to_string(config.pubsub()) {
scope.set_tag("pubsub", ps);
}
if let Ok(cache) = serde_json::to_string(config.cache()) {
scope.set_tag("cache", cache);
}
if let Ok(topo) = serde_json::to_string(config.topology()) {
scope.set_tag("topology", topo);
}
});
sentry::configure_scope(|scope| configure_scope(scope, config));

Some(guard)
}

fn configure_scope(scope: &mut sentry::Scope, config: &rivet_config::Config) {
// Only send fixed, allowlisted labels. Config serialization preserves secrets, and
// even ordinary strings (such as server URLs) can contain credentials.
scope.set_tag(
"database",
match config.database() {
Database::Postgres(_) => "postgres",
Database::FileSystem(_) => "file_system",
},
);
scope.set_tag(
"pubsub",
match config.pubsub() {
PubSub::Nats(_) => "nats",
PubSub::Memory(_) => "memory",
},
);
let cache = config.cache();
scope.set_tag(
"cache",
if cache.enabled {
match cache.driver() {
CacheDriver::InMemory => "in_memory",
}
} else {
"disabled"
},
);
}

pub fn capture_error(err: &anyhow::Error) -> Uuid {
sentry::integrations::anyhow::capture_anyhow(err)
}
Loading