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
6 changes: 5 additions & 1 deletion sentry-core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rand::random;
use crate::constants::SDK_INFO;
use crate::protocol::{ClientSdkInfo, Event};
use crate::types::{Dsn, Uuid};
use crate::{ClientOptions, Integration, Scope, Transport};
use crate::{ClientOptions, Hub, Integration, Scope, Transport};

impl<T: Into<ClientOptions>> From<T> for Client {
fn from(o: T) -> Client {
Expand Down Expand Up @@ -93,6 +93,10 @@ impl Client {
/// If the DSN on the options is set to `None` the client will be entirely
/// disabled.
pub fn with_options(mut options: ClientOptions) -> Client {
// Create the main hub eagerly to avoid problems with the background thread
// See https://github.com/getsentry/sentry-rust/issues/237
Hub::with(|_| {});

let create_transport = || {
options.dsn.as_ref()?;
let factory = options.transport.as_ref()?;
Expand Down
12 changes: 8 additions & 4 deletions sentry-core/src/hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ impl HubImpl {
}

fn is_active_and_usage_safe(&self) -> bool {
let guard = match self.stack.try_read() {
Err(TryLockError::Poisoned(err)) => err.into_inner(),
Err(TryLockError::WouldBlock) => return false,
let guard = match self.stack.read() {
Err(err) => err.into_inner(),
Ok(guard) => guard,
};
guard.top().client.is_some()

guard
.top()
.client
.as_ref()
.map_or(false, |c| c.is_enabled())
}
}

Expand Down
1 change: 0 additions & 1 deletion sentry-log/src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl Integration for LogIntegration {
}

INIT.call_once(|| {
// silently ignore errors here, as running tests will hit this condition for some reason.
log::set_boxed_logger(Box::new(Logger::default())).ok();
});
}
Expand Down