[Bug] [Invalid] incorrect datapoint count report in DefaultTransportService
See original GitHub issueDescribe the bug The datapoint counter will be submitted multiple in `DefaultTransportService
Your Server Environment
- own setup
- docker deployment
- ThingsBoard Version: latest version
- OS Name and Version: Linux
curl test
- Connectivity
- HTTP
To Reproduce Steps to reproduce the behavior:
- create test device (with access token
test_token
) - report device timeseries in json array:
curl -v -X POST -d "[{\"temperature\": 24}, {\"other1\": 25, \"other2\": \"some\"}]" http://127.0.0.1:8080/api/v1/test_token/telemetry --header "Content-Type:application/json"
- open the api usage dashboard and check the Transport datapoint counter, It has increased by six, but there are actually only three data points.
Additional context
The problem may be caused by the following methods. The dataPoints
calculates all of the KvCount
in list, but it will be submitted multiple times in packCallback
.
@Override
public void process(TransportProtos.SessionInfoProto sessionInfo, TransportProtos.PostTelemetryMsg msg, TransportServiceCallback<Void> callback) {
int dataPoints = 0;
for (TransportProtos.TsKvListProto tsKv : msg.getTsKvListList()) {
dataPoints += tsKv.getKvCount();
}
if (checkLimits(sessionInfo, msg, callback, dataPoints)) {
reportActivityInternal(sessionInfo);
TenantId tenantId = getTenantId(sessionInfo);
DeviceId deviceId = new DeviceId(new UUID(sessionInfo.getDeviceIdMSB(), sessionInfo.getDeviceIdLSB()));
CustomerId customerId = getCustomerId(sessionInfo);
MsgPackCallback packCallback = new MsgPackCallback(msg.getTsKvListCount(), new ApiStatsProxyCallback<>(tenantId, customerId, dataPoints, callback));
for (TransportProtos.TsKvListProto tsKv : msg.getTsKvListList()) {
TbMsgMetaData metaData = new TbMsgMetaData();
metaData.putValue("deviceName", sessionInfo.getDeviceName());
metaData.putValue("deviceType", sessionInfo.getDeviceType());
metaData.putValue("ts", tsKv.getTs() + "");
JsonObject json = JsonUtils.getJsonObject(tsKv.getKvList());
sendToRuleEngine(tenantId, deviceId, customerId, sessionInfo, json, metaData, SessionMsgType.POST_TELEMETRY_REQUEST, packCallback);
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Why can't I retrieve data points for CloudWatch metrics in the ...
There are several reasons that a data point retrieved from the default or custom metric might be missing or incorrect.
Read more >CloudWatch Tips and Tricks: Monitoring Error Metrics - marbot
However, other metrics only contain data points when something goes wrong. I call them error counting metrics.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ViacheslavKlimov Sorry for late reply. I’ve checked the code, and it’s indeed executed only once.
I’ll check the test again, and close this issue for this moment. Thanks for your time : )
@ByteGen We’ve checked with TB version 3.2.2 and everything still works as expected. Maybe you’ve accidentally sent this telemetry for the device a couple of times in a row? If you send the payload only once and check
transportDataPointsCount
key ints_kv_latest
table, it is not increased by 3? Could you then please describe your setup in more detail?