Closed
Description
There is currently no check when a dimension is added that the value is of type string. The values must be string as per [EMF schema]. The consequence of writing non string values for dimensions to the logs is a silent failure scenario where no metrics get published. (https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html):
DimensionSet Array
A DimensionSet is an array of strings containing the dimension keys that will be applied to all metrics in the document. The values within this array MUST also be members on the root-node—referred to as the Target Members
A DimensionSet MUST NOT contain more than 9 dimension keys.
The target member MUST have a string value.
Reproduce:
from aws_lambda_powertools.metrics import Metrics
metrics = Metrics()
metrics.add_namespace("test-namespace")
@metrics.log_metrics
def lambda_handler(event, context):
metrics.add_metric(name="CartUpdated", unit=MetricUnit.Count, value=1)
metrics.add_dimension(name="user_type", value=3)
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Triage