From 856c3aa0110cd3723e8dad7f9da07a6d8cca8b77 Mon Sep 17 00:00:00 2001 From: runner Date: Fri, 29 Nov 2024 13:33:10 +0000 Subject: [PATCH 1/6] updating poms for branch'release-4.1.8' with non-snapshot versions --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 464284d..33ba052 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.swisspush redisques - 4.1.8-SNAPSHOT + 4.1.8 redisques A highly scalable redis-persistent queuing system for vertx From 83f364a8cf8b814350c92fcf7e07f6dcbb5a6654 Mon Sep 17 00:00:00 2001 From: runner Date: Fri, 29 Nov 2024 13:33:10 +0000 Subject: [PATCH 2/6] updating poms for 4.1.9-SNAPSHOT development --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 464284d..96064ba 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.swisspush redisques - 4.1.8-SNAPSHOT + 4.1.9-SNAPSHOT redisques A highly scalable redis-persistent queuing system for vertx From f3e78b56e624591be274c8c7a105f0d5610e9ffc Mon Sep 17 00:00:00 2001 From: runner Date: Fri, 29 Nov 2024 13:35:42 +0000 Subject: [PATCH 3/6] updating develop poms to master versions to avoid merge conflicts --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 96064ba..33ba052 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.swisspush redisques - 4.1.9-SNAPSHOT + 4.1.8 redisques A highly scalable redis-persistent queuing system for vertx From 21ab39c64662c5a2d9a42838695c6f47a1738927 Mon Sep 17 00:00:00 2001 From: runner Date: Fri, 29 Nov 2024 13:35:42 +0000 Subject: [PATCH 4/6] Updating develop poms back to pre merge state --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 33ba052..96064ba 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.swisspush redisques - 4.1.8 + 4.1.9-SNAPSHOT redisques A highly scalable redis-persistent queuing system for vertx From d92085c57510ed15740960cc5a994d6b107db04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Weber?= Date: Mon, 2 Dec 2024 15:21:56 +0100 Subject: [PATCH 5/6] #224 Added micrometer identifier option to configuration to distinguish between multiple redisques instances --- README.md | 1 + .../redisques/QueueStatsService.java | 94 ++++++++++++------- .../org/swisspush/redisques/RedisQues.java | 3 +- .../redisques/action/EnqueueAction.java | 8 +- .../redisques/action/LockedEnqueueAction.java | 5 +- .../handler/RedisquesHttpRequestHandler.java | 2 +- .../swisspush/redisques/util/MetricTags.java | 16 ++++ .../redisques/util/QueueActionFactory.java | 7 +- .../util/RedisquesConfiguration.java | 9 +- .../redisques/action/EnqueueActionTest.java | 7 +- .../action/LockedEnqueueActionTest.java | 7 +- .../util/RedisquesConfigurationTest.java | 6 +- 12 files changed, 112 insertions(+), 53 deletions(-) create mode 100644 src/main/java/org/swisspush/redisques/util/MetricTags.java diff --git a/README.md b/README.md index 3689c04..3f0ee6d 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ The following configuration values are available: | redisReconnectDelaySec | 30 | The interval [s] to attempt to reconnect when redis connection is lost. | | redisPoolRecycleTimeoutMs | 180000 | The timeout [ms] when the connection pool is recycled. Use **-1** when having reconnect feature enabled. | | micrometerMetricsEnabled | false | Enable / disable collection of metrics using micrometer | +| micrometerMetricsIdentifier | default | Identifier to track values from multiple redisques instances | | httpRequestHandlerEnabled | false | Enable / disable the HTTP API | | httpRequestHandlerAuthenticationEnabled | false | Enable / disable authentication for the HTTP API | | httpRequestHandlerUsername | | The username for the HTTP API authentication | diff --git a/src/main/java/org/swisspush/redisques/QueueStatsService.java b/src/main/java/org/swisspush/redisques/QueueStatsService.java index f3c66a2..1297b06 100644 --- a/src/main/java/org/swisspush/redisques/QueueStatsService.java +++ b/src/main/java/org/swisspush/redisques/QueueStatsService.java @@ -8,10 +8,7 @@ import io.vertx.core.json.JsonObject; import org.slf4j.Logger; import org.swisspush.redisques.exception.RedisQuesExceptionFactory; -import org.swisspush.redisques.util.DequeueStatistic; -import org.swisspush.redisques.util.DequeueStatisticCollector; -import org.swisspush.redisques.util.MetricMeter; -import org.swisspush.redisques.util.QueueStatisticsCollector; +import org.swisspush.redisques.util.*; import java.util.ArrayList; import java.util.List; @@ -55,14 +52,15 @@ public class QueueStatsService { private final AtomicLong maxQueueSize = new AtomicLong(0); public QueueStatsService( - Vertx vertx, - EventBus eventBus, - String redisquesAddress, - QueueStatisticsCollector queueStatisticsCollector, - DequeueStatisticCollector dequeueStatisticCollector, - RedisQuesExceptionFactory exceptionFactory, - Semaphore incomingRequestQuota, - MeterRegistry meterRegistry + Vertx vertx, + EventBus eventBus, + String redisquesAddress, + QueueStatisticsCollector queueStatisticsCollector, + DequeueStatisticCollector dequeueStatisticCollector, + RedisQuesExceptionFactory exceptionFactory, + Semaphore incomingRequestQuota, + MeterRegistry meterRegistry, + String metricsIdentifier ) { this.vertx = vertx; this.eventBus = eventBus; @@ -72,9 +70,10 @@ public QueueStatsService( this.exceptionFactory = exceptionFactory; this.incomingRequestQuota = incomingRequestQuota; - if(meterRegistry != null) { + if (meterRegistry != null) { Gauge.builder(MetricMeter.MAX_QUEUE_SIZE.getId(), maxQueueSize, AtomicLong::get). - description(MetricMeter.MAX_QUEUE_SIZE.getDescription()). + description(MetricMeter.MAX_QUEUE_SIZE.getDescription()) + .tag(MetricTags.IDENTIFIER.getId(), metricsIdentifier). register(meterRegistry); } } @@ -101,14 +100,23 @@ public void getQueueStats(CTX mCtx, GetQueueStatsMentor mentor) { req0.mCtx = mCtx; req0.mentor = mentor; fetchQueueNamesAndSize(req0, (ex1, req1) -> { - if (ex1 != null) { onDone.accept(ex1, null); return; } + if (ex1 != null) { + onDone.accept(ex1, null); + return; + } // Prepare a list of queue names as it is needed to fetch retryDetails. req1.queueNames = new ArrayList<>(req1.queues.size()); for (Queue q : req1.queues) req1.queueNames.add(q.name); fetchRetryDetails(req1, (ex2, req2) -> { - if (ex2 != null) { onDone.accept(ex2, null); return; } + if (ex2 != null) { + onDone.accept(ex2, null); + return; + } attachDequeueStats(req2, (ex3, req3) -> { - if (ex3 != null) { onDone.accept(ex3, null); return; } + if (ex3 != null) { + onDone.accept(ex3, null); + return; + } onDone.accept(null, req3.queues); }); }); @@ -172,7 +180,7 @@ private void fetchQueueNamesAndSize(GetQueueStatsRequest req, BiConsu } private void collectMaxQueueSize(List queues) { - if(queues.isEmpty()) { + if (queues.isEmpty()) { maxQueueSize.set(0); } else { maxQueueSize.set(queues.get(0).getSize()); @@ -182,7 +190,7 @@ private void collectMaxQueueSize(List queues) { private void fetchRetryDetails(GetQueueStatsRequest req, BiConsumer> onDone) { long begGetQueueStatsMs = currentTimeMillis(); assert req.queueNames != null; - queueStatisticsCollector.getQueueStatistics(req.queueNames).onComplete( ev -> { + queueStatisticsCollector.getQueueStatistics(req.queueNames).onComplete(ev -> { req.queueNames = null; // <- no longer needed long durGetQueueStatsMs = currentTimeMillis() - begGetQueueStatsMs; log.debug("queueStatisticsCollector.getQueueStatistics() took {}ms", durGetQueueStatsMs); @@ -244,17 +252,32 @@ public static class Queue { private Long lastDequeueAttemptEpochMs; private Long lastDequeueSuccessEpochMs; private Long nextDequeueDueTimestampEpochMs; - private Queue(String name, long size){ + + private Queue(String name, long size) { assert name != null; this.name = name; this.size = size; } - public String getName() { return name; } - public long getSize() { return size; } - public Long getLastDequeueAttemptEpochMs() { return lastDequeueAttemptEpochMs; } - public Long getLastDequeueSuccessEpochMs() { return lastDequeueSuccessEpochMs; } - public Long getNextDequeueDueTimestampEpochMs() { return nextDequeueDueTimestampEpochMs; } + public String getName() { + return name; + } + + public long getSize() { + return size; + } + + public Long getLastDequeueAttemptEpochMs() { + return lastDequeueAttemptEpochMs; + } + + public Long getLastDequeueSuccessEpochMs() { + return lastDequeueSuccessEpochMs; + } + + public Long getNextDequeueDueTimestampEpochMs() { + return nextDequeueDueTimestampEpochMs; + } } @@ -262,9 +285,8 @@ private Queue(String name, long size){ *

