Struct sentry::Hub

source ·
pub struct Hub { /* private fields */ }
Expand description

The central object that can manages scopes and clients.

This can be used to capture events and manage the scope. This object is internally synchronized so it can be used from multiple threads if needed. The default hub that is available automatically is thread local.

In most situations developers do not need to interface the hub. Instead toplevel convenience functions are expose tht will automatically dispatch to global (Hub::current) hub. In some situations this might not be possible in which case it might become necessary to manually work with the hub. This is for instance the case when working with async code.

Hubs that are wrapped in Arcs can be bound to the current thread with the run static method.

Most common operations:

  • Hub::new: creates a brand new hub
  • Hub::current: returns the thread local hub
  • Hub::with: invoke a callback with the thread local hub
  • Hub::with_active: like Hub::with but does not invoke the callback if the client is not in a supported state or not bound
  • Hub::new_from_top: creates a new hub with just the top scope of another hub.

Implementations§

Creates a new hub from the given client and scope.

Creates a new hub based on the top scope of the given hub.

Returns the current hub.

By default each thread gets a different thread local hub. If an atomically reference counted hub is available it can override this one here by calling Hub::run with a closure.

This method is unavailable if the client implementation is disabled. When using the minimal API set use Hub::with_active instead.

Returns the main thread’s hub.

This is similar to current but instead of picking the current thread’s hub it returns the main thread’s hub instead.

Invokes the callback with the default hub.

This is a slightly more efficient version than Hub::current() and also unavailable in minimal mode.

Like Hub::with but only calls the function if a client is bound.

This is useful for integrations that want to do efficiently nothing if there is no client bound. Additionally this internally ensures that the client can be safely synchronized. This prevents accidental recursive calls into the client.

Binds a hub to the current thread for the duration of the call.

Returns the last event id.

Sends the event to the current client with the current scope.

In case no client is bound this does nothing instead.

Captures an arbitrary message.

Returns the currently bound client.

Binds a new client to the hub.

Pushes a new scope.

This returns a guard that when dropped will pop the scope again.

Temporarily pushes a scope for a single call optionally reconfiguring it.

This works the same as the global with_scope function.

Invokes a function that can modify the current scope.

This works the same as the global configure_scope function.

Adds a new breadcrumb to the current scope.

This is equivalent to the global sentry::add_breadcrumb but sends the breadcrumb into the hub instead.

Trait Implementations§

Formats the value using the given formatter. Read more
Captures an error chain on a specific hub.
Captures a boxed failure (failure::Error).
Captures a failure::Fail.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.