added one more filtering for metrics data

This commit is contained in:
YevhenBondarenko 2024-09-13 10:02:06 +02:00
parent 137b1732bb
commit 55b6b8c564

View File

@ -398,15 +398,20 @@ public abstract class AbstractGatewaySessionHandler<T extends AbstractGatewayDev
var serverReceiveTs = System.currentTimeMillis();
var metricsData = metadata.stream()
.filter(JsonElement::isJsonObject)
.map(je -> {
var jo = je.getAsJsonObject();
.map(JsonElement::getAsJsonObject)
.filter(jo -> jo.has("connector")
&& jo.has("receivedTs")
&& jo.has("publishedTs"))
.map(jo -> {
var connector = jo.get("connector").getAsString();
var receivedTs = jo.get("receivedTs").getAsLong();
var publishedTs = jo.get("publishedTs").getAsLong();
return new GatewayMetricsData(connector, receivedTs, publishedTs);
}).toList();
if (!metadata.isEmpty()) {
gatewayMetricsService.process(deviceSessionCtx.getSessionInfo(), gateway.getDeviceId(), metricsData, serverReceiveTs);
}
}
protected void onDeviceTelemetryProto(int msgId, ByteBuf payload) throws AdaptorException {
try {