#metrics #sqlite

metrics-sqlite

Library for providing SQLite backend for metrics

6 releases

0.3.1 Jan 21, 2022
0.3.0 Jan 21, 2022
0.2.3 May 10, 2021
0.2.2 Apr 28, 2021
0.2.1 Mar 10, 2021

#213 in Debugging

Download history 20/week @ 2022-06-09 13/week @ 2022-06-16 12/week @ 2022-06-23 11/week @ 2022-06-30 25/week @ 2022-07-07 11/week @ 2022-07-14 29/week @ 2022-07-21 6/week @ 2022-07-28 7/week @ 2022-08-04 5/week @ 2022-08-11 15/week @ 2022-08-18 23/week @ 2022-08-25 10/week @ 2022-09-01 35/week @ 2022-09-08 28/week @ 2022-09-15 37/week @ 2022-09-22

126 downloads per month

MIT/Apache

34KB
780 lines

SQLite Observer & Exporter for SQLite

Rust docs Crates.io

This provides a fairly simple SQLite powered backend for the metrics crate, useful for offline or desktop applications to gather metrics that can be easily queried afterwards.

Version 0.3 Notes

  • Now vacuums on setup which can incur a delay in being ready to record
  • Migration of database blows away 0.2 data unfortunately

Example

    let exporter = SqliteExporter::new(
        Duration::from_secs(30), // flush to sqlite on disk every 30s (or internal buffer limit)
        Some(Duration::from_secs(60 * 60 * 24 * 7)), // 60 sec * 60 min * 24 hours * 7 days
        "metrics.db",
    )
    .expect("Failed to create SqliteExporter");
    exporter
        .install()
        .expect("Failed to install SqliteExporter");

// use metrics macros etc.
metrics::gauge!("mykey", 1.0);

Dependencies

~23MB
~442K SLoC