You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Amazon CloudWatch announced support for high resolution metric extraction from structured logs (EMF). Customers can now provide an optional StorageResolution parameter within the EMF specification with a value of 1 or 60 (default) to indicate the desired resolution (in seconds) of the metric.
We should consider adding support for this new optional parameter to Metrics.
As part of this issue we should also update the API docs, documentation, and unit/integration tests.
Solution/User Experience
fromaws_lambda_powertoolsimportMetricsfromaws_lambda_powertools.metricsimportMetricUnit, MetricResolutionfromaws_lambda_powertools.utilities.typingimportLambdaContextmetrics=Metrics()
@metrics.log_metrics# ensures metrics are flushed upon request completion/failuredeflambda_handler(event: dict, context: LambdaContext):
# Publish a metric with standard resolution i.e. StorageResolution = 60metrics.add_metric(name="SuccessfulBooking", unit=MetricUnit.Count, value=1, resolution=MetricResolution.Standard)
# Publish a metric with high resolution i.e. StorageResolution = 1metrics.add_metric(name="FailedBooking", unit=MetricUnit.Count, value=1, resolution=MetricResolution.High)
# The last parameter (storage resolution) is optionalmetrics.add_metric(name="SuccessfulUpgrade", unit=MetricUnit.Count, value=1)
To support the proposal, a new MetricResolution enum should be added:
classMetricResolution(Enum):
Standard=60High=1
and changes should be made to the Metrics.add_metric method to allow for a new optional parameter.
Note
The EMF specification states that if a value is not provided, then a default value of 60 is assumed (aka standard resolution). For this reason, if the resolution parameter is not specified we won't add the resolution.
Use case
Amazon CloudWatch announced support for high resolution metric extraction from structured logs (EMF). Customers can now provide an optional
StorageResolution
parameter within the EMF specification with a value of 1 or 60 (default) to indicate the desired resolution (in seconds) of the metric.We should consider adding support for this new optional parameter to Metrics.
The EMF log should have this format:
As part of this issue we should also update the API docs, documentation, and unit/integration tests.
Solution/User Experience
To support the proposal, a new
MetricResolution
enum should be added:and changes should be made to the
Metrics.add_metric
method to allow for a new optional parameter.Alternative solutions
No response
Acknowledgment
The text was updated successfully, but these errors were encountered: