|
|
|
@ -18,7 +18,6 @@ package org.thingsboard.server.service.queue; |
|
|
|
import io.micrometer.core.instrument.Timer; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
|
import org.thingsboard.server.common.data.queue.Queue; |
|
|
|
import org.thingsboard.server.common.msg.queue.RuleEngineException; |
|
|
|
import org.thingsboard.server.common.stats.StatsCounter; |
|
|
|
import org.thingsboard.server.common.stats.StatsFactory; |
|
|
|
@ -45,6 +44,7 @@ public class TbRuleEngineConsumerStats { |
|
|
|
public static final String FAILED_MSGS = "failedMsgs"; |
|
|
|
public static final String SUCCESSFUL_ITERATIONS = "successfulIterations"; |
|
|
|
public static final String FAILED_ITERATIONS = "failedIterations"; |
|
|
|
public static final String TENANT_ID_TAG = "tenantId"; |
|
|
|
|
|
|
|
private final StatsFactory statsFactory; |
|
|
|
|
|
|
|
@ -73,14 +73,15 @@ public class TbRuleEngineConsumerStats { |
|
|
|
this.statsFactory = statsFactory; |
|
|
|
|
|
|
|
String statsKey = StatsType.RULE_ENGINE.getName() + "." + queueName; |
|
|
|
this.totalMsgCounter = statsFactory.createStatsCounter(statsKey, TOTAL_MSGS); |
|
|
|
this.successMsgCounter = statsFactory.createStatsCounter(statsKey, SUCCESSFUL_MSGS); |
|
|
|
this.timeoutMsgCounter = statsFactory.createStatsCounter(statsKey, TIMEOUT_MSGS); |
|
|
|
this.failedMsgCounter = statsFactory.createStatsCounter(statsKey, FAILED_MSGS); |
|
|
|
this.tmpTimeoutMsgCounter = statsFactory.createStatsCounter(statsKey, TMP_TIMEOUT); |
|
|
|
this.tmpFailedMsgCounter = statsFactory.createStatsCounter(statsKey, TMP_FAILED); |
|
|
|
this.successIterationsCounter = statsFactory.createStatsCounter(statsKey, SUCCESSFUL_ITERATIONS); |
|
|
|
this.failedIterationsCounter = statsFactory.createStatsCounter(statsKey, FAILED_ITERATIONS); |
|
|
|
String tenant = tenantId == null || tenantId.isSysTenantId() ? "system" : tenantId.toString(); |
|
|
|
this.totalMsgCounter = statsFactory.createStatsCounter(statsKey, TOTAL_MSGS, TENANT_ID_TAG, tenant); |
|
|
|
this.successMsgCounter = statsFactory.createStatsCounter(statsKey, SUCCESSFUL_MSGS, TENANT_ID_TAG, tenant); |
|
|
|
this.timeoutMsgCounter = statsFactory.createStatsCounter(statsKey, TIMEOUT_MSGS, TENANT_ID_TAG, tenant); |
|
|
|
this.failedMsgCounter = statsFactory.createStatsCounter(statsKey, FAILED_MSGS, TENANT_ID_TAG, tenant); |
|
|
|
this.tmpTimeoutMsgCounter = statsFactory.createStatsCounter(statsKey, TMP_TIMEOUT, TENANT_ID_TAG, tenant); |
|
|
|
this.tmpFailedMsgCounter = statsFactory.createStatsCounter(statsKey, TMP_FAILED, TENANT_ID_TAG, tenant); |
|
|
|
this.successIterationsCounter = statsFactory.createStatsCounter(statsKey, SUCCESSFUL_ITERATIONS, TENANT_ID_TAG, tenant); |
|
|
|
this.failedIterationsCounter = statsFactory.createStatsCounter(statsKey, FAILED_ITERATIONS, TENANT_ID_TAG, tenant); |
|
|
|
|
|
|
|
counters.add(totalMsgCounter); |
|
|
|
counters.add(successMsgCounter); |
|
|
|
@ -93,7 +94,7 @@ public class TbRuleEngineConsumerStats { |
|
|
|
counters.add(failedIterationsCounter); |
|
|
|
} |
|
|
|
|
|
|
|
public Timer getTimer(TenantId tenantId, String status){ |
|
|
|
public Timer getTimer(TenantId tenantId, String status) { |
|
|
|
return tenantMsgProcessTimers.computeIfAbsent(tenantId, |
|
|
|
id -> statsFactory.createTimer(StatsType.RULE_ENGINE.getName() + "." + queueName, |
|
|
|
"tenantId", tenantId.getId().toString(), |
|
|
|
|