Commit 9f2bae98158e63dd1d3a61a31a0723b05fc63b6a

Authored by Andrii Shvaika
1 parent 627c0577

Improvements to API usage statistics collection

... ... @@ -390,7 +390,8 @@ public class DefaultTransportService implements TransportService {
390 390 metaData.putValue("deviceName", sessionInfo.getDeviceName());
391 391 metaData.putValue("deviceType", sessionInfo.getDeviceType());
392 392 metaData.putValue("notifyDevice", "false");
393   - sendToRuleEngine(tenantId, deviceId, sessionInfo, json, metaData, SessionMsgType.POST_ATTRIBUTES_REQUEST, new TransportTbQueueCallback(callback));
  393 + sendToRuleEngine(tenantId, deviceId, sessionInfo, json, metaData, SessionMsgType.POST_ATTRIBUTES_REQUEST,
  394 + new TransportTbQueueCallback(new ApiStatsProxyCallback<>(tenantId, msg.getKvList().size(), callback)));
394 395 }
395 396 }
396 397
... ... @@ -399,7 +400,7 @@ public class DefaultTransportService implements TransportService {
399 400 if (checkLimits(sessionInfo, msg, callback)) {
400 401 reportActivityInternal(sessionInfo);
401 402 sendToDeviceActor(sessionInfo, TransportToDeviceActorMsg.newBuilder().setSessionInfo(sessionInfo)
402   - .setGetAttributes(msg).build(), callback);
  403 + .setGetAttributes(msg).build(), new ApiStatsProxyCallback<>(getTenantId(sessionInfo), 1, callback));
403 404 }
404 405 }
405 406
... ... @@ -409,7 +410,7 @@ public class DefaultTransportService implements TransportService {
409 410 SessionMetaData sessionMetaData = reportActivityInternal(sessionInfo);
410 411 sessionMetaData.setSubscribedToAttributes(!msg.getUnsubscribe());
411 412 sendToDeviceActor(sessionInfo, TransportToDeviceActorMsg.newBuilder().setSessionInfo(sessionInfo)
412   - .setSubscribeToAttributes(msg).build(), callback);
  413 + .setSubscribeToAttributes(msg).build(), new ApiStatsProxyCallback<>(getTenantId(sessionInfo), 1, callback));
413 414 }
414 415 }
415 416
... ... @@ -419,7 +420,7 @@ public class DefaultTransportService implements TransportService {
419 420 SessionMetaData sessionMetaData = reportActivityInternal(sessionInfo);
420 421 sessionMetaData.setSubscribedToRPC(!msg.getUnsubscribe());
421 422 sendToDeviceActor(sessionInfo, TransportToDeviceActorMsg.newBuilder().setSessionInfo(sessionInfo)
422   - .setSubscribeToRPC(msg).build(), callback);
  423 + .setSubscribeToRPC(msg).build(), new ApiStatsProxyCallback<>(getTenantId(sessionInfo), 1, callback));
423 424 }
424 425 }
425 426
... ... @@ -428,7 +429,7 @@ public class DefaultTransportService implements TransportService {
428 429 if (checkLimits(sessionInfo, msg, callback)) {
429 430 reportActivityInternal(sessionInfo);
430 431 sendToDeviceActor(sessionInfo, TransportToDeviceActorMsg.newBuilder().setSessionInfo(sessionInfo)
431   - .setToDeviceRPCCallResponse(msg).build(), callback);
  432 + .setToDeviceRPCCallResponse(msg).build(), new ApiStatsProxyCallback<>(getTenantId(sessionInfo), 1, callback));
432 433 }
433 434 }
434 435
... ... @@ -805,7 +806,7 @@ public class DefaultTransportService implements TransportService {
805 806
806 807 @Override
807 808 public void onFailure(Throwable t) {
808   - callback.onError(t);
  809 + DefaultTransportService.this.transportCallbackExecutor.submit(() -> callback.onError(t));
809 810 }
810 811 }
811 812
... ...