#tracing #loki #grafana #protobuf #http-api #tracing-layer #type

loki-api

由Grafana Loki HTTP API使用的Protobuf类型

4个版本

0.1.2 2024年6月12日
0.1.1 2023年3月8日
0.1.0 2022年3月22日
0.0.0 2022年3月19日

#1175 in 网络编程

Download history 12006/week @ 2024-04-14 14007/week @ 2024-04-21 17808/week @ 2024-04-28 13896/week @ 2024-05-05 17539/week @ 2024-05-12 17935/week @ 2024-05-19 18002/week @ 2024-05-26 19486/week @ 2024-06-02 14573/week @ 2024-06-09 17700/week @ 2024-06-16 20103/week @ 2024-06-23 15911/week @ 2024-06-30 10683/week @ 2024-07-07 10744/week @ 2024-07-14 10963/week @ 2024-07-21 9331/week @ 2024-07-28

41,857 每月下载量
9 个crate中(2个直接) 使用

MIT/Apache

14KB
303

tracing-loki

tracing 提供的 Grafana Loki 层。

Build status

文档

https://docs.rs/tracing-loki

用法

将以下内容添加到您的 Cargo.toml

[dependencies]
tracing-loki = "0.1"

示例

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(())
}

依赖项

~440KB