Class EmfMetricLoggingPublisher
- All Implemented Interfaces:
AutoCloseable,MetricPublisher,SdkAutoCloseable
This publisher is particularly well-suited for serverless environments like AWS Lambda and container environments like Amazon ECS that have built-in integration with CloudWatch Logs. Using EMF eliminates the need for separate metric publishing infrastructure as metrics are automatically extracted from log entries.
The EMF publisher converts metric collections into JSON-formatted log entries that conform to the CloudWatch EMF specification. The logGroupName field is required for EMF to work. CloudWatch automatically processes these logs to generate corresponding metrics that can be used for monitoring and alerting.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder()voidclose()Closes this metric publisher.voidpublish(MetricCollection metricCollection) Notify the publisher of new metric data.
-
Method Details
-
builder
-
publish
Description copied from interface:MetricPublisherNotify the publisher of new metric data. After this call returns, the caller can safely discard the givenmetricCollectioninstance if it no longer needs it. Implementations are strongly encouraged to complete any further aggregation and publishing of metrics in an asynchronous manner to avoid blocking the calling thread.With the exception of a
nullmetricCollection, all invocations of this method must return normally. This is to ensure that callers of the publisher can safely assume that even in situations where an error happens during publishing that it will not interrupt the calling thread.- Specified by:
publishin interfaceMetricPublisher- Parameters:
metricCollection- The collection of metrics.
-
close
public void close()Closes this metric publisher. This implementation is empty as the EMF metric logging publisher does not maintain any resources that require explicit cleanup.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceMetricPublisher- Specified by:
closein interfaceSdkAutoCloseable
-