pub struct SlackBackgroundWorker { /* private fields */ }
Expand description
This worker manages a background async task that schedules the network requests to send traces to the Slack on the running tokio runtime.
Ensure to invoke .startup()
before, and .teardown()
after, your application code runs. This
is required to ensure proper initialization and shutdown.
tracing-layer-slack
synchronously generates payloads to send to the Slack API using the
tracing events from the global subscriber. However, all network requests are offloaded onto
an unbuffered channel and processed by a provided future acting as an asynchronous worker.
Implementations§
source§impl SlackBackgroundWorker
impl SlackBackgroundWorker
sourcepub async fn shutdown(self)
pub async fn shutdown(self)
Initiate the worker’s shutdown sequence.
Without invoking.teardown()
, your application may exit before all Slack messages can be
sent.
Examples found in repository?
More examples
examples/exclude_fields_from_messages.rs (line 31)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
async fn main() {
let targets_to_filter: EventFilters = Regex::new("exclude_fields_from_messages").unwrap().into();
let fields_to_exclude = vec![
Regex::new(".*token.*").unwrap(),
Regex::new(".*password.*").unwrap(),
Regex::new("command").unwrap(),
];
let (slack_layer, background_worker) = SlackLayer::builder("test-app".to_string(), targets_to_filter)
.field_exclusion_filters(fields_to_exclude)
.build();
let subscriber = Registry::default().with(slack_layer);
tracing::subscriber::set_global_default(subscriber).unwrap();
handler().await;
background_worker.shutdown().await;
}
Trait Implementations§
source§impl Clone for SlackBackgroundWorker
impl Clone for SlackBackgroundWorker
source§fn clone(&self) -> SlackBackgroundWorker
fn clone(&self) -> SlackBackgroundWorker
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for SlackBackgroundWorker
impl !RefUnwindSafe for SlackBackgroundWorker
impl Send for SlackBackgroundWorker
impl Sync for SlackBackgroundWorker
impl Unpin for SlackBackgroundWorker
impl !UnwindSafe for SlackBackgroundWorker
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more