Skip to content

Commit b13b980

Browse files
author
Meshwa Savalia
committed
remove unnecessary checks for MetricMap
1 parent 0e17199 commit b13b980

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

aws_embedded_metrics/logger/metrics_context.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ def put_metric(self, key: str, value: float, unit: str = None, storageResolution
5858
metric.add_value(value)
5959
else:
6060
self.metrics[key] = Metric(value, unit, storageResolution)
61-
if key not in self.metricNameAndResolutionMap:
62-
self.metricNameAndResolutionMap[key] = storageResolution
61+
self.metricNameAndResolutionMap[key] = storageResolution
6362

6463
def put_dimensions(self, dimension_set: Dict[str, str]) -> None:
6564
"""

aws_embedded_metrics/validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def validate_metric(name: str, value: float, unit: Optional[str], storageResolut
8787
if storageResolution is None or storageResolution not in StorageResolution:
8888
raise InvalidMetricError(f"Metric storage Resolution is not valid: {storageResolution}")
8989

90-
if metricNameAndResolutionMap and name in metricNameAndResolutionMap and metricNameAndResolutionMap.get(name) is not storageResolution:
90+
if name in metricNameAndResolutionMap and metricNameAndResolutionMap.get(name) is not storageResolution:
9191
raise InvalidMetricError(
9292
"Resolution for metrics ${name} is already set. A single log event cannot have a metric with two different resolutions.")
9393

tests/logger/test_metrics_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def test_put_metric_uses_standard_storage_resolution_if_not_provided():
318318
("metric", math.nan, "Seconds", StorageResolution.STANDARD),
319319
("metric", 1, "Kilometers/Fahrenheit", StorageResolution.STANDARD),
320320
("metric", 1, "Seconds", 2),
321+
("metric", 1, "Seconds", 0),
321322
("metric", 1, "Seconds", None)
322323
]
323324
)

0 commit comments

Comments
 (0)