diff --git a/application/src/main/java/org/thingsboard/mqtt/broker/service/stats/StatsManager.java b/application/src/main/java/org/thingsboard/mqtt/broker/service/stats/StatsManager.java index e7e2bf3b1..9954707a0 100644 --- a/application/src/main/java/org/thingsboard/mqtt/broker/service/stats/StatsManager.java +++ b/application/src/main/java/org/thingsboard/mqtt/broker/service/stats/StatsManager.java @@ -30,6 +30,7 @@ import java.util.concurrent.atomic.AtomicLong; public interface StatsManager { + TbQueueCallback wrapTbQueueCallback(TbQueueCallback queueCallback, MessagesStats stats); MessagesStats createMsgDispatcherPublishStats(); diff --git a/application/src/main/java/org/thingsboard/mqtt/broker/service/stats/StatsManagerStub.java b/application/src/main/java/org/thingsboard/mqtt/broker/service/stats/StatsManagerStub.java index 95875e5c0..0cb347f7d 100644 --- a/application/src/main/java/org/thingsboard/mqtt/broker/service/stats/StatsManagerStub.java +++ b/application/src/main/java/org/thingsboard/mqtt/broker/service/stats/StatsManagerStub.java @@ -42,6 +42,7 @@ @Service @ConditionalOnProperty(prefix = "stats", value = "enabled", havingValue = "false", matchIfMissing = true) public class StatsManagerStub implements StatsManager, ActorStatsManager, ProducerStatsManager, ConsumerStatsManager { + private static final StubTimerStats timerStats = new StubTimerStats(); @Override diff --git a/application/src/main/resources/thingsboard-mqtt-broker.yml b/application/src/main/resources/thingsboard-mqtt-broker.yml index 7d43347c4..36c510dd9 100644 --- a/application/src/main/resources/thingsboard-mqtt-broker.yml +++ b/application/src/main/resources/thingsboard-mqtt-broker.yml @@ -957,6 +957,9 @@ stats: enabled: "${STATS_ENABLED:true}" # Period in milliseconds to print stats. Default value corresponds to 1 minute print-interval-ms: "${STATS_PRINT_INTERVAL_MS:60000}" + timer: + # Metrics percentiles returned by actuator for timer metrics. List of comma-separated (,) double values + percentiles: "${STATS_TIMER_PERCENTILES:0.3}" application-processor: # Enable/disable specific Application clients stats enabled: "${APPLICATION_PROCESSOR_STATS_ENABLED:true}" diff --git a/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/DefaultStatsFactory.java b/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/DefaultStatsFactory.java index 1ede7addd..e84687b30 100644 --- a/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/DefaultStatsFactory.java +++ b/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/DefaultStatsFactory.java @@ -39,7 +39,7 @@ public class DefaultStatsFactory implements StatsFactory { private final MeterRegistry meterRegistry; - @Value("${metrics.timer.percentiles:0.5}") + @Value("${stats.timer.percentiles:0.5}") private String timerPercentilesStr; private double[] timerPercentiles; @@ -55,7 +55,6 @@ public void init() { } } - @Override public StatsCounter createStatsCounter(String key, String statsName, String... tags) { String[] updatedTags = new String[tags.length + 2]; diff --git a/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/StatsConstantNames.java b/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/StatsConstantNames.java index b464882ff..eca7790a5 100644 --- a/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/StatsConstantNames.java +++ b/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/StatsConstantNames.java @@ -16,6 +16,7 @@ package org.thingsboard.mqtt.broker.common.stats; public class StatsConstantNames { + public static final String TOTAL_MSGS = "totalMsgs"; public static final String SUCCESSFUL_MSGS = "successfulMsgs"; public static final String FAILED_MSGS = "failedMsgs"; diff --git a/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/StatsFactory.java b/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/StatsFactory.java index 58efcc290..1d95e25d0 100644 --- a/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/StatsFactory.java +++ b/common/stats/src/main/java/org/thingsboard/mqtt/broker/common/stats/StatsFactory.java @@ -19,8 +19,8 @@ import java.util.function.ToDoubleFunction; -// TODO move this to some separate library (or use ThingsBoard stats library) public interface StatsFactory { + StatsCounter createStatsCounter(String key, String statsName, String... tags); DefaultCounter createDefaultCounter(String key, String... tags);