Mentors fetching operations and so provides the fetcher the required * information. Finally it also receives the operations result.

* - * @param - * The context object of choice handled back to each callback so the mentor - * knows about what request the fetcher is talking. + * @param The context object of choice handled back to each callback so the mentor + * knows about what request the fetcher is talking. */ public static interface GetQueueStatsMentor { @@ -272,16 +294,20 @@ public static interface GetQueueStatsMentor { *

Returning true means that all queues will be present in the result. If * false, empty queues won't show up the result.

* - * @param ctx See {@link GetQueueStatsMentor}. + * @param ctx See {@link GetQueueStatsMentor}. */ - public boolean includeEmptyQueues( CTX ctx ); + public boolean includeEmptyQueues(CTX ctx); - /**

Limits the result to the largest N queues.

*/ - public int limit( CTX ctx ); + /** + *

Limits the result to the largest N queues.

+ */ + public int limit(CTX ctx); - public String filter( CTX ctx); + public String filter(CTX ctx); - /**

Called ONCE with the final result.

*/ + /** + *

Called ONCE with the final result.

+ */ public void onQueueStatistics(List queues, CTX ctx); /** diff --git a/src/main/java/org/swisspush/redisques/RedisQues.java b/src/main/java/org/swisspush/redisques/RedisQues.java index c95910b..0091990 100644 --- a/src/main/java/org/swisspush/redisques/RedisQues.java +++ b/src/main/java/org/swisspush/redisques/RedisQues.java @@ -388,8 +388,9 @@ private void initMicrometerMetrics(RedisquesConfiguration modConfig) { if(meterRegistry == null) { meterRegistry = BackendRegistries.getDefaultNow(); } + String metricsIdentifier = modConfig.getMicrometerMetricsIdentifier(); dequeueCounter = Counter.builder(MetricMeter.DEQUEUE.getId()) - .description(MetricMeter.DEQUEUE.getDescription()).register(meterRegistry); + .description(MetricMeter.DEQUEUE.getDescription()).tag(MetricTags.IDENTIFIER.getId(), metricsIdentifier).register(meterRegistry); String address = modConfig.getAddress(); int metricRefreshPeriod = modConfig.getMetricRefreshPeriod(); diff --git a/src/main/java/org/swisspush/redisques/action/EnqueueAction.java b/src/main/java/org/swisspush/redisques/action/EnqueueAction.java index f227865..9e04a11 100644 --- a/src/main/java/org/swisspush/redisques/action/EnqueueAction.java +++ b/src/main/java/org/swisspush/redisques/action/EnqueueAction.java @@ -25,7 +25,7 @@ public EnqueueAction( Vertx vertx, RedisProvider redisProvider, String address, String queuesKey, String queuesPrefix, String consumersPrefix, String locksKey, List queueConfigurations, RedisQuesExceptionFactory exceptionFactory, QueueStatisticsCollector queueStatisticsCollector, Logger log, - MemoryUsageProvider memoryUsageProvider, int memoryUsageLimitPercent, MeterRegistry meterRegistry + MemoryUsageProvider memoryUsageProvider, int memoryUsageLimitPercent, MeterRegistry meterRegistry, String metricsIdentifier ) { super(vertx, redisProvider, address, queuesKey, queuesPrefix, consumersPrefix, locksKey, queueConfigurations, exceptionFactory, queueStatisticsCollector, log); @@ -33,8 +33,10 @@ public EnqueueAction( this.memoryUsageLimitPercent = memoryUsageLimitPercent; if(meterRegistry != null) { - enqueueCounterSuccess = Counter.builder(MetricMeter.ENQUEUE_SUCCESS.getId()).description(MetricMeter.ENQUEUE_SUCCESS.getDescription()).register(meterRegistry); - enqueueCounterFail = Counter.builder(MetricMeter.ENQUEUE_FAIL.getId()).description(MetricMeter.ENQUEUE_FAIL.getDescription()).register(meterRegistry); + enqueueCounterSuccess = Counter.builder(MetricMeter.ENQUEUE_SUCCESS.getId()).description(MetricMeter.ENQUEUE_SUCCESS.getDescription()) + .tag(MetricTags.IDENTIFIER.getId(), metricsIdentifier).register(meterRegistry); + enqueueCounterFail = Counter.builder(MetricMeter.ENQUEUE_FAIL.getId()).description(MetricMeter.ENQUEUE_FAIL.getDescription()) + .tag(MetricTags.IDENTIFIER.getId(), metricsIdentifier).register(meterRegistry); } } diff --git a/src/main/java/org/swisspush/redisques/action/LockedEnqueueAction.java b/src/main/java/org/swisspush/redisques/action/LockedEnqueueAction.java index bc510e3..12416fe 100644 --- a/src/main/java/org/swisspush/redisques/action/LockedEnqueueAction.java +++ b/src/main/java/org/swisspush/redisques/action/LockedEnqueueAction.java @@ -23,10 +23,11 @@ public LockedEnqueueAction(Vertx vertx, RedisProvider redisProvider, String consumersPrefix, String locksKey, List queueConfigurations, RedisQuesExceptionFactory exceptionFactory, QueueStatisticsCollector queueStatisticsCollector, Logger log, - MemoryUsageProvider memoryUsageProvider, int memoryUsageLimitPercent, MeterRegistry meterRegistry) { + MemoryUsageProvider memoryUsageProvider, int memoryUsageLimitPercent, MeterRegistry meterRegistry, + String metricsIdentifier) { super(vertx, redisProvider, address, queuesKey, queuesPrefix, consumersPrefix, locksKey, queueConfigurations, exceptionFactory, queueStatisticsCollector, log, memoryUsageProvider, - memoryUsageLimitPercent, meterRegistry); + memoryUsageLimitPercent, meterRegistry, metricsIdentifier); } @Override diff --git a/src/main/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandler.java b/src/main/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandler.java index 6921b23..a7e6668 100644 --- a/src/main/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandler.java @@ -140,7 +140,7 @@ private RedisquesHttpRequestHandler( this.exceptionFactory = exceptionFactory; this.queueStatsService = new QueueStatsService( vertx, eventBus, redisquesAddress, queueStatisticsCollector, dequeueStatisticCollector, - exceptionFactory, queueStatsRequestQuota, meterRegistry); + exceptionFactory, queueStatsRequestQuota, meterRegistry, modConfig.getMicrometerMetricsIdentifier()); final String prefix = modConfig.getHttpRequestHandlerPrefix(); diff --git a/src/main/java/org/swisspush/redisques/util/MetricTags.java b/src/main/java/org/swisspush/redisques/util/MetricTags.java new file mode 100644 index 0000000..7e948dc --- /dev/null +++ b/src/main/java/org/swisspush/redisques/util/MetricTags.java @@ -0,0 +1,16 @@ +package org.swisspush.redisques.util; + +public enum MetricTags { + + IDENTIFIER("identifier"); + + private final String id; + + MetricTags(String id) { + this.id = id; + } + + public String getId() { + return id; + } +} diff --git a/src/main/java/org/swisspush/redisques/util/QueueActionFactory.java b/src/main/java/org/swisspush/redisques/util/QueueActionFactory.java index 145e4da..1ed2e26 100644 --- a/src/main/java/org/swisspush/redisques/util/QueueActionFactory.java +++ b/src/main/java/org/swisspush/redisques/util/QueueActionFactory.java @@ -23,6 +23,7 @@ public class QueueActionFactory { private final QueueStatisticsCollector queueStatisticsCollector; private final int memoryUsageLimitPercent; private final MeterRegistry meterRegistry; + private final String metricsIdentifier; private final MemoryUsageProvider memoryUsageProvider; private final RedisQuesExceptionFactory exceptionFactory; private final Semaphore getQueuesItemsCountRedisRequestQuota; @@ -60,6 +61,8 @@ public QueueActionFactory( this.memoryUsageLimitPercent = configurationProvider.configuration().getMemoryUsageLimitPercent(); this.getQueuesItemsCountRedisRequestQuota = getQueuesItemsCountRedisRequestQuota; this.meterRegistry = meterRegistry; + + metricsIdentifier = configurationProvider.configuration().getMicrometerMetricsIdentifier(); } public QueueAction buildQueueAction(RedisquesAPI.QueueOperation queueOperation){ @@ -101,11 +104,11 @@ public QueueAction buildQueueAction(RedisquesAPI.QueueOperation queueOperation){ case enqueue: return new EnqueueAction(vertx, redisProvider, address, queuesKey, queuesPrefix, consumersPrefix, locksKey, queueConfigurations, exceptionFactory, queueStatisticsCollector, log, - memoryUsageProvider, memoryUsageLimitPercent, meterRegistry); + memoryUsageProvider, memoryUsageLimitPercent, meterRegistry, metricsIdentifier); case lockedEnqueue: return new LockedEnqueueAction(vertx, redisProvider, address, queuesKey, queuesPrefix, consumersPrefix, locksKey, queueConfigurations, exceptionFactory, queueStatisticsCollector, log, - memoryUsageProvider, memoryUsageLimitPercent, meterRegistry); + memoryUsageProvider, memoryUsageLimitPercent, meterRegistry, metricsIdentifier); case getLock: return new GetLockAction(vertx, redisProvider, address, queuesKey, queuesPrefix, consumersPrefix, locksKey, queueConfigurations, exceptionFactory, queueStatisticsCollector, log); diff --git a/src/main/java/org/swisspush/redisques/util/RedisquesConfiguration.java b/src/main/java/org/swisspush/redisques/util/RedisquesConfiguration.java index 2175062..93e731d 100644 --- a/src/main/java/org/swisspush/redisques/util/RedisquesConfiguration.java +++ b/src/main/java/org/swisspush/redisques/util/RedisquesConfiguration.java @@ -64,6 +64,7 @@ public class RedisquesConfiguration { private static final int DEFAULT_PROCESSOR_TIMEOUT_MS = 240000; // 240s private static final int DEFAULT_METRIC_REFRESH_PERIOD_S = 10; // 10s private static final String DEFAULT_METRIC_STORAGE_NAME = "queue"; + private static final String DEFAULT_MICROMETER_METRICS_IDENTIFIER = "default"; private static final long DEFAULT_PROCESSOR_DELAY_MAX = 0; private static final int DEFAULT_REDIS_MAX_POOL_SIZE = 200; private static final int DEFAULT_REDIS_RECONNECT_ATTEMPTS = 0; @@ -277,6 +278,13 @@ private RedisquesConfiguration(String address, String configurationUpdatedAddres this.maxPipelineWaitSize = maxPipelineWaitSize; Logger log = LoggerFactory.getLogger(RedisquesConfiguration.class); + String maybeEmptyMicrometerMetricsIdentifier = Strings.nullToEmpty(micrometerMetricsIdentifier).trim(); + if(Strings.isNullOrEmpty(maybeEmptyMicrometerMetricsIdentifier)) { + this.micrometerMetricsIdentifier = DEFAULT_MICROMETER_METRICS_IDENTIFIER; + } else { + this.micrometerMetricsIdentifier = maybeEmptyMicrometerMetricsIdentifier; + } + String maybeEmptyMetricStorageName = Strings.nullToEmpty(metricStorageName).trim(); if(Strings.isNullOrEmpty(maybeEmptyMetricStorageName)) { this.metricStorageName = DEFAULT_METRIC_STORAGE_NAME; @@ -319,7 +327,6 @@ private RedisquesConfiguration(String address, String configurationUpdatedAddres this.httpRequestHandlerEnabled = httpRequestHandlerEnabled; this.httpRequestHandlerAuthenticationEnabled = httpRequestHandlerAuthenticationEnabled; this.micrometerMetricsEnabled = micrometerMetricsEnabled; - this.micrometerMetricsIdentifier = micrometerMetricsIdentifier; this.httpRequestHandlerPrefix = httpRequestHandlerPrefix; this.httpRequestHandlerUsername = httpRequestHandlerUsername; this.httpRequestHandlerPassword = httpRequestHandlerPassword; diff --git a/src/test/java/org/swisspush/redisques/action/EnqueueActionTest.java b/src/test/java/org/swisspush/redisques/action/EnqueueActionTest.java index 6c1aee9..58fb3cf 100644 --- a/src/test/java/org/swisspush/redisques/action/EnqueueActionTest.java +++ b/src/test/java/org/swisspush/redisques/action/EnqueueActionTest.java @@ -15,6 +15,7 @@ import org.mockito.Mockito; import org.slf4j.Logger; import org.swisspush.redisques.util.MetricMeter; +import org.swisspush.redisques.util.MetricTags; import org.swisspush.redisques.util.QueueStatisticsCollector; import java.util.ArrayList; @@ -40,12 +41,12 @@ public class EnqueueActionTest extends AbstractQueueActionTest { public void setup() { super.setup(); MeterRegistry meterRegistry = new SimpleMeterRegistry(); - enqueueCounterSuccess = meterRegistry.counter(MetricMeter.ENQUEUE_SUCCESS.getId()); - enqueueCounterFail = meterRegistry.counter(MetricMeter.ENQUEUE_FAIL.getId()); + enqueueCounterSuccess = meterRegistry.counter(MetricMeter.ENQUEUE_SUCCESS.getId(), MetricTags.IDENTIFIER.getId(), "foo"); + enqueueCounterFail = meterRegistry.counter(MetricMeter.ENQUEUE_FAIL.getId(), MetricTags.IDENTIFIER.getId(), "foo"); action = new EnqueueAction(vertx, redisProvider, "addr", "q-", "prefix-", "c-", "l-", new ArrayList<>(), exceptionFactory, Mockito.mock(QueueStatisticsCollector.class), - Mockito.mock(Logger.class), memoryUsageProvider, 80, meterRegistry); + Mockito.mock(Logger.class), memoryUsageProvider, 80, meterRegistry, "foo"); } @Test diff --git a/src/test/java/org/swisspush/redisques/action/LockedEnqueueActionTest.java b/src/test/java/org/swisspush/redisques/action/LockedEnqueueActionTest.java index ba22d86..0967e5f 100644 --- a/src/test/java/org/swisspush/redisques/action/LockedEnqueueActionTest.java +++ b/src/test/java/org/swisspush/redisques/action/LockedEnqueueActionTest.java @@ -14,6 +14,7 @@ import org.mockito.Mockito; import org.slf4j.Logger; import org.swisspush.redisques.util.MetricMeter; +import org.swisspush.redisques.util.MetricTags; import org.swisspush.redisques.util.QueueStatisticsCollector; import java.util.ArrayList; @@ -37,12 +38,12 @@ public class LockedEnqueueActionTest extends AbstractQueueActionTest { public void setup() { super.setup(); MeterRegistry meterRegistry = new SimpleMeterRegistry(); - enqueueCounterSuccess = meterRegistry.counter(MetricMeter.ENQUEUE_SUCCESS.getId()); - enqueueCounterFail = meterRegistry.counter(MetricMeter.ENQUEUE_FAIL.getId()); + enqueueCounterSuccess = meterRegistry.counter(MetricMeter.ENQUEUE_SUCCESS.getId(), MetricTags.IDENTIFIER.getId(), "foo"); + enqueueCounterFail = meterRegistry.counter(MetricMeter.ENQUEUE_FAIL.getId(), MetricTags.IDENTIFIER.getId(), "foo"); action = new LockedEnqueueAction(vertx, redisProvider, "addr", "q-", "prefix-", "c-", "l-", new ArrayList<>(), exceptionFactory, Mockito.mock(QueueStatisticsCollector.class), - Mockito.mock(Logger.class), memoryUsageProvider, 80, meterRegistry); + Mockito.mock(Logger.class), memoryUsageProvider, 80, meterRegistry, "foo"); } @Test diff --git a/src/test/java/org/swisspush/redisques/util/RedisquesConfigurationTest.java b/src/test/java/org/swisspush/redisques/util/RedisquesConfigurationTest.java index 5c0de28..d11dd84 100644 --- a/src/test/java/org/swisspush/redisques/util/RedisquesConfigurationTest.java +++ b/src/test/java/org/swisspush/redisques/util/RedisquesConfigurationTest.java @@ -42,7 +42,7 @@ public void testDefaultConfiguration(TestContext testContext) { testContext.assertFalse(config.getHttpRequestHandlerEnabled()); testContext.assertFalse(config.getHttpRequestHandlerAuthenticationEnabled()); testContext.assertFalse(config.getMicrometerMetricsEnabled()); - testContext.assertNull(config.getMicrometerMetricsIdentifier()); + testContext.assertEquals(config.getMicrometerMetricsIdentifier(), "default"); testContext.assertEquals(config.getHttpRequestHandlerPrefix(), "/queuing"); testContext.assertNull(config.getHttpRequestHandlerUsername()); testContext.assertNull(config.getHttpRequestHandlerPassword()); @@ -149,7 +149,7 @@ public void testGetDefaultAsJsonObject(TestContext testContext) { testContext.assertFalse(json.getBoolean(PROP_HTTP_REQUEST_HANDLER_ENABLED)); testContext.assertFalse(json.getBoolean(PROP_HTTP_REQUEST_HANDLER_AUTH_ENABLED)); testContext.assertFalse(json.getBoolean(PROP_MICROMETER_METRICS_ENABLED)); - testContext.assertNull(json.getString(PROP_MICROMETER_METRICS_IDENTIFIER)); + testContext.assertEquals(json.getString(PROP_MICROMETER_METRICS_IDENTIFIER), "default"); testContext.assertEquals(json.getString(PROP_HTTP_REQUEST_HANDLER_PREFIX), "/queuing"); testContext.assertNull(json.getString(PROP_HTTP_REQUEST_HANDLER_USERNAME)); testContext.assertNull(json.getString(PROP_HTTP_REQUEST_HANDLER_PASSWORD)); @@ -264,7 +264,7 @@ public void testGetDefaultFromJsonObject(TestContext testContext) { testContext.assertFalse(config.getHttpRequestHandlerEnabled()); testContext.assertFalse(config.getHttpRequestHandlerAuthenticationEnabled()); testContext.assertFalse(config.getMicrometerMetricsEnabled()); - testContext.assertNull(config.getMicrometerMetricsIdentifier()); + testContext.assertEquals(config.getMicrometerMetricsIdentifier(), "default"); testContext.assertEquals(config.getHttpRequestHandlerPrefix(), "/queuing"); testContext.assertNull(config.getHttpRequestHandlerUsername()); testContext.assertNull(config.getHttpRequestHandlerPassword()); From 4a1a4b328dfbeb415c8caa2ae528d9b6919fbd8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Weber?= Date: Mon, 2 Dec 2024 15:28:47 +0100 Subject: [PATCH 6/6] #224 Added micrometer identifier option to configuration to distinguish between multiple redisques instances --- src/test/java/org/swisspush/redisques/RedisQuesTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/swisspush/redisques/RedisQuesTest.java b/src/test/java/org/swisspush/redisques/RedisQuesTest.java index a3eab6c..7dc621b 100644 --- a/src/test/java/org/swisspush/redisques/RedisQuesTest.java +++ b/src/test/java/org/swisspush/redisques/RedisQuesTest.java @@ -37,6 +37,8 @@ public class RedisQuesTest extends AbstractTestCase { private Counter enqueueCounterFail; private Counter dequeueCounter; + private final String metricsIdentifier = "foo"; + @Rule public Timeout rule = Timeout.seconds(50); @@ -47,6 +49,7 @@ public void deployRedisques(TestContext context) { JsonObject config = RedisquesConfiguration.with() .processorAddress(PROCESSOR_ADDRESS) .micrometerMetricsEnabled(true) + .micrometerMetricsIdentifier(metricsIdentifier) .refreshPeriod(2) .publishMetricsAddress("my-metrics-eb-address") .metricStorageName("foobar") @@ -61,9 +64,9 @@ public void deployRedisques(TestContext context) { .asJsonObject(); MeterRegistry meterRegistry = new SimpleMeterRegistry(); - enqueueCounterSuccess = meterRegistry.counter(MetricMeter.ENQUEUE_SUCCESS.getId()); - enqueueCounterFail = meterRegistry.counter(MetricMeter.ENQUEUE_FAIL.getId()); - dequeueCounter = meterRegistry.counter(MetricMeter.DEQUEUE.getId()); + enqueueCounterSuccess = meterRegistry.counter(MetricMeter.ENQUEUE_SUCCESS.getId(), MetricTags.IDENTIFIER.getId(), metricsIdentifier); + enqueueCounterFail = meterRegistry.counter(MetricMeter.ENQUEUE_FAIL.getId(), MetricTags.IDENTIFIER.getId(), metricsIdentifier); + dequeueCounter = meterRegistry.counter(MetricMeter.DEQUEUE.getId(), MetricTags.IDENTIFIER.getId(), metricsIdentifier); memoryUsageProvider = new TestMemoryUsageProvider(Optional.of(50)); redisQues = RedisQues.builder()