Provide a backend for the metrics
facade
crate, pushing metrics to CloudWatch.
Credentials for AWS needs to be available in the environment, see Rusoto docs on AWS credentials
bash
cargo add -s metrics metrics_cloudwatch
```rust fn main() { // Initialize the backend metricscloudwatch::builder() .cloudwatchnamespace("my-namespace") .init_thread() .unwrap();
metrics::counter!("requests", 1);
} ```
The CloudWatch metrics API imposes some limitations.
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.