#metrics #cloudwatch #aws

metrics_cloudwatch

CloudWatch emitter for the metrics crate

14 releases (8 breaking)

0.9.2 Nov 2, 2020
0.9.0 Sep 28, 2020
0.6.0 Jun 16, 2020
0.4.0 Mar 18, 2020

#128 in Debugging

Download history 30/week @ 2020-08-11 74/week @ 2020-08-18 79/week @ 2020-08-25 102/week @ 2020-09-01 143/week @ 2020-09-08 138/week @ 2020-09-15 168/week @ 2020-09-22 227/week @ 2020-09-29 157/week @ 2020-10-06 199/week @ 2020-10-13 117/week @ 2020-10-20 144/week @ 2020-10-27 167/week @ 2020-11-03 186/week @ 2020-11-10 87/week @ 2020-11-17 114/week @ 2020-11-24

513 downloads per month

MIT/Apache

35KB
812 lines

metrics_cloudwatch

crates.io Docs Build status

Purpose

Provide a backend for the metrics facade crate, pushing metrics to CloudWatch.

How to use

Credentials for AWS needs to be available in the environment, see Rusoto docs on AWS credentials

cargo add -s metrics metrics_cloudwatch
fn main() {
    // Initialize the backend
    metrics_cloudwatch::builder()
        .cloudwatch_namespace("my-namespace")
        .init_thread()
        .unwrap();

    metrics::counter!("requests", 1);
}

Limitations

The CloudWatch metrics API imposes some limitations.

  • Max 10 labels (dimensions) per metric
  • Max 150 unique histogram values (used by timing!() and value!()) per API call. Going beyond this works but will incur one API call per batch of 150 unique values. Could be a good idea to measure timing in milliseconds rather than nanoseconds, to keep down the number of unique values.

Dependencies

~14MB
~294K SLoC