Skip to content

Commit

Permalink
Merge pull request #16 from svanill/better-sentry-integration
Browse files Browse the repository at this point in the history
Update Sentry and setup instrumentations
  • Loading branch information
riquito authored Mar 29, 2022
2 parents 15fe9f1 + 994ec6c commit ceec550
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 77 deletions.
66 changes: 49 additions & 17 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions svanill-vault-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "svanill-vault-server"
description = "svanill-vault, the server"
version = "0.4.2"
version = "0.5.0"
authors = ["Riccardo Attilio Galli <[email protected]>"]
repository = "https://github.com/svanill/svanill-vault-server"
edition = "2018"
edition = "2021"
license = "AGPL-3.0-or-later"
readme = "README.md"

Expand Down Expand Up @@ -42,11 +42,12 @@ diesel_migrations = "1.4.0"
reqwest = { version = "0.11.6", default-features = false, features = ["blocking", "gzip", "multipart", "json", "rustls-tls", "rustls-tls-webpki-roots"] }
hyper = { version = "0.14.14", features = ["full"] }
hyper-rustls = { version = "0.22.1", features = ["webpki-roots"] }
sentry-actix = "0.25.0"

[dependencies.sentry]
version = "0.23.0"
version = "0.25.0"
default-features = false
features = ["rustls", "backtrace", "contexts", "panic", "reqwest"]
features = ["rustls", "backtrace", "contexts", "panic", "reqwest", "tracing"]

[dev-dependencies]
tokio = "1.13.1"
Expand Down
4 changes: 4 additions & 0 deletions svanill-vault-server/src/bin/svanill-vault-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ async fn main() -> Result<()> {
release: Some(format!("svanill-vault-server@{}", std::env!("GIT_HASH")).into()),
attach_stacktrace: true,
in_app_include: vec!["svanill"],
session_mode: sentry::SessionMode::Request,
auto_session_tracking: true,
sample_rate: 1.0,
traces_sample_rate: 1.0,
..Default::default()
});

Expand Down
2 changes: 1 addition & 1 deletion svanill-vault-server/src/file_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl FileServer {
.unwrap_or_default()
.into_iter()
.filter(|x| x.key.is_some())
.map(|obj| async {
.map(|obj| async move {
let key = obj.key.unwrap(); // always ok, we filtered for Some(key) only
let size = obj.size.unwrap_or_default();

Expand Down
1 change: 0 additions & 1 deletion svanill-vault-server/src/http/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
mod auth_middleware;
pub mod handlers;
pub mod sentry_middleware;
48 changes: 0 additions & 48 deletions svanill-vault-server/src/http/sentry_middleware.rs

This file was deleted.

7 changes: 1 addition & 6 deletions svanill-vault-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use actix_web::{http, web, App, HttpServer};
use crate::auth::tokens_cache::TokensCache;
use crate::file_server::FileServer;
use crate::http::handlers::{config_handlers, render_40x, render_500};
use crate::http::sentry_middleware::enrich_sentry_event_with_request_metadata;
use actix_web::dev::Service;
use diesel::{
r2d2::{self, ConnectionManager},
SqliteConnection,
Expand Down Expand Up @@ -58,10 +56,7 @@ pub fn run(listener: TcpListener, data: AppData) -> Result<Server, std::io::Erro
.wrap(ErrorHandlers::new().handler(http::StatusCode::BAD_REQUEST, render_40x))
.wrap(Logger::default())
.wrap(cors_handler)
.wrap_fn(|req, srv| {
enrich_sentry_event_with_request_metadata(&req);
srv.call(req)
})
.wrap(sentry_actix::Sentry::with_transaction())
.configure(config_handlers)
})
.listen(listener)?
Expand Down

0 comments on commit ceec550

Please sign in to comment.