Skip to content

Commit a1b9023

Browse files
authored
Merge pull request #227 from swisspost/develop
PR for new release
2 parents 04dee96 + bc92c6c commit a1b9023

5 files changed

Lines changed: 56 additions & 16 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.swisspush</groupId>
44
<artifactId>redisques</artifactId>
5-
<version>4.1.7-SNAPSHOT</version>
5+
<version>4.1.8-SNAPSHOT</version>
66
<name>redisques</name>
77
<description>
88
A highly scalable redis-persistent queuing system for vertx

src/main/java/org/swisspush/redisques/RedisQues.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ private void initMicrometerMetrics(RedisquesConfiguration modConfig) {
393393

394394
String address = modConfig.getAddress();
395395
int metricRefreshPeriod = modConfig.getMetricRefreshPeriod();
396-
new PeriodicMetricsCollector(vertx, periodicSkipScheduler, address, meterRegistry, metricRefreshPeriod);
396+
String identifier = modConfig.getMicrometerMetricsIdentifier();
397+
new PeriodicMetricsCollector(vertx, periodicSkipScheduler, address, identifier, meterRegistry, metricRefreshPeriod);
397398
}
398399

399400
private void initialize() {

src/main/java/org/swisspush/redisques/metrics/PeriodicMetricsCollector.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.micrometer.core.instrument.Gauge;
44
import io.micrometer.core.instrument.MeterRegistry;
5+
import io.netty.util.internal.StringUtil;
56
import io.vertx.core.AsyncResult;
67
import io.vertx.core.Handler;
78
import io.vertx.core.Vertx;
@@ -27,15 +28,23 @@ public class PeriodicMetricsCollector {
2728
private final Vertx vertx;
2829
private final String redisquesAddress;
2930

31+
private static final String DEFAULT_IDENTIFIER = "default";
32+
3033
private final AtomicLong activeQueuesCount = new AtomicLong(0);
3134

32-
public PeriodicMetricsCollector(Vertx vertx, PeriodicSkipScheduler periodicSkipScheduler, String redisquesAddress, MeterRegistry meterRegistry, long metricCollectIntervalSec) {
35+
public PeriodicMetricsCollector(Vertx vertx, PeriodicSkipScheduler periodicSkipScheduler, String redisquesAddress,
36+
String identifier, MeterRegistry meterRegistry, long metricCollectIntervalSec) {
3337
this.vertx = vertx;
3438
this.redisquesAddress = redisquesAddress;
3539

36-
Gauge.builder(MetricMeter.ACTIVE_QUEUES.getId(), activeQueuesCount, AtomicLong::get).
37-
description(MetricMeter.ACTIVE_QUEUES.getDescription()).
38-
register(meterRegistry);
40+
String id = identifier;
41+
42+
if(StringUtil.isNullOrEmpty(id)) {
43+
id = DEFAULT_IDENTIFIER;
44+
}
45+
46+
Gauge.builder(MetricMeter.ACTIVE_QUEUES.getId(), activeQueuesCount, AtomicLong::get).tag("identifier", id)
47+
.description(MetricMeter.ACTIVE_QUEUES.getDescription()).register(meterRegistry);
3948

4049
periodicSkipScheduler.setPeriodic(metricCollectIntervalSec * 1000, "metricCollectRefresh",
4150
this::updateActiveQueuesCount);

src/main/java/org/swisspush/redisques/util/RedisquesConfiguration.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class RedisquesConfiguration {
4040
private final boolean httpRequestHandlerEnabled;
4141
private final boolean httpRequestHandlerAuthenticationEnabled;
4242
private final boolean micrometerMetricsEnabled;
43+
private final String micrometerMetricsIdentifier;
4344
private final String httpRequestHandlerPrefix;
4445
private final String httpRequestHandlerUsername;
4546
private final String httpRequestHandlerPassword;
@@ -114,6 +115,7 @@ public class RedisquesConfiguration {
114115
public static final String PROP_HTTP_REQUEST_HANDLER_ENABLED = "httpRequestHandlerEnabled";
115116
public static final String PROP_HTTP_REQUEST_HANDLER_AUTH_ENABLED = "httpRequestHandlerAuthenticationEnabled";
116117
public static final String PROP_MICROMETER_METRICS_ENABLED = "micrometerMetricsEnabled";
118+
public static final String PROP_MICROMETER_METRICS_IDENTIFIER = "micrometerMetricsIdentifier";
117119
public static final String PROP_HTTP_REQUEST_HANDLER_PREFIX = "httpRequestHandlerPrefix";
118120
public static final String PROP_HTTP_REQUEST_HANDLER_USERNAME = "httpRequestHandlerUsername";
119121
public static final String PROP_HTTP_REQUEST_HANDLER_PASSWORD = "httpRequestHandlerPassword";
@@ -148,15 +150,16 @@ public RedisquesConfiguration(String address, String configurationUpdatedAddress
148150
String publishMetricsAddress, String metricStorageName, int metricRefreshPeriod, int refreshPeriod,
149151
String redisHost, int redisPort, String redisAuth, int checkInterval,
150152
int processorTimeout, long processorDelayMax, boolean httpRequestHandlerEnabled,
151-
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled, String httpRequestHandlerPrefix,
153+
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled,
154+
String micrometerMetricsIdentifier, String httpRequestHandlerPrefix,
152155
String httpRequestHandlerUsername, String httpRequestHandlerPassword,
153156
Integer httpRequestHandlerPort, String httpRequestHandlerUserHeader,
154157
List<QueueConfiguration> queueConfigurations, boolean enableQueueNameDecoding) {
155158
this(address, configurationUpdatedAddress, redisPrefix, processorAddress, publishMetricsAddress, metricStorageName,
156159
metricRefreshPeriod, refreshPeriod, DEFAULT_CONSUMER_LOCK_MULTIPLIER, Collections.singletonList(redisHost), Collections.singletonList(redisPort),
157160
RedisClientType.STANDALONE, redisAuth, null, null, false, checkInterval,
158161
processorTimeout, processorDelayMax, httpRequestHandlerEnabled,
159-
httpRequestHandlerAuthenticationEnabled, micrometerMetricsEnabled, httpRequestHandlerPrefix, httpRequestHandlerUsername,
162+
httpRequestHandlerAuthenticationEnabled, micrometerMetricsEnabled, micrometerMetricsIdentifier, httpRequestHandlerPrefix, httpRequestHandlerUsername,
160163
httpRequestHandlerPassword, httpRequestHandlerPort, httpRequestHandlerUserHeader, queueConfigurations,
161164
enableQueueNameDecoding, DEFAULT_REDIS_MAX_POOL_SIZE, DEFAULT_REDIS_MAX_POOL_WAIT_SIZE,
162165
DEFAULT_REDIS_MAX_PIPELINE_WAIT_SIZE, DEFAULT_QUEUE_SPEED_INTERVAL_SEC, DEFAULT_MEMORY_USAGE_LIMIT_PCT,
@@ -173,15 +176,16 @@ public RedisquesConfiguration(String address, String configurationUpdatedAddress
173176
String publishMetricsAddress, String metricStorageName, int metricRefreshPeriod, int refreshPeriod,
174177
String redisHost, int redisPort, String redisPassword, String redisUser, boolean redisEnableTls,
175178
int checkInterval, int processorTimeout, long processorDelayMax, boolean httpRequestHandlerEnabled,
176-
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled, String httpRequestHandlerPrefix,
179+
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled,
180+
String micrometerMetricsIdentifier, String httpRequestHandlerPrefix,
177181
String httpRequestHandlerUsername, String httpRequestHandlerPassword,
178182
Integer httpRequestHandlerPort, String httpRequestHandlerUserHeader,
179183
List<QueueConfiguration> queueConfigurations, boolean enableQueueNameDecoding) {
180184
this(address, configurationUpdatedAddress, redisPrefix, processorAddress, publishMetricsAddress, metricStorageName,
181185
metricRefreshPeriod, refreshPeriod, DEFAULT_CONSUMER_LOCK_MULTIPLIER, Collections.singletonList(redisHost), Collections.singletonList(redisPort),
182186
RedisClientType.STANDALONE, null, redisPassword, redisUser, redisEnableTls, checkInterval,
183187
processorTimeout, processorDelayMax, httpRequestHandlerEnabled,
184-
httpRequestHandlerAuthenticationEnabled, micrometerMetricsEnabled, httpRequestHandlerPrefix, httpRequestHandlerUsername,
188+
httpRequestHandlerAuthenticationEnabled, micrometerMetricsEnabled, micrometerMetricsIdentifier, httpRequestHandlerPrefix, httpRequestHandlerUsername,
185189
httpRequestHandlerPassword, httpRequestHandlerPort, httpRequestHandlerUserHeader, queueConfigurations,
186190
enableQueueNameDecoding, DEFAULT_REDIS_MAX_POOL_SIZE, DEFAULT_REDIS_MAX_POOL_WAIT_SIZE,
187191
DEFAULT_REDIS_MAX_PIPELINE_WAIT_SIZE, DEFAULT_QUEUE_SPEED_INTERVAL_SEC, DEFAULT_MEMORY_USAGE_LIMIT_PCT,
@@ -198,14 +202,15 @@ public RedisquesConfiguration(String address, String configurationUpdatedAddress
198202
String redisHost, int redisPort, RedisClientType redisClientType, String redisPassword,
199203
String redisUser, boolean redisEnableTls, int checkInterval,
200204
int processorTimeout, long processorDelayMax, boolean httpRequestHandlerEnabled,
201-
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled, String httpRequestHandlerPrefix,
205+
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled,
206+
String micrometerMetricsIdentifier, String httpRequestHandlerPrefix,
202207
String httpRequestHandlerUsername, String httpRequestHandlerPassword,
203208
Integer httpRequestHandlerPort, String httpRequestHandlerUserHeader,
204209
List<QueueConfiguration> queueConfigurations, boolean enableQueueNameDecoding) {
205210
this(address, configurationUpdatedAddress, redisPrefix, processorAddress, publishMetricsAddress, metricStorageName,
206211
metricRefreshPeriod, refreshPeriod, DEFAULT_CONSUMER_LOCK_MULTIPLIER, Collections.singletonList(redisHost), Collections.singletonList(redisPort),
207212
redisClientType, null, redisPassword, redisUser, redisEnableTls, checkInterval, processorTimeout,
208-
processorDelayMax, httpRequestHandlerEnabled, httpRequestHandlerAuthenticationEnabled, micrometerMetricsEnabled, httpRequestHandlerPrefix, httpRequestHandlerUsername,
213+
processorDelayMax, httpRequestHandlerEnabled, httpRequestHandlerAuthenticationEnabled, micrometerMetricsEnabled, micrometerMetricsIdentifier, httpRequestHandlerPrefix, httpRequestHandlerUsername,
209214
httpRequestHandlerPassword, httpRequestHandlerPort, httpRequestHandlerUserHeader, queueConfigurations,
210215
enableQueueNameDecoding, DEFAULT_REDIS_MAX_POOL_SIZE, DEFAULT_REDIS_MAX_POOL_WAIT_SIZE,
211216
DEFAULT_REDIS_MAX_PIPELINE_WAIT_SIZE, DEFAULT_QUEUE_SPEED_INTERVAL_SEC, DEFAULT_MEMORY_USAGE_LIMIT_PCT,
@@ -222,15 +227,16 @@ public RedisquesConfiguration(String address, String configurationUpdatedAddress
222227
int consumerLockMultiplier, String redisHost, int redisPort, RedisClientType redisClientType, String redisPassword,
223228
String redisUser, boolean redisEnableTls, int checkInterval,
224229
int processorTimeout, long processorDelayMax, boolean httpRequestHandlerEnabled,
225-
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled, String httpRequestHandlerPrefix,
230+
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled,
231+
String micrometerMetricsIdentifier, String httpRequestHandlerPrefix,
226232
String httpRequestHandlerUsername, String httpRequestHandlerPassword,
227233
Integer httpRequestHandlerPort, String httpRequestHandlerUserHeader,
228234
List<QueueConfiguration> queueConfigurations, boolean enableQueueNameDecoding) {
229235
this(address, configurationUpdatedAddress, redisPrefix, processorAddress, publishMetricsAddress, metricStorageName,
230236
metricRefreshPeriod, refreshPeriod, consumerLockMultiplier, Collections.singletonList(redisHost), Collections.singletonList(redisPort),
231237
redisClientType, null, redisPassword, redisUser, redisEnableTls, checkInterval, processorTimeout,
232238
processorDelayMax, httpRequestHandlerEnabled,
233-
httpRequestHandlerAuthenticationEnabled, micrometerMetricsEnabled, httpRequestHandlerPrefix, httpRequestHandlerUsername,
239+
httpRequestHandlerAuthenticationEnabled, micrometerMetricsEnabled, micrometerMetricsIdentifier, httpRequestHandlerPrefix, httpRequestHandlerUsername,
234240
httpRequestHandlerPassword, httpRequestHandlerPort, httpRequestHandlerUserHeader, queueConfigurations,
235241
enableQueueNameDecoding, DEFAULT_REDIS_MAX_POOL_SIZE, DEFAULT_REDIS_MAX_POOL_WAIT_SIZE,
236242
DEFAULT_REDIS_MAX_PIPELINE_WAIT_SIZE, DEFAULT_QUEUE_SPEED_INTERVAL_SEC, DEFAULT_MEMORY_USAGE_LIMIT_PCT,
@@ -244,7 +250,7 @@ private RedisquesConfiguration(String address, String configurationUpdatedAddres
244250
int consumerLockMultiplier, List<String> redisHosts, List<Integer> redisPorts, RedisClientType redisClientType,
245251
String redisAuth, String redisPassword, String redisUser, boolean redisEnableTls, int checkInterval,
246252
int processorTimeout, long processorDelayMax, boolean httpRequestHandlerEnabled,
247-
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled,
253+
boolean httpRequestHandlerAuthenticationEnabled, boolean micrometerMetricsEnabled, String micrometerMetricsIdentifier,
248254
String httpRequestHandlerPrefix, String httpRequestHandlerUsername, String httpRequestHandlerPassword,
249255
Integer httpRequestHandlerPort, String httpRequestHandlerUserHeader,
250256
List<QueueConfiguration> queueConfigurations, boolean enableQueueNameDecoding,
@@ -313,6 +319,7 @@ private RedisquesConfiguration(String address, String configurationUpdatedAddres
313319
this.httpRequestHandlerEnabled = httpRequestHandlerEnabled;
314320
this.httpRequestHandlerAuthenticationEnabled = httpRequestHandlerAuthenticationEnabled;
315321
this.micrometerMetricsEnabled = micrometerMetricsEnabled;
322+
this.micrometerMetricsIdentifier = micrometerMetricsIdentifier;
316323
this.httpRequestHandlerPrefix = httpRequestHandlerPrefix;
317324
this.httpRequestHandlerUsername = httpRequestHandlerUsername;
318325
this.httpRequestHandlerPassword = httpRequestHandlerPassword;
@@ -361,7 +368,7 @@ private RedisquesConfiguration(RedisquesConfigurationBuilder builder) {
361368
builder.redisPassword, builder.redisUser, builder.redisEnableTls, builder.checkInterval,
362369
builder.processorTimeout, builder.processorDelayMax, builder.httpRequestHandlerEnabled,
363370
builder.httpRequestHandlerAuthenticationEnabled,
364-
builder.micrometerMetricsEnabled, builder.httpRequestHandlerPrefix,
371+
builder.micrometerMetricsEnabled, builder.micrometerMetricsIdentifier, builder.httpRequestHandlerPrefix,
365372
builder.httpRequestHandlerUsername, builder.httpRequestHandlerPassword, builder.httpRequestHandlerPort,
366373
builder.httpRequestHandlerUserHeader, builder.queueConfigurations,
367374
builder.enableQueueNameDecoding,
@@ -405,6 +412,7 @@ public JsonObject asJsonObject() {
405412
obj.put(PROP_HTTP_REQUEST_HANDLER_ENABLED, getHttpRequestHandlerEnabled());
406413
obj.put(PROP_HTTP_REQUEST_HANDLER_AUTH_ENABLED, getHttpRequestHandlerAuthenticationEnabled());
407414
obj.put(PROP_MICROMETER_METRICS_ENABLED, getMicrometerMetricsEnabled());
415+
obj.put(PROP_MICROMETER_METRICS_IDENTIFIER, getMicrometerMetricsIdentifier());
408416
obj.put(PROP_HTTP_REQUEST_HANDLER_PREFIX, getHttpRequestHandlerPrefix());
409417
obj.put(PROP_HTTP_REQUEST_HANDLER_USERNAME, getHttpRequestHandlerUsername());
410418
obj.put(PROP_HTTP_REQUEST_HANDLER_PASSWORD, getHttpRequestHandlerPassword());
@@ -506,6 +514,9 @@ public static RedisquesConfiguration fromJsonObject(JsonObject json) {
506514
if (json.containsKey(PROP_MICROMETER_METRICS_ENABLED)) {
507515
builder.micrometerMetricsEnabled(json.getBoolean(PROP_MICROMETER_METRICS_ENABLED));
508516
}
517+
if (json.containsKey(PROP_MICROMETER_METRICS_IDENTIFIER)) {
518+
builder.micrometerMetricsIdentifier(json.getString(PROP_MICROMETER_METRICS_IDENTIFIER));
519+
}
509520
if (json.containsKey(PROP_HTTP_REQUEST_HANDLER_PREFIX)) {
510521
builder.httpRequestHandlerPrefix(json.getString(PROP_HTTP_REQUEST_HANDLER_PREFIX));
511522
}
@@ -665,6 +676,10 @@ public boolean getHttpRequestHandlerAuthenticationEnabled() {
665676

666677
public boolean getMicrometerMetricsEnabled() { return micrometerMetricsEnabled; }
667678

679+
public String getMicrometerMetricsIdentifier() {
680+
return micrometerMetricsIdentifier;
681+
}
682+
668683
public String getHttpRequestHandlerPrefix() {
669684
return httpRequestHandlerPrefix;
670685
}
@@ -790,6 +805,7 @@ public static class RedisquesConfigurationBuilder {
790805
private int processorTimeout;
791806
private long processorDelayMax;
792807
private boolean micrometerMetricsEnabled;
808+
private String micrometerMetricsIdentifier;
793809
private boolean httpRequestHandlerEnabled;
794810
private boolean httpRequestHandlerAuthenticationEnabled;
795811
private String httpRequestHandlerPrefix;
@@ -976,6 +992,11 @@ public RedisquesConfigurationBuilder micrometerMetricsEnabled(boolean micrometer
976992
return this;
977993
}
978994

995+
public RedisquesConfigurationBuilder micrometerMetricsIdentifier(String micrometerMetricsIdentifier) {
996+
this.micrometerMetricsIdentifier = micrometerMetricsIdentifier;
997+
return this;
998+
}
999+
9791000
public RedisquesConfigurationBuilder httpRequestHandlerAuthenticationEnabled(boolean httpRequestHandlerAuthenticationEnabled) {
9801001
this.httpRequestHandlerAuthenticationEnabled = httpRequestHandlerAuthenticationEnabled;
9811002
return this;

0 commit comments

Comments
 (0)