Commit 3db338557172537fd7e6bac779f1b08bb418b875
Committed by
Andrew Shvayka
1 parent
9d045e23
Enable/disable usage stats per customer from config
Showing
2 changed files
with
4 additions
and
1 deletions
@@ -124,6 +124,7 @@ usage: | @@ -124,6 +124,7 @@ usage: | ||
124 | stats: | 124 | stats: |
125 | report: | 125 | report: |
126 | enabled: "${USAGE_STATS_REPORT_ENABLED:true}" | 126 | enabled: "${USAGE_STATS_REPORT_ENABLED:true}" |
127 | + enabled_per_customer: "${USAGE_STATS_REPORT_PER_CUSTOMER_ENABLED:false}" | ||
127 | interval: "${USAGE_STATS_REPORT_INTERVAL:10}" | 128 | interval: "${USAGE_STATS_REPORT_INTERVAL:10}" |
128 | check: | 129 | check: |
129 | cycle: "${USAGE_STATS_CHECK_CYCLE:60000}" | 130 | cycle: "${USAGE_STATS_CHECK_CYCLE:60000}" |
@@ -50,6 +50,8 @@ public class DefaultTbApiUsageClient implements TbApiUsageClient { | @@ -50,6 +50,8 @@ public class DefaultTbApiUsageClient implements TbApiUsageClient { | ||
50 | 50 | ||
51 | @Value("${usage.stats.report.enabled:true}") | 51 | @Value("${usage.stats.report.enabled:true}") |
52 | private boolean enabled; | 52 | private boolean enabled; |
53 | + @Value("${usage.stats.report.enabled_per_customer:false}") | ||
54 | + private boolean enabledPerCustomer; | ||
53 | @Value("${usage.stats.report.interval:10}") | 55 | @Value("${usage.stats.report.interval:10}") |
54 | private int interval; | 56 | private int interval; |
55 | 57 | ||
@@ -135,7 +137,7 @@ public class DefaultTbApiUsageClient implements TbApiUsageClient { | @@ -135,7 +137,7 @@ public class DefaultTbApiUsageClient implements TbApiUsageClient { | ||
135 | statsForKey.computeIfAbsent(new OwnerId(tenantId), id -> new AtomicLong()).addAndGet(value); | 137 | statsForKey.computeIfAbsent(new OwnerId(tenantId), id -> new AtomicLong()).addAndGet(value); |
136 | statsForKey.computeIfAbsent(new OwnerId(TenantId.SYS_TENANT_ID), id -> new AtomicLong()).addAndGet(value); | 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 | statsForKey.computeIfAbsent(new OwnerId(tenantId, customerId), id -> new AtomicLong()).addAndGet(value); | 141 | statsForKey.computeIfAbsent(new OwnerId(tenantId, customerId), id -> new AtomicLong()).addAndGet(value); |
140 | } | 142 | } |
141 | } | 143 | } |