#metrics-exporter #metrics

metrics-exporter-plotly

An embedded metrics-rs exporter for plotting with plotly

2 releases

0.1.1 Jun 19, 2024
0.1.0 Jun 19, 2024

#1478 in Development tools

41 downloads per month

MIT license

19KB
423 lines

metrics-exporter-plotly

An embedded metrics exporter which plots metrics in the browser.

Usage

Normal usage is setting up the PlotlyRecorder using the PlotlyRecorderBuilder. This will return a PlotlyRecorderHandle which can be used for a one-shot plotting of the metrics.

PlotlyRecorderHandle takes a slice of PatternGroups, which are just regex patterns you wish to group together into rows of plots. For instance, in the following:

use metrics_exporter_plotly::{PatternGroup, PlotKind, PlotlyRecorderBuilder};

#[tokio::main]
async fn main() {
    let handle = PlotlyRecorderBuilder::new().install().unwrap();

    /* Your code */

    // Have to call `.plot()` on handle when you want to plot metrics
    handle
        .plot(&[PatternGroup::new()
            .pattern(r"(?<transaction>.*)_success", PlotKind::Rate)
            .pattern(r"(?<transaction>.*)_error", PlotKind::Rate)])
        .await;
}

foo_success and foo_error would be plotted together on a row, and bar_success and bar_error would be on another row.

Dependencies

~14–22MB
~246K SLoC