question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] [Invalid] incorrect datapoint count report in DefaultTransportService

See original GitHub issue

Describe 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:

  1. create test device (with access token test_token)
  2. 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"
  3. 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:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ByteGencommented, Oct 21, 2021

@ViacheslavKlimov Sorry for late reply. I’ve checked the code, and it’s indeed executed only once.

public void onSuccess(TbQueueMsgMetadata metadata) {
    if (msgCount.decrementAndGet() <= 0) {
        DefaultTransportService.this.transportCallbackExecutor.submit(() -> callback.onSuccess(null));
    }
}

I’ll check the test again, and close this issue for this moment. Thanks for your time : )

0reactions
ViacheslavKlimovcommented, Oct 11, 2021

@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 in ts_kv_latest table, it is not increased by 3? Could you then please describe your setup in more detail?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found