From 9a35ffe337d201bfb235d4335700dc08c57eed23 Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Thu, 15 Aug 2024 17:38:16 -0400 Subject: [PATCH 01/11] add metrics for config push events --- .../ep/common/messages/CommandMessage.java | 8 ++++++ .../ep/common/metrics/MetricConstants.java | 14 +++++++++++ .../agent/command/CommandManager.java | 25 ++++++++++++++++++- .../subscriber/CommandMessageHandler.java | 14 ++++++++++- .../ep/event/management/agent/TestConfig.java | 7 ++++-- .../plugin/command/model/CommandRequest.java | 15 +++++++++++ 6 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 service/application/src/main/java/com/solace/maas/ep/common/metrics/MetricConstants.java diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/CommandMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/CommandMessage.java index 4755c295..7f1d9e29 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/CommandMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/CommandMessage.java @@ -66,4 +66,12 @@ public CommandMessage(String serviceId, public String toLog() { return null; } + + public String getType() { + return "CommandMessage"; + } + + public void setType() { + // Intentionally left blank + } } diff --git a/service/application/src/main/java/com/solace/maas/ep/common/metrics/MetricConstants.java b/service/application/src/main/java/com/solace/maas/ep/common/metrics/MetricConstants.java new file mode 100644 index 00000000..9b24ef6c --- /dev/null +++ b/service/application/src/main/java/com/solace/maas/ep/common/metrics/MetricConstants.java @@ -0,0 +1,14 @@ +package com.solace.maas.ep.common.metrics; + +public class MetricConstants { + public static final String MAAS_EMA_EVENT_SENT = "maas.ema.event.sent"; + public static final String MAAS_EMA_EVENT_RECEIVED = "maas.ema.event.received"; + public static final String MAAS_EMA_EVENT_PRECYCLE_TIME = "maas.ema.event.pre_cycle_time"; + public static final String MAAS_EMA_EVENT_CYCLE_TIME = "maas.ema.event.cycle_time"; + public static final String ENTITY_TYPE_TAG = "entity_type"; + public static final String STATUS_TAG = "status"; + public static final String ORG_ID_TAG = "org_id"; + public static final String PRECYCLE_TIME_DESCRIPTION = "The producer latency of events. Measures the time from creation to when we pick up the " + + "event from the queue."; + public static final String CYCLE_TIME_DESCRIPTION = "The producer throughput of events. Measures the time taken to process an event."; +} diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java index 6aef42e3..34a91d07 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java @@ -15,6 +15,8 @@ import com.solace.maas.ep.event.management.agent.processor.CommandLogStreamingProcessor; import com.solace.maas.ep.event.management.agent.publisher.CommandPublisher; import com.solace.maas.ep.event.management.agent.util.MdcTaskDecorator; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.Timer; import lombok.extern.slf4j.Slf4j; import org.slf4j.MDC; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -24,14 +26,22 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.time.Instant; import java.time.OffsetDateTime; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; +import static com.solace.maas.ep.common.metrics.MetricConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.MetricConstants.MAAS_EMA_EVENT_CYCLE_TIME; +import static com.solace.maas.ep.common.metrics.MetricConstants.MAAS_EMA_EVENT_SENT; +import static com.solace.maas.ep.common.metrics.MetricConstants.ORG_ID_TAG; +import static com.solace.maas.ep.common.metrics.MetricConstants.STATUS_TAG; import static com.solace.maas.ep.event.management.agent.constants.Command.COMMAND_CORRELATION_ID; import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.ACTOR_ID; import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.TRACE_ID; @@ -49,18 +59,21 @@ public class CommandManager { private final EventPortalProperties eventPortalProperties; private final ThreadPoolTaskExecutor configPushPool; private final Optional commandLogStreamingProcessorOpt; + private final MeterRegistry meterRegistry; public CommandManager(TerraformManager terraformManager, CommandMapper commandMapper, CommandPublisher commandPublisher, MessagingServiceDelegateService messagingServiceDelegateService, EventPortalProperties eventPortalProperties, - Optional commandLogStreamingProcessorOpt) { + Optional commandLogStreamingProcessorOpt, + MeterRegistry meterRegistry) { this.terraformManager = terraformManager; this.commandMapper = commandMapper; this.commandPublisher = commandPublisher; this.messagingServiceDelegateService = messagingServiceDelegateService; this.eventPortalProperties = eventPortalProperties; + this.meterRegistry = meterRegistry; configPushPool = new ThreadPoolTaskExecutor(); configPushPool.setCorePoolSize(eventPortalProperties.getCommandThreadPoolMinSize()); configPushPool.setMaxPoolSize(eventPortalProperties.getCommandThreadPoolMaxSize()); @@ -73,6 +86,7 @@ public CommandManager(TerraformManager terraformManager, public void execute(CommandMessage request) { CommandRequest requestBO = commandMapper.map(request); + requestBO.setCreatedTime(Instant.now()); CompletableFuture.runAsync(() -> configPush(requestBO), configPushPool) .exceptionally(e -> { log.error("Error running command", e); @@ -221,6 +235,15 @@ private void finalizeAndSendResponse(CommandRequest request) { response.setTraceId(MDC.get(TRACE_ID)); response.setActorId(MDC.get(ACTOR_ID)); commandPublisher.sendCommandResponse(response, topicVars); + meterRegistry.counter(MAAS_EMA_EVENT_SENT, ENTITY_TYPE_TAG, response.getType(), + ORG_ID_TAG, response.getOrgId(), STATUS_TAG, response.getStatus().name()).increment(); + Timer jobCycleTime = Timer + .builder(MAAS_EMA_EVENT_CYCLE_TIME) + .tag(ORG_ID_TAG, response.getOrgId()) + .tag(STATUS_TAG, request.getStatus().name()) + .tag(ENTITY_TYPE_TAG, response.getType()) + .register(meterRegistry); + jobCycleTime.record(request.getLifetime(ChronoUnit.MILLIS), TimeUnit.MILLISECONDS); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java index e64ea5b3..47fe10c0 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java @@ -3,27 +3,39 @@ import com.solace.maas.ep.common.messages.CommandMessage; import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration; import com.solace.maas.ep.event.management.agent.subscriber.messageProcessors.CommandMessageProcessor; +import io.micrometer.core.instrument.MeterRegistry; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; +import static com.solace.maas.ep.common.metrics.MetricConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.MetricConstants.MAAS_EMA_EVENT_RECEIVED; +import static com.solace.maas.ep.common.metrics.MetricConstants.ORG_ID_TAG; +import static com.solace.maas.ep.common.metrics.MetricConstants.STATUS_TAG; + @Slf4j @Component @ConditionalOnExpression("${event-portal.gateway.messaging.standalone:true}== false && ${event-portal.managed:false} == false") public class CommandMessageHandler extends SolaceDirectMessageHandler { + private final MeterRegistry meterRegistry; private final CommandMessageProcessor commandMessageProcessor; public CommandMessageHandler( SolaceConfiguration solaceConfiguration, - SolaceSubscriber solaceSubscriber, CommandMessageProcessor commandMessageProcessor) { + SolaceSubscriber solaceSubscriber, + CommandMessageProcessor commandMessageProcessor, + MeterRegistry meterRegistry) { super(solaceConfiguration.getTopicPrefix() + "command/v1/>", solaceSubscriber); + this.meterRegistry = meterRegistry; this.commandMessageProcessor = commandMessageProcessor; } @Override public void receiveMessage(String destinationName, CommandMessage message) { log.debug("receiveMessage {}\n{}", destinationName, message); + meterRegistry.counter(MAAS_EMA_EVENT_RECEIVED, ENTITY_TYPE_TAG, message.getType(), + ORG_ID_TAG, message.getOrgId(), STATUS_TAG, message.getStatus().name()).increment(); commandMessageProcessor.processMessage(message); } } diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java index c9821678..55d7d51f 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/TestConfig.java @@ -25,6 +25,7 @@ import com.solace.maas.ep.event.management.agent.util.config.idgenerator.IDGeneratorProperties; import com.solace.messaging.publisher.OutboundMessageBuilder; import com.solace.messaging.resources.Topic; +import io.micrometer.core.instrument.MeterRegistry; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.ProducerTemplate; @@ -167,14 +168,16 @@ public CommandManager getCommandManager(TerraformManager terraformManager, CommandPublisher commandPublisher, MessagingServiceDelegateService messagingServiceDelegateService, EventPortalProperties eventPortalProperties, - Optional commandLogStreamingProcessor) { + Optional commandLogStreamingProcessor, + MeterRegistry meterRegistry) { return new CommandManager( terraformManager, commandMapper, commandPublisher, messagingServiceDelegateService, eventPortalProperties, - commandLogStreamingProcessor + commandLogStreamingProcessor, + meterRegistry ); } diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/command/model/CommandRequest.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/command/model/CommandRequest.java index 6ad491c5..e8909fd5 100644 --- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/command/model/CommandRequest.java +++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/command/model/CommandRequest.java @@ -6,6 +6,8 @@ import lombok.NoArgsConstructor; import org.apache.commons.collections4.CollectionUtils; +import java.time.Instant; +import java.time.temporal.TemporalUnit; import java.util.List; @Data @@ -18,6 +20,19 @@ public class CommandRequest { private String serviceId; private JobStatus status; private List commandBundles; + private Instant createdTime; + private Instant updatedTime; + + public long getLifetime(TemporalUnit timeUnit) { + if (createdTime == null) { + // micrometer won't record negative numbers + return -1L; + } + if (updatedTime == null) { + return createdTime.until(Instant.now(), timeUnit); + } + return createdTime.until(updatedTime, timeUnit); + } public void determineStatus() { boolean hasAtLeastOneError = false; From 05cdd97c6c4dc5e082309136ce35c756bc9efb1e Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Wed, 21 Aug 2024 12:49:44 -0400 Subject: [PATCH 02/11] add metrics for scan and remove unnecessary metrics for standalone related modes --- .../ep/common/messages/HeartbeatMessage.java | 8 +++++++ .../common/messages/ScanCommandMessage.java | 10 ++++++-- .../messages/ScanDataImportMessage.java | 8 +++++++ .../ep/common/metrics/MetricConstants.java | 14 ----------- .../metrics/ObservabilityConstants.java | 21 +++++++++++++++++ .../agent/command/CommandManager.java | 14 +++++------ .../agent/publisher/HeartbeatGenerator.java | 23 +++++++++++++++++-- .../agent/publisher/ScanDataPublisher.java | 21 +++++++++++++++-- .../agent/publisher/ScanStatusPublisher.java | 19 ++++++++++++++- .../agent/scanManager/ScanManager.java | 4 ++-- .../management/agent/service/ScanService.java | 22 +++++++++++++++--- .../subscriber/CommandMessageHandler.java | 10 ++++---- .../subscriber/HeartbeatMessageHandler.java | 7 +++++- .../subscriber/ScanCommandMessageHandler.java | 12 +++++++++- .../ScanDataPublisherRouteBuilderTests.java | 4 +++- .../subscriber/MessageReceiverTests.java | 12 ++++++---- .../plugin/publisher/SolacePublisher.java | 4 +++- 17 files changed, 167 insertions(+), 46 deletions(-) delete mode 100644 service/application/src/main/java/com/solace/maas/ep/common/metrics/MetricConstants.java create mode 100644 service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java index 83a591f0..ed76467a 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java @@ -33,4 +33,12 @@ public HeartbeatMessage(String runtimeAgentId, String timestamp, String runtime public String toLog() { return null; } + + public String getType() { + return "HeartbeatMessage"; + } + + public void setType() { + // Intentionally left blank + } } diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java index cfb17c9f..54fc3e23 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java @@ -49,10 +49,16 @@ public ScanCommandMessage(String messagingServiceId, this(messagingServiceId, scanId, scanTypes, destinations, null); } - - @Override public String toLog() { return null; } + + public String getType() { + return "ScanCommandMessage"; + } + + public void setType() { + // Intentionally left blank + } } diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java index f7f7e2a8..71d38dd4 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java @@ -45,4 +45,12 @@ public ScanDataImportMessage(String orgId, String scanId, String traceId, String public String toLog() { return null; } + + public String getType() { + return "ScanDataImportMessage"; + } + + public void setType() { + // Intentionally left blank + } } diff --git a/service/application/src/main/java/com/solace/maas/ep/common/metrics/MetricConstants.java b/service/application/src/main/java/com/solace/maas/ep/common/metrics/MetricConstants.java deleted file mode 100644 index 9b24ef6c..00000000 --- a/service/application/src/main/java/com/solace/maas/ep/common/metrics/MetricConstants.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.solace.maas.ep.common.metrics; - -public class MetricConstants { - public static final String MAAS_EMA_EVENT_SENT = "maas.ema.event.sent"; - public static final String MAAS_EMA_EVENT_RECEIVED = "maas.ema.event.received"; - public static final String MAAS_EMA_EVENT_PRECYCLE_TIME = "maas.ema.event.pre_cycle_time"; - public static final String MAAS_EMA_EVENT_CYCLE_TIME = "maas.ema.event.cycle_time"; - public static final String ENTITY_TYPE_TAG = "entity_type"; - public static final String STATUS_TAG = "status"; - public static final String ORG_ID_TAG = "org_id"; - public static final String PRECYCLE_TIME_DESCRIPTION = "The producer latency of events. Measures the time from creation to when we pick up the " + - "event from the queue."; - public static final String CYCLE_TIME_DESCRIPTION = "The producer throughput of events. Measures the time taken to process an event."; -} diff --git a/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java b/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java new file mode 100644 index 00000000..08ac73b2 --- /dev/null +++ b/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java @@ -0,0 +1,21 @@ +package com.solace.maas.ep.common.metrics; + +public class ObservabilityConstants { + private ObservabilityConstants() {} + + public static final String MAAS_EMA_SCAN_EVENT_SENT = "maas.ema.scan_event.sent"; + public static final String MAAS_EMA_CONFIG_PUSH_EVENT_SENT = "maas.ema.config_push_event.sent"; + public static final String MAAS_EMA_HEARTBEAT_EVENT_SENT = "maas.ema.heartbeat_event.sent"; + + public static final String MAAS_EMA_SCAN_EVENT_RECEIVED = "maas.ema.scan_event.received"; + public static final String MAAS_EMA_CONFIG_PUSH_EVENT_RECEIVED = "maas.ema.config_push_event.received"; + + public static final String MAAS_EMA_CONFIG_PUSH_EVENT_CYCLE_TIME = "maas.ema.config_push_event.cycle_time"; + + public static final String ENTITY_TYPE_TAG = "entity_type"; + public static final String STATUS_TAG = "status"; + public static final String ORG_ID_TAG = "org_id"; + public static final String SCAN_ID_TAG = "scan_id"; + + public static final String MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE = "ScanCommandReplyMessage"; +} diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java index 34a91d07..fec813c7 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java @@ -37,11 +37,11 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import static com.solace.maas.ep.common.metrics.MetricConstants.ENTITY_TYPE_TAG; -import static com.solace.maas.ep.common.metrics.MetricConstants.MAAS_EMA_EVENT_CYCLE_TIME; -import static com.solace.maas.ep.common.metrics.MetricConstants.MAAS_EMA_EVENT_SENT; -import static com.solace.maas.ep.common.metrics.MetricConstants.ORG_ID_TAG; -import static com.solace.maas.ep.common.metrics.MetricConstants.STATUS_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_CONFIG_PUSH_EVENT_CYCLE_TIME; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_CONFIG_PUSH_EVENT_SENT; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.STATUS_TAG; import static com.solace.maas.ep.event.management.agent.constants.Command.COMMAND_CORRELATION_ID; import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.ACTOR_ID; import static com.solace.maas.ep.event.management.agent.plugin.constants.RouteConstants.TRACE_ID; @@ -235,10 +235,10 @@ private void finalizeAndSendResponse(CommandRequest request) { response.setTraceId(MDC.get(TRACE_ID)); response.setActorId(MDC.get(ACTOR_ID)); commandPublisher.sendCommandResponse(response, topicVars); - meterRegistry.counter(MAAS_EMA_EVENT_SENT, ENTITY_TYPE_TAG, response.getType(), + meterRegistry.counter(MAAS_EMA_CONFIG_PUSH_EVENT_SENT, ENTITY_TYPE_TAG, response.getType(), ORG_ID_TAG, response.getOrgId(), STATUS_TAG, response.getStatus().name()).increment(); Timer jobCycleTime = Timer - .builder(MAAS_EMA_EVENT_CYCLE_TIME) + .builder(MAAS_EMA_CONFIG_PUSH_EVENT_CYCLE_TIME) .tag(ORG_ID_TAG, response.getOrgId()) .tag(STATUS_TAG, request.getStatus().name()) .tag(ENTITY_TYPE_TAG, response.getType()) diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java index 8fb835f0..74af1431 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java @@ -5,6 +5,8 @@ import com.solace.maas.ep.event.management.agent.config.eventPortal.EventPortalProperties; import com.solace.maas.ep.event.management.agent.plugin.jacoco.ExcludeFromJacocoGeneratedReport; import com.solace.maas.ep.event.management.agent.plugin.publisher.SolacePublisher; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.Tag; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.info.BuildProperties; @@ -12,6 +14,12 @@ import org.springframework.stereotype.Component; import java.time.Instant; +import java.util.ArrayList; +import java.util.List; + +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_HEARTBEAT_EVENT_SENT; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; @ExcludeFromJacocoGeneratedReport @Component @@ -23,21 +31,32 @@ public class HeartbeatGenerator { private final String runtimeAgentId; private final String topic; private final String runtimeAgentVersion; + private final MeterRegistry meterRegistry; public HeartbeatGenerator(SolaceConfiguration solaceConfiguration, EventPortalProperties eventPortalProperties, SolacePublisher solacePublisher, - BuildProperties buildProperties) { + BuildProperties buildProperties, + MeterRegistry meterRegistry) { this.solacePublisher = solacePublisher; this.runtimeAgentId = eventPortalProperties.getRuntimeAgentId(); topic = solaceConfiguration.getTopicPrefix() + "heartbeat/v1"; this.runtimeAgentVersion = getFormattedVersion(buildProperties.getVersion()); + this.meterRegistry = meterRegistry; } @Scheduled(fixedRate = 5000) public void sendHeartbeat() { HeartbeatMessage message = new HeartbeatMessage(runtimeAgentId, Instant.now().toString(), runtimeAgentVersion); - solacePublisher.publish(message, topic); + boolean result = solacePublisher.publish(message, topic); + logHealthMetric(message, result); + } + + private void logHealthMetric(HeartbeatMessage message, boolean isHealthy) { + List tags = new ArrayList<>(); + tags.add(Tag.of(ENTITY_TYPE_TAG, message.getType())); + tags.add(Tag.of(ORG_ID_TAG, message.getOrgId())); + meterRegistry.gauge(MAAS_EMA_HEARTBEAT_EVENT_SENT, tags, isHealthy ? 1 : 0); } private String getFormattedVersion(String version) { diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanDataPublisher.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanDataPublisher.java index e334d584..cc22dcc4 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanDataPublisher.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanDataPublisher.java @@ -1,20 +1,32 @@ package com.solace.maas.ep.event.management.agent.publisher; +import com.solace.maas.ep.event.management.agent.plugin.constants.ScanStatus; import com.solace.maas.ep.event.management.agent.plugin.mop.MOPMessage; import com.solace.maas.ep.event.management.agent.plugin.publisher.SolacePublisher; +import io.micrometer.core.instrument.MeterRegistry; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; import java.util.Map; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_SENT; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.SCAN_ID_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.STATUS_TAG; + @Component @ConditionalOnProperty(name = "event-portal.gateway.messaging.standalone", havingValue = "false") public class ScanDataPublisher { private final SolacePublisher solacePublisher; + private final MeterRegistry meterRegistry; - public ScanDataPublisher(SolacePublisher solacePublisher) { + public ScanDataPublisher(SolacePublisher solacePublisher, + MeterRegistry meterRegistry) { this.solacePublisher = solacePublisher; + this.meterRegistry = meterRegistry; } /** @@ -43,6 +55,11 @@ public void sendScanData(MOPMessage message, Map topicDetails) { topicDetails.get("scanId"), topicDetails.get("scanType")); - solacePublisher.publish(message, topicString); + boolean isSuccessful = solacePublisher.publish(message, topicString); + + meterRegistry.counter(MAAS_EMA_SCAN_EVENT_SENT, ENTITY_TYPE_TAG, MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE, + STATUS_TAG, isSuccessful ? ScanStatus.COMPLETE.name() : ScanStatus.FAILED.name(), + SCAN_ID_TAG, topicDetails.get("scanId"), + ORG_ID_TAG, topicDetails.get("orgId")).increment(); } } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanStatusPublisher.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanStatusPublisher.java index b7122836..5b8568ad 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanStatusPublisher.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanStatusPublisher.java @@ -6,6 +6,7 @@ import com.solace.maas.ep.event.management.agent.plugin.publisher.SolacePublisher; import com.solace.maas.ep.event.management.agent.plugin.route.exceptions.ScanOverallStatusException; import com.solace.maas.ep.event.management.agent.plugin.route.exceptions.ScanStatusException; +import io.micrometer.core.instrument.MeterRegistry; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; @@ -14,15 +15,25 @@ import java.util.List; import java.util.Map; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_SENT; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.SCAN_ID_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.STATUS_TAG; + @Slf4j @Component @ConditionalOnProperty(name = "event-portal.gateway.messaging.standalone", havingValue = "false") public class ScanStatusPublisher { private final SolacePublisher solacePublisher; + private final MeterRegistry meterRegistry; - public ScanStatusPublisher(SolacePublisher solacePublisher) { + public ScanStatusPublisher(SolacePublisher solacePublisher, + MeterRegistry meterRegistry) { this.solacePublisher = solacePublisher; + this.meterRegistry = meterRegistry; } /** @@ -46,6 +57,9 @@ public void sendOverallScanStatus(ScanStatusMessage message, Map } catch (Exception e) { throw new ScanOverallStatusException("Over all status exception: " + e.getMessage(), Map.of(scanId, List.of(e)), "Overall status", Arrays.asList(scanType.split(",")), ScanStatus.valueOf(status)); + } finally { + meterRegistry.counter(MAAS_EMA_SCAN_EVENT_SENT, ENTITY_TYPE_TAG, MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE, + STATUS_TAG, status, SCAN_ID_TAG, scanId, ORG_ID_TAG, topicDetails.get("orgId")).increment(); } } @@ -72,6 +86,9 @@ public void sendScanDataStatus(ScanDataStatusMessage message, Map !list.isEmpty()) - .collect(Collectors.toList()).stream() + .toList().stream() ) - .collect(Collectors.toList()).stream().flatMap(List::stream).collect(Collectors.toList()); + .toList().stream().flatMap(List::stream).toList(); return scanService.singleScan(routes, groupId, scanId, traceId, actorId, messagingServiceEntity, runtimeAgentId); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java index 53a8f5fe..522b8b75 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/service/ScanService.java @@ -21,6 +21,7 @@ import com.solace.maas.ep.event.management.agent.scanManager.model.ScanItemBO; import com.solace.maas.ep.event.management.agent.scanManager.model.ScanTypeBO; import com.solace.maas.ep.event.management.agent.util.IDGenerator; +import io.micrometer.core.instrument.MeterRegistry; import lombok.extern.slf4j.Slf4j; import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; import org.apache.camel.Exchange; @@ -40,6 +41,12 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_SENT; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.SCAN_ID_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.STATUS_TAG; + /** * Responsible for initiating and managing Messaging Service scans. */ @@ -62,11 +69,17 @@ public class ScanService { private final IDGenerator idGenerator; + private final MeterRegistry meterRegistry; + public ScanService(ScanRepository repository, ScanRecipientHierarchyRepository scanRecipientHierarchyRepository, - ScanTypeRepository scanTypeRepository, ScanStatusRepository scanStatusRepository, ScanRouteService scanRouteService, - RouteService routeService, ProducerTemplate producerTemplate, - IDGenerator idGenerator) { + ScanTypeRepository scanTypeRepository, + ScanStatusRepository scanStatusRepository, + ScanRouteService scanRouteService, + RouteService routeService, + ProducerTemplate producerTemplate, + IDGenerator idGenerator, + MeterRegistry meterRegistry) { this.repository = repository; this.scanRecipientHierarchyRepository = scanRecipientHierarchyRepository; this.scanTypeRepository = scanTypeRepository; @@ -75,6 +88,7 @@ public ScanService(ScanRepository repository, this.routeService = routeService; this.producerTemplate = producerTemplate; this.idGenerator = idGenerator; + this.meterRegistry = meterRegistry; } /** @@ -284,6 +298,8 @@ public void sendScanStatus(String groupId, String scanId, String traceId, String exchange.getIn().setHeader(RouteConstants.SCAN_STATUS, status); exchange.getIn().setHeader(RouteConstants.SCAN_STATUS_DESC, ""); }); + meterRegistry.counter(MAAS_EMA_SCAN_EVENT_SENT, ENTITY_TYPE_TAG, MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE, + STATUS_TAG, status.name(), SCAN_ID_TAG, scanId).increment(); } protected CompletableFuture scanAsync(String groupId, String scanId, String traceId, String actorId, diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java index 47fe10c0..62c1385f 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java @@ -8,10 +8,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; -import static com.solace.maas.ep.common.metrics.MetricConstants.ENTITY_TYPE_TAG; -import static com.solace.maas.ep.common.metrics.MetricConstants.MAAS_EMA_EVENT_RECEIVED; -import static com.solace.maas.ep.common.metrics.MetricConstants.ORG_ID_TAG; -import static com.solace.maas.ep.common.metrics.MetricConstants.STATUS_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_CONFIG_PUSH_EVENT_RECEIVED; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.STATUS_TAG; @Slf4j @Component @@ -34,7 +34,7 @@ public CommandMessageHandler( @Override public void receiveMessage(String destinationName, CommandMessage message) { log.debug("receiveMessage {}\n{}", destinationName, message); - meterRegistry.counter(MAAS_EMA_EVENT_RECEIVED, ENTITY_TYPE_TAG, message.getType(), + meterRegistry.counter(MAAS_EMA_CONFIG_PUSH_EVENT_RECEIVED, ENTITY_TYPE_TAG, message.getType(), ORG_ID_TAG, message.getOrgId(), STATUS_TAG, message.getStatus().name()).increment(); commandMessageProcessor.processMessage(message); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/HeartbeatMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/HeartbeatMessageHandler.java index 3e714f67..183ec050 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/HeartbeatMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/HeartbeatMessageHandler.java @@ -2,6 +2,7 @@ import com.solace.maas.ep.common.messages.HeartbeatMessage; import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration; +import io.micrometer.core.instrument.MeterRegistry; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -20,10 +21,14 @@ @ConditionalOnProperty(name = "event-portal.gateway.messaging.standalone", havingValue = "false") public class HeartbeatMessageHandler extends SolaceDirectMessageHandler { + private final MeterRegistry meterRegistry; + public HeartbeatMessageHandler( SolaceConfiguration solaceConfiguration, - SolaceSubscriber solaceSubscriber) { + SolaceSubscriber solaceSubscriber, + MeterRegistry meterRegistry) { super(solaceConfiguration.getTopicPrefix() + "heartbeat/>", solaceSubscriber); + this.meterRegistry = meterRegistry; } @Override diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java index ae439f85..29408fc6 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java @@ -3,23 +3,31 @@ import com.solace.maas.ep.common.messages.ScanCommandMessage; import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration; import com.solace.maas.ep.event.management.agent.subscriber.messageProcessors.ScanCommandMessageProcessor; +import io.micrometer.core.instrument.MeterRegistry; import lombok.extern.slf4j.Slf4j; import org.slf4j.MDC; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_RECEIVED; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; + @Slf4j @Component @ConditionalOnExpression("${event-portal.gateway.messaging.standalone:true}== false && ${event-portal.managed:false} == false") public class ScanCommandMessageHandler extends SolaceDirectMessageHandler { private final ScanCommandMessageProcessor scanCommandMessageProcessor; + private final MeterRegistry meterRegistry; public ScanCommandMessageHandler(SolaceConfiguration solaceConfiguration, SolaceSubscriber solaceSubscriber, - ScanCommandMessageProcessor scanCommandMessageProcessor) { + ScanCommandMessageProcessor scanCommandMessageProcessor, + MeterRegistry meterRegistry) { super(solaceConfiguration.getTopicPrefix() + "scan/command/v1/scanStart/>", solaceSubscriber); this.scanCommandMessageProcessor = scanCommandMessageProcessor; + this.meterRegistry = meterRegistry; } @Override @@ -27,6 +35,8 @@ public void receiveMessage(String destinationName, ScanCommandMessage message) { MDC.clear(); log.debug("Received scan command message: {} for event broker: {}, traceId: {}", message, message.getMessagingServiceId(), message.getTraceId()); + meterRegistry.counter(MAAS_EMA_SCAN_EVENT_RECEIVED, ENTITY_TYPE_TAG, message.getType(), + ORG_ID_TAG, message.getOrgId()).increment(); scanCommandMessageProcessor.processMessage(message); } } diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java index de9d124a..3c152aef 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java @@ -6,6 +6,7 @@ import com.solace.maas.ep.event.management.agent.processor.ScanDataProcessor; import com.solace.maas.ep.event.management.agent.publisher.ScanDataPublisher; import com.solace.maas.ep.event.management.agent.route.ep.ScanDataPublisherRouteBuilder; +import io.micrometer.core.instrument.MeterRegistry; import lombok.SneakyThrows; import org.apache.camel.CamelContext; import org.apache.camel.EndpointInject; @@ -65,8 +66,9 @@ static class TestConfig { public static RoutesBuilder createRouteBuilder() { SolacePublisher solacePublisher = mock(SolacePublisher.class); EventPortalProperties eventPortalProperties = mock(EventPortalProperties.class); + MeterRegistry meterRegistry = mock(MeterRegistry.class); - ScanDataPublisher scanDataPublisher = new ScanDataPublisher(solacePublisher); + ScanDataPublisher scanDataPublisher = new ScanDataPublisher(solacePublisher, meterRegistry); ScanDataProcessor scanDataProcessor = new ScanDataProcessor(scanDataPublisher, eventPortalProperties); ScanTypeDescendentsProcessor scanTypeDescendentsProcessor = mock(ScanTypeDescendentsProcessor.class); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java index 9e95aea0..05a2c657 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java @@ -12,6 +12,7 @@ import com.solace.maas.ep.event.management.agent.service.ManualImportFilesService; import com.solace.maas.ep.event.management.agent.subscriber.messageProcessors.ScanCommandMessageProcessor; import com.solace.messaging.receiver.InboundMessage; +import io.micrometer.core.instrument.MeterRegistry; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.camel.ProducerTemplate; @@ -66,6 +67,9 @@ public class MessageReceiverTests { @Mock ManualImportDetailsService manualImportDetailsService; + @Mock + MeterRegistry meterRegistry; + @Test @SneakyThrows public void scanReceiver() { @@ -89,7 +93,7 @@ public void scanReceiver() { when(inboundMessage.getDestinationName()).thenReturn("anyTopic"); ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( - solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor); + solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor, meterRegistry); String topic = scanCommandMessageHandler.getTopicString(); log.info("topic: {}", topic); @@ -106,7 +110,7 @@ public void testBadClass() { assertThrows(RuntimeException.class, () -> { when(inboundMessage.getProperty(MOPConstants.MOP_MSG_META_DECODER)).thenReturn("badClass"); ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( - solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor); + solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor, meterRegistry); scanCommandMessageHandler.onMessage(inboundMessage); }); } @@ -115,7 +119,7 @@ public void testBadClass() { @SneakyThrows public void testScanCommandMessage() { ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( - solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor); + solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor, meterRegistry); ScanCommandMessage scanCommandMessage = new ScanCommandMessage("messagingServiceId", @@ -233,7 +237,7 @@ public void heartbeatReceiverTest() { when(inboundMessage.getDestinationName()).thenReturn("anyTopic"); HeartbeatMessageHandler heartbeatMessageHandler = new HeartbeatMessageHandler(solaceConfiguration, - solaceSubscriber); + solaceSubscriber, meterRegistry); heartbeatMessageHandler.onMessage(inboundMessage); } diff --git a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java index 28a121c4..222b5ddb 100644 --- a/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java +++ b/service/plugin/src/main/java/com/solace/maas/ep/event/management/agent/plugin/publisher/SolacePublisher.java @@ -38,7 +38,7 @@ public SolacePublisher(OutboundMessageBuilder outboundMessageBuilder, this.directMessagePublisher = directMessagePublisher; } - public void publish(MOPMessage message, String topicString) { + public boolean publish(MOPMessage message, String topicString) { Topic topic = Topic.of(topicString); try { @@ -51,6 +51,7 @@ public void publish(MOPMessage message, String topicString) { log.trace("publishing to {}:\n{}", topicString, messageString); directMessagePublisher.publish(outboundMessage, topic, properties); } + return true; } catch (PubSubPlusClientException e) { log.error("PubSubPlus Client Exception while attempting to publish message: {}", message.toString(), e); } catch (IllegalStateException e) { @@ -60,6 +61,7 @@ public void publish(MOPMessage message, String topicString) { } catch (JsonProcessingException e) { log.error("JsonProcessingException while attempting to publish message: {}", message.toString(), e); } + return false; } private Properties getProperties(MOPMessage message) { From 764d1b4a793006a54c9c649e943f99d706af4f34 Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Wed, 21 Aug 2024 14:34:04 -0400 Subject: [PATCH 03/11] fix pmd constants violation --- .../solace/maas/ep/common/metrics/ObservabilityConstants.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java b/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java index 08ac73b2..ce6e9bd9 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java @@ -1,8 +1,6 @@ package com.solace.maas.ep.common.metrics; public class ObservabilityConstants { - private ObservabilityConstants() {} - public static final String MAAS_EMA_SCAN_EVENT_SENT = "maas.ema.scan_event.sent"; public static final String MAAS_EMA_CONFIG_PUSH_EVENT_SENT = "maas.ema.config_push_event.sent"; public static final String MAAS_EMA_HEARTBEAT_EVENT_SENT = "maas.ema.heartbeat_event.sent"; @@ -18,4 +16,6 @@ private ObservabilityConstants() {} public static final String SCAN_ID_TAG = "scan_id"; public static final String MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE = "ScanCommandReplyMessage"; + + private ObservabilityConstants() {} } From 2f9c384c4413bc568e89ea802c53f6d4b35139c3 Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Wed, 21 Aug 2024 14:35:35 -0400 Subject: [PATCH 04/11] remove meter registry from wrong heartbeat handler used for testing --- .../agent/subscriber/HeartbeatMessageHandler.java | 7 +------ .../management/agent/subscriber/MessageReceiverTests.java | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/HeartbeatMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/HeartbeatMessageHandler.java index 183ec050..3e714f67 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/HeartbeatMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/HeartbeatMessageHandler.java @@ -2,7 +2,6 @@ import com.solace.maas.ep.common.messages.HeartbeatMessage; import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration; -import io.micrometer.core.instrument.MeterRegistry; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -21,14 +20,10 @@ @ConditionalOnProperty(name = "event-portal.gateway.messaging.standalone", havingValue = "false") public class HeartbeatMessageHandler extends SolaceDirectMessageHandler { - private final MeterRegistry meterRegistry; - public HeartbeatMessageHandler( SolaceConfiguration solaceConfiguration, - SolaceSubscriber solaceSubscriber, - MeterRegistry meterRegistry) { + SolaceSubscriber solaceSubscriber) { super(solaceConfiguration.getTopicPrefix() + "heartbeat/>", solaceSubscriber); - this.meterRegistry = meterRegistry; } @Override diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java index 05a2c657..b3a9c65a 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java @@ -236,8 +236,7 @@ public void heartbeatReceiverTest() { "com.solace.maas.ep.common.messages.HeartbeatMessage"); when(inboundMessage.getDestinationName()).thenReturn("anyTopic"); - HeartbeatMessageHandler heartbeatMessageHandler = new HeartbeatMessageHandler(solaceConfiguration, - solaceSubscriber, meterRegistry); + HeartbeatMessageHandler heartbeatMessageHandler = new HeartbeatMessageHandler(solaceConfiguration, solaceSubscriber); heartbeatMessageHandler.onMessage(inboundMessage); } From fe3d4a18debbf0ec56836a858f7c40b580fbc0cd Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Wed, 21 Aug 2024 14:46:05 -0400 Subject: [PATCH 05/11] fix test not mocking the meterRegistry --- .../event/management/agent/service/ScanServiceTests.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java index df792469..6f6cae90 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java @@ -18,6 +18,7 @@ import com.solace.maas.ep.event.management.agent.repository.scan.ScanTypeRepository; import com.solace.maas.ep.event.management.agent.service.logging.LoggingService; import com.solace.maas.ep.event.management.agent.util.IDGenerator; +import io.micrometer.core.instrument.MeterRegistry; import lombok.SneakyThrows; import org.apache.camel.Processor; import org.apache.camel.Produce; @@ -95,6 +96,9 @@ public class ScanServiceTests { @Autowired private ScanServiceHelper scanServiceHelper; + @Mock + private MeterRegistry meterRegistry; + @Test @SneakyThrows public void testSingleScanWithRouteBundle() { @@ -312,7 +316,8 @@ public void testParseRouteRecipients() { public void testSendScanStatus() { ScanService service = new ScanService(mock(ScanRepository.class), mock(ScanRecipientHierarchyRepository.class), mock(ScanTypeRepository.class), - mock(ScanStatusRepository.class), mock(ScanRouteService.class), mock(RouteService.class), template, idGenerator); + mock(ScanStatusRepository.class), mock(ScanRouteService.class), mock(RouteService.class), + template, idGenerator, meterRegistry); service.sendScanStatus("scanId", "groupId", "messagingServiceId", "traceId", "actorId", "queueListing", ScanStatus.IN_PROGRESS); From 3353265fb763b33703972a5dafbde7b6f5ca3b25 Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Wed, 21 Aug 2024 15:34:59 -0400 Subject: [PATCH 06/11] fix mocking meterRegistry for tests --- .../agent/subscriber/ScanCommandMessageHandler.java | 3 ++- .../agent/commandManager/CommandManagerTests.java | 2 +- .../route/handler/ScanDataPublisherRouteBuilderTests.java | 6 ++++++ .../event/management/agent/service/ScanServiceTests.java | 2 +- .../management/agent/subscriber/MessageReceiverTests.java | 7 +++++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java index 29408fc6..9b1538e9 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java @@ -12,6 +12,7 @@ import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_RECEIVED; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.SCAN_ID_TAG; @Slf4j @Component @@ -36,7 +37,7 @@ public void receiveMessage(String destinationName, ScanCommandMessage message) { log.debug("Received scan command message: {} for event broker: {}, traceId: {}", message, message.getMessagingServiceId(), message.getTraceId()); meterRegistry.counter(MAAS_EMA_SCAN_EVENT_RECEIVED, ENTITY_TYPE_TAG, message.getType(), - ORG_ID_TAG, message.getOrgId()).increment(); + ORG_ID_TAG, message.getOrgId(), SCAN_ID_TAG, message.getScanId()).increment(); scanCommandMessageProcessor.processMessage(message); } } diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/commandManager/CommandManagerTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/commandManager/CommandManagerTests.java index a27ec7d0..2639f467 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/commandManager/CommandManagerTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/commandManager/CommandManagerTests.java @@ -218,7 +218,7 @@ void failConfigPushCommand() { CommandMessage message = getCommandMessage("1"); doNothing().when(commandPublisher).sendCommandResponse(any(), any()); - doThrow(new RuntimeException("Error running command.")).when(commandManager).configPush(commandMapper.map(message)); + doThrow(new RuntimeException("Error running command.")).when(commandManager).configPush(any()); commandManager.execute(message); await().atMost(10, TimeUnit.SECONDS).until(() -> CommandManagerTestHelper.verifyCommandPublisherIsInvoked(commandPublisher, 1)); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java index 3c152aef..43cef4bd 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java @@ -6,7 +6,9 @@ import com.solace.maas.ep.event.management.agent.processor.ScanDataProcessor; import com.solace.maas.ep.event.management.agent.publisher.ScanDataPublisher; import com.solace.maas.ep.event.management.agent.route.ep.ScanDataPublisherRouteBuilder; +import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.noop.NoopCounter; import lombok.SneakyThrows; import org.apache.camel.CamelContext; import org.apache.camel.EndpointInject; @@ -24,7 +26,9 @@ import org.springframework.context.annotation.Primary; import org.springframework.test.context.ActiveProfiles; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; @CamelSpringBootTest @@ -67,6 +71,8 @@ public static RoutesBuilder createRouteBuilder() { SolacePublisher solacePublisher = mock(SolacePublisher.class); EventPortalProperties eventPortalProperties = mock(EventPortalProperties.class); MeterRegistry meterRegistry = mock(MeterRegistry.class); + when(meterRegistry.counter(any(), any(), any(), any(), any(), any(), any(), any(), any())) + .thenReturn(new NoopCounter(new Meter.Id("noop", null, null, null, null))); ScanDataPublisher scanDataPublisher = new ScanDataPublisher(solacePublisher, meterRegistry); ScanDataProcessor scanDataProcessor = new ScanDataProcessor(scanDataPublisher, eventPortalProperties); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java index 6f6cae90..20b73416 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java @@ -96,7 +96,7 @@ public class ScanServiceTests { @Autowired private ScanServiceHelper scanServiceHelper; - @Mock + @Autowired private MeterRegistry meterRegistry; @Test diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java index b3a9c65a..65b2df2c 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java @@ -12,7 +12,9 @@ import com.solace.maas.ep.event.management.agent.service.ManualImportFilesService; import com.solace.maas.ep.event.management.agent.subscriber.messageProcessors.ScanCommandMessageProcessor; import com.solace.messaging.receiver.InboundMessage; +import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.noop.NoopCounter; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.camel.ProducerTemplate; @@ -34,6 +36,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThatNoException; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; @@ -91,6 +94,8 @@ public void scanReceiver() { when(inboundMessage.getProperty(MOPConstants.MOP_MSG_META_DECODER)).thenReturn( "com.solace.maas.ep.common.messages.ScanCommandMessage"); when(inboundMessage.getDestinationName()).thenReturn("anyTopic"); + when(meterRegistry.counter(any(), any(), any(), any(), any(), any(), any())).thenReturn(new NoopCounter( + new Meter.Id("mockMeterId", null, null, null, null))); ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor, meterRegistry); @@ -118,6 +123,8 @@ public void testBadClass() { @Test @SneakyThrows public void testScanCommandMessage() { + when(meterRegistry.counter(any(), any(), any(), any(), any(), any(), any())).thenReturn(new NoopCounter( + new Meter.Id("mockMeterId", null, null, null, null))); ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor, meterRegistry); From 563c6acbad017c77c914689d867100b9b2488882 Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Wed, 21 Aug 2024 15:53:23 -0400 Subject: [PATCH 07/11] fix more tests --- .../handler/ScanDataPublisherRouteBuilderTests.java | 2 +- .../event/management/agent/service/ScanServiceTests.java | 9 +++++++-- .../agent/subscriber/MessageReceiverTests.java | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java index 43cef4bd..b8e16309 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/plugin/route/handler/ScanDataPublisherRouteBuilderTests.java @@ -71,7 +71,7 @@ public static RoutesBuilder createRouteBuilder() { SolacePublisher solacePublisher = mock(SolacePublisher.class); EventPortalProperties eventPortalProperties = mock(EventPortalProperties.class); MeterRegistry meterRegistry = mock(MeterRegistry.class); - when(meterRegistry.counter(any(), any(), any(), any(), any(), any(), any(), any(), any())) + when(meterRegistry.counter(any(), any(String[].class))) .thenReturn(new NoopCounter(new Meter.Id("noop", null, null, null, null))); ScanDataPublisher scanDataPublisher = new ScanDataPublisher(solacePublisher, meterRegistry); diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java index 20b73416..e7a810b1 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/service/ScanServiceTests.java @@ -18,7 +18,9 @@ import com.solace.maas.ep.event.management.agent.repository.scan.ScanTypeRepository; import com.solace.maas.ep.event.management.agent.service.logging.LoggingService; import com.solace.maas.ep.event.management.agent.util.IDGenerator; +import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.noop.NoopCounter; import lombok.SneakyThrows; import org.apache.camel.Processor; import org.apache.camel.Produce; @@ -96,7 +98,7 @@ public class ScanServiceTests { @Autowired private ScanServiceHelper scanServiceHelper; - @Autowired + @Mock private MeterRegistry meterRegistry; @Test @@ -147,9 +149,10 @@ public void testSingleScanWithRouteBundle() { .thenReturn(scanType); when(scanStatusRepository.save(scanStatus)) .thenReturn(scanStatus); - when(scanRecipientHierarchyRepository.save(any(ScanRecipientHierarchyEntity.class))) .thenReturn(mock(ScanRecipientHierarchyEntity.class)); + when(meterRegistry.counter(any(), any(String[].class))) + .thenReturn(new NoopCounter(new Meter.Id("noop", null, null, null, null))); scanService.singleScan(List.of(topicListing, consumerGroups, additionalConsumerGroupConfigBundle), "groupId", @@ -314,6 +317,8 @@ public void testParseRouteRecipients() { @Test @SneakyThrows public void testSendScanStatus() { + when(meterRegistry.counter(any(), any(String[].class))) + .thenReturn(new NoopCounter(new Meter.Id("noop", null, null, null, null))); ScanService service = new ScanService(mock(ScanRepository.class), mock(ScanRecipientHierarchyRepository.class), mock(ScanTypeRepository.class), mock(ScanStatusRepository.class), mock(ScanRouteService.class), mock(RouteService.class), diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java index 65b2df2c..5000731e 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java @@ -94,7 +94,7 @@ public void scanReceiver() { when(inboundMessage.getProperty(MOPConstants.MOP_MSG_META_DECODER)).thenReturn( "com.solace.maas.ep.common.messages.ScanCommandMessage"); when(inboundMessage.getDestinationName()).thenReturn("anyTopic"); - when(meterRegistry.counter(any(), any(), any(), any(), any(), any(), any())).thenReturn(new NoopCounter( + when(meterRegistry.counter(any(), any(String[].class))).thenReturn(new NoopCounter( new Meter.Id("mockMeterId", null, null, null, null))); ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( @@ -123,7 +123,7 @@ public void testBadClass() { @Test @SneakyThrows public void testScanCommandMessage() { - when(meterRegistry.counter(any(), any(), any(), any(), any(), any(), any())).thenReturn(new NoopCounter( + when(meterRegistry.counter(any(), any(String[].class))).thenReturn(new NoopCounter( new Meter.Id("mockMeterId", null, null, null, null))); ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor, meterRegistry); From df3e1291912552fa3412ecc51d8c628dcfcb4766 Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Thu, 22 Aug 2024 17:07:16 -0400 Subject: [PATCH 08/11] move metrics to processors instead of message receivers so that we have a better place to set and check fields for null values --- .../agent/publisher/HeartbeatGenerator.java | 2 -- .../subscriber/CommandMessageHandler.java | 13 +------- .../subscriber/ScanCommandMessageHandler.java | 7 ----- .../CommandMessageProcessor.java | 30 ++++++++++++++++++- .../ScanCommandMessageProcessor.java | 15 ++++++++-- 5 files changed, 43 insertions(+), 24 deletions(-) diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java index 74af1431..db9af672 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java @@ -19,7 +19,6 @@ import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_HEARTBEAT_EVENT_SENT; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; @ExcludeFromJacocoGeneratedReport @Component @@ -55,7 +54,6 @@ public void sendHeartbeat() { private void logHealthMetric(HeartbeatMessage message, boolean isHealthy) { List tags = new ArrayList<>(); tags.add(Tag.of(ENTITY_TYPE_TAG, message.getType())); - tags.add(Tag.of(ORG_ID_TAG, message.getOrgId())); meterRegistry.gauge(MAAS_EMA_HEARTBEAT_EVENT_SENT, tags, isHealthy ? 1 : 0); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java index 62c1385f..5e2a1089 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/CommandMessageHandler.java @@ -3,39 +3,28 @@ import com.solace.maas.ep.common.messages.CommandMessage; import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration; import com.solace.maas.ep.event.management.agent.subscriber.messageProcessors.CommandMessageProcessor; -import io.micrometer.core.instrument.MeterRegistry; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_CONFIG_PUSH_EVENT_RECEIVED; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.STATUS_TAG; - @Slf4j @Component @ConditionalOnExpression("${event-portal.gateway.messaging.standalone:true}== false && ${event-portal.managed:false} == false") public class CommandMessageHandler extends SolaceDirectMessageHandler { - private final MeterRegistry meterRegistry; private final CommandMessageProcessor commandMessageProcessor; public CommandMessageHandler( SolaceConfiguration solaceConfiguration, SolaceSubscriber solaceSubscriber, - CommandMessageProcessor commandMessageProcessor, - MeterRegistry meterRegistry) { + CommandMessageProcessor commandMessageProcessor) { super(solaceConfiguration.getTopicPrefix() + "command/v1/>", solaceSubscriber); - this.meterRegistry = meterRegistry; this.commandMessageProcessor = commandMessageProcessor; } @Override public void receiveMessage(String destinationName, CommandMessage message) { log.debug("receiveMessage {}\n{}", destinationName, message); - meterRegistry.counter(MAAS_EMA_CONFIG_PUSH_EVENT_RECEIVED, ENTITY_TYPE_TAG, message.getType(), - ORG_ID_TAG, message.getOrgId(), STATUS_TAG, message.getStatus().name()).increment(); commandMessageProcessor.processMessage(message); } } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java index 9b1538e9..928b2d1d 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java @@ -9,11 +9,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_RECEIVED; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.SCAN_ID_TAG; - @Slf4j @Component @ConditionalOnExpression("${event-portal.gateway.messaging.standalone:true}== false && ${event-portal.managed:false} == false") @@ -36,8 +31,6 @@ public void receiveMessage(String destinationName, ScanCommandMessage message) { MDC.clear(); log.debug("Received scan command message: {} for event broker: {}, traceId: {}", message, message.getMessagingServiceId(), message.getTraceId()); - meterRegistry.counter(MAAS_EMA_SCAN_EVENT_RECEIVED, ENTITY_TYPE_TAG, message.getType(), - ORG_ID_TAG, message.getOrgId(), SCAN_ID_TAG, message.getScanId()).increment(); scanCommandMessageProcessor.processMessage(message); } } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java index 8a9e30fe..48bf5a35 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java @@ -2,11 +2,23 @@ import com.solace.maas.ep.common.messages.CommandMessage; import com.solace.maas.ep.event.management.agent.command.CommandManager; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.Tag; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_CONFIG_PUSH_EVENT_RECEIVED; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.STATUS_TAG; + @Slf4j @Component @ConditionalOnProperty(name = "event-portal.gateway.messaging.standalone", havingValue = "false") @@ -15,21 +27,37 @@ public class CommandMessageProcessor implements MessageProcessor private final CommandManager commandManager; private final DynamicResourceConfigurationHelper dynamicResourceConfigurationHelper; + private final MeterRegistry meterRegistry; public CommandMessageProcessor(CommandManager commandManager, - DynamicResourceConfigurationHelper dynamicResourceConfigurationHelper) { + DynamicResourceConfigurationHelper dynamicResourceConfigurationHelper, + MeterRegistry meterRegistry) { this.commandManager = commandManager; this.dynamicResourceConfigurationHelper = dynamicResourceConfigurationHelper; + this.meterRegistry = meterRegistry; } @Override public void processMessage(CommandMessage message) { + logConfigPushMetric(message); if (CollectionUtils.isNotEmpty(message.getResources())) { dynamicResourceConfigurationHelper.loadSolaceBrokerResourceConfigurations(message.getResources()); } commandManager.execute(message); } + private void logConfigPushMetric(CommandMessage message) { + List tags = new ArrayList<>(); + if (Objects.nonNull(message.getStatus())) { + tags.add(Tag.of(STATUS_TAG, message.getStatus().name())); + } + if (StringUtils.isNotBlank(message.getOrgId())) { + tags.add(Tag.of(ORG_ID_TAG, message.getOrgId())); + } + tags.add(Tag.of(ENTITY_TYPE_TAG, message.getType())); + meterRegistry.counter(MAAS_EMA_CONFIG_PUSH_EVENT_RECEIVED, tags).increment(); + } + @Override public Class supportedClass() { return CommandMessage.class; diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/ScanCommandMessageProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/ScanCommandMessageProcessor.java index 1a61d652..7f066834 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/ScanCommandMessageProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/ScanCommandMessageProcessor.java @@ -3,6 +3,7 @@ import com.solace.maas.ep.common.messages.ScanCommandMessage; import com.solace.maas.ep.event.management.agent.scanManager.ScanManager; import com.solace.maas.ep.event.management.agent.scanManager.model.ScanRequestBO; +import io.micrometer.core.instrument.MeterRegistry; import lombok.extern.slf4j.Slf4j; import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; import org.apache.commons.collections4.CollectionUtils; @@ -14,6 +15,10 @@ import java.util.List; import java.util.UUID; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_RECEIVED; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.SCAN_ID_TAG; + @Slf4j @Component @ConditionalOnProperty(name = "event-portal.gateway.messaging.standalone", havingValue = "false") @@ -22,16 +27,22 @@ public class ScanCommandMessageProcessor implements MessageProcessor destinations = new ArrayList<>(); List entityTypes = new ArrayList<>(); @@ -59,7 +70,7 @@ public void processMessage(ScanCommandMessage message) { ScanRequestBO scanRequestBO = ScanRequestBO.builder() .messagingServiceId(message.getMessagingServiceId()) - .scanId(!StringUtils.isEmpty(message.getScanId()) ? message.getScanId() : UUID.randomUUID().toString()) + .scanId(scanId) .traceId(message.getTraceId()) .actorId(message.getActorId()) .scanTypes(entityTypes) From 4e0f6e78b5277a6cf8a92a15805732b8ff8665b8 Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Thu, 22 Aug 2024 17:19:53 -0400 Subject: [PATCH 09/11] add an info log to the config push flow --- .../subscriber/messageProcessors/CommandMessageProcessor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java index 48bf5a35..27a5761c 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java @@ -39,6 +39,7 @@ public CommandMessageProcessor(CommandManager commandManager, @Override public void processMessage(CommandMessage message) { + log.info("Config push command processor started. context={} actorId={} ", message.getContext(), message.getActorId()); logConfigPushMetric(message); if (CollectionUtils.isNotEmpty(message.getResources())) { dynamicResourceConfigurationHelper.loadSolaceBrokerResourceConfigurations(message.getResources()); From ae729bd8244ac323bcaf3548427e58422529c094 Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Thu, 22 Aug 2024 18:02:36 -0400 Subject: [PATCH 10/11] fix pmd violation --- .../agent/subscriber/ScanCommandMessageHandler.java | 6 +----- .../management/agent/subscriber/MessageReceiverTests.java | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java index 928b2d1d..ae439f85 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/ScanCommandMessageHandler.java @@ -3,7 +3,6 @@ import com.solace.maas.ep.common.messages.ScanCommandMessage; import com.solace.maas.ep.event.management.agent.config.SolaceConfiguration; import com.solace.maas.ep.event.management.agent.subscriber.messageProcessors.ScanCommandMessageProcessor; -import io.micrometer.core.instrument.MeterRegistry; import lombok.extern.slf4j.Slf4j; import org.slf4j.MDC; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; @@ -15,15 +14,12 @@ public class ScanCommandMessageHandler extends SolaceDirectMessageHandler { private final ScanCommandMessageProcessor scanCommandMessageProcessor; - private final MeterRegistry meterRegistry; public ScanCommandMessageHandler(SolaceConfiguration solaceConfiguration, SolaceSubscriber solaceSubscriber, - ScanCommandMessageProcessor scanCommandMessageProcessor, - MeterRegistry meterRegistry) { + ScanCommandMessageProcessor scanCommandMessageProcessor) { super(solaceConfiguration.getTopicPrefix() + "scan/command/v1/scanStart/>", solaceSubscriber); this.scanCommandMessageProcessor = scanCommandMessageProcessor; - this.meterRegistry = meterRegistry; } @Override diff --git a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java index 5000731e..9e522d1e 100644 --- a/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java +++ b/service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/MessageReceiverTests.java @@ -98,7 +98,7 @@ public void scanReceiver() { new Meter.Id("mockMeterId", null, null, null, null))); ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( - solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor, meterRegistry); + solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor); String topic = scanCommandMessageHandler.getTopicString(); log.info("topic: {}", topic); @@ -115,7 +115,7 @@ public void testBadClass() { assertThrows(RuntimeException.class, () -> { when(inboundMessage.getProperty(MOPConstants.MOP_MSG_META_DECODER)).thenReturn("badClass"); ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( - solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor, meterRegistry); + solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor); scanCommandMessageHandler.onMessage(inboundMessage); }); } @@ -126,7 +126,7 @@ public void testScanCommandMessage() { when(meterRegistry.counter(any(), any(String[].class))).thenReturn(new NoopCounter( new Meter.Id("mockMeterId", null, null, null, null))); ScanCommandMessageHandler scanCommandMessageHandler = new ScanCommandMessageHandler( - solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor, meterRegistry); + solaceConfiguration, solaceSubscriber, scanCommandMessageProcessor); ScanCommandMessage scanCommandMessage = new ScanCommandMessage("messagingServiceId", From da3cdc390e1b8e086d91fb4e576e0b11061e4685 Mon Sep 17 00:00:00 2001 From: Cameron Rushton Date: Fri, 30 Aug 2024 13:21:56 -0400 Subject: [PATCH 11/11] remove entity type tag --- .../solace/maas/ep/common/messages/CommandMessage.java | 8 -------- .../maas/ep/common/messages/HeartbeatMessage.java | 8 -------- .../maas/ep/common/messages/ScanCommandMessage.java | 8 -------- .../maas/ep/common/messages/ScanDataImportMessage.java | 8 -------- .../maas/ep/common/metrics/ObservabilityConstants.java | 3 --- .../event/management/agent/command/CommandManager.java | 6 ++---- .../management/agent/publisher/HeartbeatGenerator.java | 7 +++++-- .../management/agent/publisher/ScanDataPublisher.java | 4 +--- .../agent/publisher/ScanStatusPublisher.java | 10 ++++------ .../ep/event/management/agent/service/ScanService.java | 5 +---- .../messageProcessors/CommandMessageProcessor.java | 2 -- .../messageProcessors/ScanCommandMessageProcessor.java | 4 +--- 12 files changed, 14 insertions(+), 59 deletions(-) diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/CommandMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/CommandMessage.java index 7f1d9e29..4755c295 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/CommandMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/CommandMessage.java @@ -66,12 +66,4 @@ public CommandMessage(String serviceId, public String toLog() { return null; } - - public String getType() { - return "CommandMessage"; - } - - public void setType() { - // Intentionally left blank - } } diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java index ed76467a..83a591f0 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/HeartbeatMessage.java @@ -33,12 +33,4 @@ public HeartbeatMessage(String runtimeAgentId, String timestamp, String runtime public String toLog() { return null; } - - public String getType() { - return "HeartbeatMessage"; - } - - public void setType() { - // Intentionally left blank - } } diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java index 54fc3e23..538bdc56 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanCommandMessage.java @@ -53,12 +53,4 @@ public ScanCommandMessage(String messagingServiceId, public String toLog() { return null; } - - public String getType() { - return "ScanCommandMessage"; - } - - public void setType() { - // Intentionally left blank - } } diff --git a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java index 71d38dd4..f7f7e2a8 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/messages/ScanDataImportMessage.java @@ -45,12 +45,4 @@ public ScanDataImportMessage(String orgId, String scanId, String traceId, String public String toLog() { return null; } - - public String getType() { - return "ScanDataImportMessage"; - } - - public void setType() { - // Intentionally left blank - } } diff --git a/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java b/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java index ce6e9bd9..8030c107 100644 --- a/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java +++ b/service/application/src/main/java/com/solace/maas/ep/common/metrics/ObservabilityConstants.java @@ -10,12 +10,9 @@ public class ObservabilityConstants { public static final String MAAS_EMA_CONFIG_PUSH_EVENT_CYCLE_TIME = "maas.ema.config_push_event.cycle_time"; - public static final String ENTITY_TYPE_TAG = "entity_type"; public static final String STATUS_TAG = "status"; public static final String ORG_ID_TAG = "org_id"; public static final String SCAN_ID_TAG = "scan_id"; - public static final String MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE = "ScanCommandReplyMessage"; - private ObservabilityConstants() {} } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java index fec813c7..e277a11d 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/command/CommandManager.java @@ -37,7 +37,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_CONFIG_PUSH_EVENT_CYCLE_TIME; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_CONFIG_PUSH_EVENT_SENT; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; @@ -235,13 +234,12 @@ private void finalizeAndSendResponse(CommandRequest request) { response.setTraceId(MDC.get(TRACE_ID)); response.setActorId(MDC.get(ACTOR_ID)); commandPublisher.sendCommandResponse(response, topicVars); - meterRegistry.counter(MAAS_EMA_CONFIG_PUSH_EVENT_SENT, ENTITY_TYPE_TAG, response.getType(), - ORG_ID_TAG, response.getOrgId(), STATUS_TAG, response.getStatus().name()).increment(); + meterRegistry.counter(MAAS_EMA_CONFIG_PUSH_EVENT_SENT, ORG_ID_TAG, response.getOrgId(), + STATUS_TAG, response.getStatus().name()).increment(); Timer jobCycleTime = Timer .builder(MAAS_EMA_CONFIG_PUSH_EVENT_CYCLE_TIME) .tag(ORG_ID_TAG, response.getOrgId()) .tag(STATUS_TAG, request.getStatus().name()) - .tag(ENTITY_TYPE_TAG, response.getType()) .register(meterRegistry); jobCycleTime.record(request.getLifetime(ChronoUnit.MILLIS), TimeUnit.MILLISECONDS); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java index db9af672..06901b61 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/HeartbeatGenerator.java @@ -16,9 +16,10 @@ import java.time.Instant; import java.util.ArrayList; import java.util.List; +import java.util.Objects; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_HEARTBEAT_EVENT_SENT; +import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; @ExcludeFromJacocoGeneratedReport @Component @@ -53,7 +54,9 @@ public void sendHeartbeat() { private void logHealthMetric(HeartbeatMessage message, boolean isHealthy) { List tags = new ArrayList<>(); - tags.add(Tag.of(ENTITY_TYPE_TAG, message.getType())); + if (Objects.nonNull(message.getOrgId())) { + tags.add(Tag.of(ORG_ID_TAG, message.getOrgId())); + } meterRegistry.gauge(MAAS_EMA_HEARTBEAT_EVENT_SENT, tags, isHealthy ? 1 : 0); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanDataPublisher.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanDataPublisher.java index cc22dcc4..0b1e35b1 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanDataPublisher.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanDataPublisher.java @@ -9,8 +9,6 @@ import java.util.Map; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_SENT; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.SCAN_ID_TAG; @@ -57,7 +55,7 @@ public void sendScanData(MOPMessage message, Map topicDetails) { boolean isSuccessful = solacePublisher.publish(message, topicString); - meterRegistry.counter(MAAS_EMA_SCAN_EVENT_SENT, ENTITY_TYPE_TAG, MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE, + meterRegistry.counter(MAAS_EMA_SCAN_EVENT_SENT, STATUS_TAG, isSuccessful ? ScanStatus.COMPLETE.name() : ScanStatus.FAILED.name(), SCAN_ID_TAG, topicDetails.get("scanId"), ORG_ID_TAG, topicDetails.get("orgId")).increment(); diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanStatusPublisher.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanStatusPublisher.java index 5b8568ad..077a63fc 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanStatusPublisher.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/publisher/ScanStatusPublisher.java @@ -15,8 +15,6 @@ import java.util.List; import java.util.Map; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_SENT; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.SCAN_ID_TAG; @@ -58,8 +56,8 @@ public void sendOverallScanStatus(ScanStatusMessage message, Map throw new ScanOverallStatusException("Over all status exception: " + e.getMessage(), Map.of(scanId, List.of(e)), "Overall status", Arrays.asList(scanType.split(",")), ScanStatus.valueOf(status)); } finally { - meterRegistry.counter(MAAS_EMA_SCAN_EVENT_SENT, ENTITY_TYPE_TAG, MAAS_EMA_SCAN_COMMAND_REPLY_MESSAGE, - STATUS_TAG, status, SCAN_ID_TAG, scanId, ORG_ID_TAG, topicDetails.get("orgId")).increment(); + meterRegistry.counter(MAAS_EMA_SCAN_EVENT_SENT, STATUS_TAG, status, SCAN_ID_TAG, scanId, + ORG_ID_TAG, topicDetails.get("orgId")).increment(); } } @@ -87,8 +85,8 @@ public void sendScanDataStatus(ScanDataStatusMessage message, Map scanAsync(String groupId, String scanId, String traceId, String actorId, diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java index 27a5761c..e106c057 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/CommandMessageProcessor.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.Objects; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_CONFIG_PUSH_EVENT_RECEIVED; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ORG_ID_TAG; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.STATUS_TAG; @@ -55,7 +54,6 @@ private void logConfigPushMetric(CommandMessage message) { if (StringUtils.isNotBlank(message.getOrgId())) { tags.add(Tag.of(ORG_ID_TAG, message.getOrgId())); } - tags.add(Tag.of(ENTITY_TYPE_TAG, message.getType())); meterRegistry.counter(MAAS_EMA_CONFIG_PUSH_EVENT_RECEIVED, tags).increment(); } diff --git a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/ScanCommandMessageProcessor.java b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/ScanCommandMessageProcessor.java index 7f066834..7bcd5995 100644 --- a/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/ScanCommandMessageProcessor.java +++ b/service/application/src/main/java/com/solace/maas/ep/event/management/agent/subscriber/messageProcessors/ScanCommandMessageProcessor.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.UUID; -import static com.solace.maas.ep.common.metrics.ObservabilityConstants.ENTITY_TYPE_TAG; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.MAAS_EMA_SCAN_EVENT_RECEIVED; import static com.solace.maas.ep.common.metrics.ObservabilityConstants.SCAN_ID_TAG; @@ -41,8 +40,7 @@ public ScanCommandMessageProcessor(ScanManager scanManager, public void processMessage(ScanCommandMessage message) { MDC.clear(); String scanId = StringUtils.isEmpty(message.getScanId()) ? UUID.randomUUID().toString() : message.getScanId(); - meterRegistry.counter(MAAS_EMA_SCAN_EVENT_RECEIVED, ENTITY_TYPE_TAG, message.getType(), - SCAN_ID_TAG, scanId).increment(); + meterRegistry.counter(MAAS_EMA_SCAN_EVENT_RECEIVED, SCAN_ID_TAG, scanId).increment(); List destinations = new ArrayList<>(); List entityTypes = new ArrayList<>();