A metrique EntryIoStream backend that submits metrics directly to
Amazon CloudWatch Logs via PutLogEvents using the
Embedded Metric Format (EMF).
This provides a direct path to CloudWatch Metrics without requiring the CloudWatch Agent or any log routing infrastructure.
For more details, read the docs for CwLogsStream.
Setup
use CwLogsStream;
use ServiceMetrics;
use ;
let sdk_config = load_from_env.await;
let client = new;
let = builder
.client
.log_group_name
.log_stream_name
.namespace
.build;
let _attach = attach_to_stream;
// Metrics emitted via ServiceMetrics are now published to CloudWatch.
// On shutdown:
handle.shutdown.await;
Runtime Feature
The tokio_runtime feature is enabled by default and provides the default
Tokio task spawner. With --no-default-features, CwLogsStream::builder()
requires an explicit task_spawner.
Custom spawners are responsible for detaching the submitted future, or otherwise
keeping it running after the spawn callback returns. Shutdown completion is
reported through CwLogsStreamHandle::shutdown(), not through a task join
handle.
For non-Tokio executors, configure the AWS client with a compatible
AsyncSleep. SDK timeouts and retry delays use that
sleep hook.