Skip to content

Commit c208e52

Browse files
author
Meshwa Savalia
committed
Minor modification in metrics validation
1 parent 2411d1e commit c208e52

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/software/amazon/cloudwatchlogs/emf/model/MetricsContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class MetricsContext {
3434
@Getter private final RootNode rootNode;
3535

3636
private MetricDirective metricDirective;
37-
private final Map<String, String> metricNameAndResolutionMap = new HashMap<>();
37+
private final Map<String, StorageResolution> metricNameAndResolutionMap = new HashMap<>();
3838

3939
public MetricsContext() {
4040
this(new RootNode());

src/main/java/software/amazon/cloudwatchlogs/emf/util/Validator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static void validateMetric(
100100
double value,
101101
Unit unit,
102102
StorageResolution storageResolution,
103-
Map<String, String> metricNameAndResolutionMap)
103+
Map<String, StorageResolution> metricNameAndResolutionMap)
104104
throws InvalidMetricException {
105105

106106
if (name == null || name.trim().isEmpty()) {
@@ -129,14 +129,14 @@ public static void validateMetric(
129129
}
130130

131131
if (metricNameAndResolutionMap.containsKey(name)) {
132-
if (!metricNameAndResolutionMap.get(name).equals(storageResolution.toString())) {
132+
if (!metricNameAndResolutionMap.get(name).equals(storageResolution)) {
133133
throw new InvalidMetricException(
134134
"Resolution for metrics "
135135
+ name
136136
+ " is already set. A single log event cannot have a metric with two different resolutions.");
137137
}
138138
} else {
139-
metricNameAndResolutionMap.put(name, storageResolution.toString());
139+
metricNameAndResolutionMap.put(name, storageResolution);
140140
}
141141
}
142142

0 commit comments

Comments
 (0)