mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(cloudwatch): parse decimal epoch timestamps in JSON protocol handler (#1388)
The AWS SDK v2 serialises Instant values via DateUtils.formatUnixTimestampInstant(), producing decimal epoch-second strings (e.g. "1750000000.123"). The JSON handler was using parseInstant(node.asText()), which failed for these values: Instant.parse() rejects them (not ISO-8601) and Long.parseLong() rejects the decimal point. This caused two silent failures: - GetMetricStatistics: StartTime/EndTime parsed as null, defaulting the filter to 0..MAX_VALUE and returning all datapoints regardless of the requested time range - PutMetricData: MetricDatum.Timestamp parsed as null, causing metrics to be stored with the current time instead of the caller-supplied timestamp Fix by switching to parseInstantNode(JsonNode), the existing helper that calls node.asLong() for numeric nodes and already handles this correctly for GetMetricData.
This commit is contained in:
1 parent
42669aaed9
commit
a876db87ef
2 files changed
+120
-3
No files matched your search
+3
-3
@@ -95,8 +95,8 @@ public class CloudWatchMetricsJsonHandler {
|
||||
String metricName = request.path("MetricName").asText();
|
||||
List<Dimension> dimensions = parseDimensionsJson(request.path("Dimensions"));
|
||||
int period = request.path("Period").asInt(60);
|
||||
Instant startTime = parseInstant(request.path("StartTime").asText(null));
|
||||
Instant endTime = parseInstant(request.path("EndTime").asText(null));
|
||||
Instant startTime = parseInstantNode(request.path("StartTime"));
|
||||
Instant endTime = parseInstantNode(request.path("EndTime"));
|
||||
|
||||
List<String> statistics = new ArrayList<>();
|
||||
JsonNode statsNode = request.path("Statistics");
|
||||
@@ -313,7 +313,7 @@ public class CloudWatchMetricsJsonHandler {
|
||||
datum.setUnit(item.path("Unit").asText(null));
|
||||
JsonNode ts = item.path("Timestamp");
|
||||
if (!ts.isMissingNode()) {
|
||||
Instant parsed = parseInstant(ts.asText(null));
|
||||
Instant parsed = parseInstantNode(ts);
|
||||
if (parsed != null) datum.setTimestamp(parsed.getEpochSecond());
|
||||
}
|
||||
datum.setDimensions(parseDimensionsJson(item.path("Dimensions")));
|
||||
|
||||
Reference in new issue
Block a user