19 releases

0.7.2 Apr 21, 2024
0.6.6 Apr 15, 2024
0.6.1 Jul 20, 2023
0.5.1 Mar 9, 2023
0.4.0 Oct 28, 2021

#170 in Debugging

Download history 31/week @ 2024-01-27 4/week @ 2024-02-03 114/week @ 2024-02-10 241/week @ 2024-02-17 194/week @ 2024-02-24 373/week @ 2024-03-02 320/week @ 2024-03-09 68/week @ 2024-03-16 83/week @ 2024-03-23 495/week @ 2024-03-30 148/week @ 2024-04-06 552/week @ 2024-04-13 250/week @ 2024-04-20 103/week @ 2024-04-27 12/week @ 2024-05-04 31/week @ 2024-05-11

430 downloads per month


155 lines


Docs Crates.io

tracing-layer-slack provides a Layer implementation for sending tracing events to Slack.


SlackLayer sends POST requests via tokio and reqwest to a Slack Webhook URL for each new tracing event. The format of the text field is statically defined.

This layer also looks for an optional JsonStorageLayer extension on the parent span of each event. This extension may contain additional contextual information for the parent span of an event, which is included into the Slack message.


Configure the dependencies and pull directly from GitHub:

tokio = "1.0"
tracing = "0.1"
tracing-layer-slack = "0.6"


See the full list of examples in examples/.


In this simple example, a layer is created using Slack configuration in the environment. An orphaned event (one with no parent span) and an event occurring within a span are created in three separate futures, and a number of messages are sent quickly to Slack.

Slack Messages

This screenshots shows the first three Slack messages sent while running this example. More messages are sent but were truncated from these images.

Slack Blocks

By default, messages are sent using Slack Blocks. Here's an example:

Screenshot demonstrating the current formatter implementation for events sent as Slack messages
Slack Text

By disabling the default features of this crate (and therefore disabling the blocks feature), you can revert to the older format which does not use the block kit.

Screenshot demonstrating the current formatter implementation for events sent as Slack messages

Code example

Run this example locally using the following commands:

$ git clone https://github.com/seanpianka/tracing-layer-slack.git
$ cd tracing-layer-slack
$ cargo run --example simple

You must have Slack configuration exported in the environment.

use regex::Regex;
use tracing::{info, warn, instrument};
use tracing_subscriber::{layer::SubscriberExt, Registry};

use tracing_layer_slack::{EventFilters, SlackLayer};

pub async fn create_user(id: u64) -> u64 {
    info!(param = id, "A user was created");

pub async fn network_io(id: u64) {
    warn!(user_id = id, "some network io happened");

pub async fn controller() {
    info!("Orphan event without a parent span");
    let (id1, id2, id3) = tokio::join!(create_user(2), create_user(4), create_user(6));

async fn main() {
    // Only show events from where this example code is the target.
    let target_to_filter: EventFilters = Regex::new("simple").unwrap().into();

    // Initialize the layer and an async background task for sending our Slack messages.
    let (slack_layer, background_worker) = SlackLayer::builder("my-app-name".to_string(), target_to_filter).build();
    // Initialize the global default subscriber for tracing events.
    let subscriber = Registry::default().with(slack_layer);

    // Perform our application code that needs tracing and Slack messages.
    // Waits for all Slack messages to be sent before exiting.


~434K SLoC