Expand description

Backend for the metrics crate to emit metrics in the CloudWatch Embedded Metrics Format (https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html)

Counters, Gauges and Histograms are supported.

§Example

let metrics = metrics_cloudwatch_embedded::Builder::new()
     .cloudwatch_namespace("MyApplication")
     .init()
     .unwrap();

 metrics::counter!("requests", "Method" => "Default").increment(1);

 metrics
     .set_property("RequestId", "ABC123")
     .flush(std::io::stdout());

§Implementation Details

Intended for use with the lambda_runtime, however Collector::flush(…) could be used for anything that writes logs that end up in CloudWatch.

  • Counters are Guages are implented as AtomicU64 via the CounterFn and GaugeFn implementations in the metrics crate
  • Histograms are implemented as mpsc::SyncSender
  • serde_json is used to serialize metric documents to simplify maintainence and for consistancy with other crates in the ecosystem
  • Registering and flushing of metrics uses state within a Mutex, recording previously registered metrics should not block on this Mutex
  • Metric names are mapped to metrics::Unit regardless of their type and labels
  • Metric descriptions are unused

§Limitations

Modules§

Structs§

  • Builder for the Embedded Cloudwatch Metrics Collector
  • Embedded CloudWatch Metrics Collector + Emitter