#metrics #sqlite

metrics-sqlite

Library for providing SQLite backend for metrics

8 releases

0.4.0 Mar 16, 2023
0.3.2 Jan 24, 2023
0.3.1 Jan 21, 2022
0.2.3 May 10, 2021
0.2.1 Mar 10, 2021

#143 in Debugging

Download history 38/week @ 2022-12-04 47/week @ 2022-12-11 56/week @ 2022-12-18 1/week @ 2022-12-25 28/week @ 2023-01-01 23/week @ 2023-01-08 56/week @ 2023-01-15 61/week @ 2023-01-22 134/week @ 2023-01-29 43/week @ 2023-02-05 34/week @ 2023-02-12 53/week @ 2023-02-19 47/week @ 2023-02-26 45/week @ 2023-03-05 100/week @ 2023-03-12 131/week @ 2023-03-19

323 downloads per month

MIT/Apache

43KB
979 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.4 Notes

  • Now works with metrics 0.20.x
  • _register!() macros aren't required & don't do anything with this exporter currently
  • Unit/description now available via _describe!() macros metrics provides

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
~429K SLoC