#tracing #loki

loki-api

Protobuf types used by the Grafana Loki HTTP API

3 unstable releases

0.1.1 Mar 8, 2023
0.1.0 Mar 22, 2022
0.0.0 Mar 19, 2022

#778 in Network programming

Download history 6626/week @ 2023-02-09 7683/week @ 2023-02-16 7441/week @ 2023-02-23 6848/week @ 2023-03-02 8396/week @ 2023-03-09 8791/week @ 2023-03-16 7375/week @ 2023-03-23 6343/week @ 2023-03-30 6293/week @ 2023-04-06 9754/week @ 2023-04-13 11151/week @ 2023-04-20 9119/week @ 2023-04-27 9515/week @ 2023-05-04 10610/week @ 2023-05-11 8871/week @ 2023-05-18 8155/week @ 2023-05-25

38,806 downloads per month
Used in tracing-loki

MIT/Apache

14KB
303 lines

tracing-loki

A tracing layer for Grafana Loki.

Build status

Documentation

https://docs.rs/tracing-loki

Usage

Add this to your Cargo.toml:

[dependencies]
tracing-loki = "0.1"

Example

use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
use std::process;
use url::Url;

#[tokio::main]
async fn main() -> Result<(), tracing_loki::Error> {
    let (layer, task) = tracing_loki::builder()
        .label("host", "mine")?
        .extra_field("pid", format!("{}", process::id()))?
        .build_url(Url::parse("http://127.0.0.1:3100").unwrap())?;

    // We need to register our layer with `tracing`.
    tracing_subscriber::registry()
        .with(layer)
        // One could add more layers here, for example logging to stdout:
        // .with(tracing_subscriber::fmt::Layer::new())
        .init();

    // The background task needs to be spawned so the logs actually get
    // delivered.
    tokio::spawn(task);

    tracing::info!(
        task = "tracing_setup",
        result = "success",
        "tracing successfully set up",
    );

    Ok(())
}

Dependencies

~2MB
~45K SLoC