Commit 3db338557172537fd7e6bac779f1b08bb418b875

Authored by Viacheslav Klimov
Committed by Andrew Shvayka
1 parent 9d045e23

Enable/disable usage stats per customer from config

... ... @@ -124,6 +124,7 @@ usage:
124 124 stats:
125 125 report:
126 126 enabled: "${USAGE_STATS_REPORT_ENABLED:true}"
  127 + enabled_per_customer: "${USAGE_STATS_REPORT_PER_CUSTOMER_ENABLED:false}"
127 128 interval: "${USAGE_STATS_REPORT_INTERVAL:10}"
128 129 check:
129 130 cycle: "${USAGE_STATS_CHECK_CYCLE:60000}"
... ...
... ... @@ -50,6 +50,8 @@ public class DefaultTbApiUsageClient implements TbApiUsageClient {
50 50
51 51 @Value("${usage.stats.report.enabled:true}")
52 52 private boolean enabled;
  53 + @Value("${usage.stats.report.enabled_per_customer:false}")
  54 + private boolean enabledPerCustomer;
53 55 @Value("${usage.stats.report.interval:10}")
54 56 private int interval;
55 57
... ... @@ -135,7 +137,7 @@ public class DefaultTbApiUsageClient implements TbApiUsageClient {
135 137 statsForKey.computeIfAbsent(new OwnerId(tenantId), id -> new AtomicLong()).addAndGet(value);
136 138 statsForKey.computeIfAbsent(new OwnerId(TenantId.SYS_TENANT_ID), id -> new AtomicLong()).addAndGet(value);
137 139
138   - if (customerId != null && !customerId.isNullUid()) {
  140 + if (enabledPerCustomer && customerId != null && !customerId.isNullUid()) {
139 141 statsForKey.computeIfAbsent(new OwnerId(tenantId, customerId), id -> new AtomicLong()).addAndGet(value);
140 142 }
141 143 }
... ...