diff --git a/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryService.kt b/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryService.kt index e4cd3864ca..a4953669f0 100644 --- a/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryService.kt +++ b/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryService.kt @@ -1,10 +1,10 @@ package uk.gov.justice.digital.hmpps.telemetry import com.microsoft.applicationinsights.TelemetryClient +import com.microsoft.applicationinsights.telemetry.TelemetryContext import org.slf4j.LoggerFactory import org.springframework.scheduling.annotation.Async import org.springframework.stereotype.Service -import java.lang.Exception @Service class TelemetryService(private val telemetryClient: TelemetryClient = TelemetryClient()) { @@ -27,4 +27,6 @@ class TelemetryService(private val telemetryClient: TelemetryClient = TelemetryC log.debug("{} {} {}", exception.message, properties, metrics) telemetryClient.trackException(exception, properties, metrics) } + + fun getContext(): TelemetryContext = telemetryClient.context } diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/listener/AwsNotificationListener.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/listener/AwsNotificationListener.kt index 9407d1a448..80409c099e 100644 --- a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/listener/AwsNotificationListener.kt +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/listener/AwsNotificationListener.kt @@ -1,12 +1,17 @@ package uk.gov.justice.digital.hmpps.listener +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import io.awspring.cloud.sqs.annotation.SqsListener import io.awspring.cloud.sqs.listener.AsyncAdapterBlockingExecutionFailedException import io.awspring.cloud.sqs.listener.ListenerExecutionFailedException import io.opentelemetry.api.trace.SpanKind +import io.opentelemetry.instrumentation.annotations.SpanAttribute import io.opentelemetry.instrumentation.annotations.WithSpan import io.sentry.Sentry import io.sentry.spring.jakarta.tracing.SentryTransaction +import org.slf4j.Logger +import org.slf4j.LoggerFactory import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression import org.springframework.context.annotation.Conditional import org.springframework.dao.CannotAcquireLockException @@ -17,36 +22,35 @@ import org.springframework.transaction.CannotCreateTransactionException import org.springframework.transaction.UnexpectedRollbackException import org.springframework.web.client.RestClientException import uk.gov.justice.digital.hmpps.config.AwsCondition +import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.NotificationHandler import uk.gov.justice.digital.hmpps.retry.retry +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.extractSpanContext +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.startSpan import java.util.concurrent.CompletionException @Component @Conditional(AwsCondition::class) @ConditionalOnExpression("\${messaging.consumer.enabled:true} and '\${messaging.consumer.queue:}' != ''") class AwsNotificationListener( - private val handler: NotificationHandler<*> + private val handler: NotificationHandler<*>, + private val objectMapper: ObjectMapper ) { - @SqsListener("\${messaging.consumer.queue}") - @SentryTransaction(operation = "messaging") @WithSpan(kind = SpanKind.CONSUMER) - fun receive(message: String) { - try { - retry( - 3, - listOf( - RestClientException::class, - CannotAcquireLockException::class, - ObjectOptimisticLockingFailureException::class, - CannotCreateTransactionException::class, - CannotGetJdbcConnectionException::class, - UnexpectedRollbackException::class - ) - ) { handler.handle(message) } - } catch (e: Throwable) { - Sentry.captureException(unwrapSqsExceptions(e)) - throw e + @SentryTransaction(operation = "messaging") + @SqsListener("\${messaging.consumer.queue}") + fun receive(@SpanAttribute message: String) { + val attributes = objectMapper.readValue(message, jacksonTypeRef>()).attributes + val span = attributes.extractSpanContext().startSpan(this::class.java.name, "receive", SpanKind.CONSUMER) + span.makeCurrent().use { + try { + retry(3, RETRYABLE_EXCEPTIONS) { handler.handle(message) } + } catch (e: Throwable) { + Sentry.captureException(unwrapSqsExceptions(e)) + throw e + } } + span.end() } fun unwrapSqsExceptions(e: Throwable): Throwable { @@ -63,4 +67,16 @@ class AwsNotificationListener( } return cause } + + companion object { + private val log: Logger = LoggerFactory.getLogger(this::class.java) + val RETRYABLE_EXCEPTIONS = listOf( + RestClientException::class, + CannotAcquireLockException::class, + ObjectOptimisticLockingFailureException::class, + CannotCreateTransactionException::class, + CannotGetJdbcConnectionException::class, + UnexpectedRollbackException::class + ) + } } diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/Notification.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/Notification.kt index 9f754e95c1..221242d81d 100644 --- a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/Notification.kt +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/Notification.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonProperty -import java.util.UUID +import java.util.* data class Notification( @JsonProperty("Message") val message: T, @@ -21,9 +21,14 @@ data class MessageAttributes( constructor(eventType: String) : this(mutableMapOf("eventType" to MessageAttribute("String", eventType))) override operator fun get(key: String): MessageAttribute? = attributes[key] + operator fun set(key: String, value: MessageAttribute) { attributes[key] = value } + + operator fun set(key: String, value: String) { + set(key, MessageAttribute("String", value)) + } } data class MessageAttribute(@JsonProperty("Type") val type: String, @JsonProperty("Value") val value: String) diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/publisher/QueuePublisher.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/publisher/QueuePublisher.kt index aabb2a3f04..d741f8a4f4 100644 --- a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/publisher/QueuePublisher.kt +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/publisher/QueuePublisher.kt @@ -2,6 +2,8 @@ package uk.gov.justice.digital.hmpps.publisher import com.fasterxml.jackson.databind.ObjectMapper import io.awspring.cloud.sqs.operations.SqsTemplate +import io.opentelemetry.api.trace.SpanKind +import io.opentelemetry.instrumentation.annotations.WithSpan import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.context.annotation.Conditional @@ -10,6 +12,7 @@ import org.springframework.messaging.support.MessageBuilder import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.config.AwsCondition import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.withSpanContext import java.util.concurrent.Semaphore @Component @@ -23,6 +26,8 @@ class QueuePublisher( ) : NotificationPublisher { private val permit = Semaphore(limit, true) + + @WithSpan(kind = SpanKind.PRODUCER) override fun publish(notification: Notification<*>) { notification.message?.also { _ -> permit.acquire() @@ -35,12 +40,7 @@ class QueuePublisher( } private fun Notification<*>.asMessage() = MessageBuilder.createMessage( - objectMapper.writeValueAsString( - Notification( - message = objectMapper.writeValueAsString(message), - attributes - ) - ), - MessageHeaders(attributes.map { it.key to it.value.value }.toMap()) + objectMapper.writeValueAsString(Notification(objectMapper.writeValueAsString(message), attributes)), + MessageHeaders(attributes.map { it.key to it.value.value }.toMap()).withSpanContext() ) } diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/publisher/TopicPublisher.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/publisher/TopicPublisher.kt index 38ee8d9a7b..f5a64a8843 100644 --- a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/publisher/TopicPublisher.kt +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/publisher/TopicPublisher.kt @@ -1,6 +1,8 @@ package uk.gov.justice.digital.hmpps.publisher import io.awspring.cloud.sns.core.SnsTemplate +import io.opentelemetry.api.trace.SpanKind +import io.opentelemetry.instrumentation.annotations.WithSpan import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.context.annotation.Conditional @@ -10,6 +12,7 @@ import org.springframework.messaging.support.MessageBuilder import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.config.AwsCondition import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.withSpanContext @Primary @Component @@ -19,12 +22,13 @@ class TopicPublisher( private val notificationTemplate: SnsTemplate, @Value("\${messaging.producer.topic}") private val topic: String ) : NotificationPublisher { + @WithSpan(kind = SpanKind.PRODUCER) override fun publish(notification: Notification<*>) { notification.message?.let { message -> notificationTemplate.convertAndSend(topic, message) { msg -> MessageBuilder.createMessage( msg.payload, - MessageHeaders(notification.attributes.map { it.key to it.value.value }.toMap()) + MessageHeaders(notification.attributes.map { it.key to it.value.value }.toMap()).withSpanContext(), ) } } diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryMessagingExtensions.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryMessagingExtensions.kt new file mode 100644 index 0000000000..3d4e7c0f34 --- /dev/null +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryMessagingExtensions.kt @@ -0,0 +1,51 @@ +package uk.gov.justice.digital.hmpps.telemetry + +import io.opentelemetry.api.GlobalOpenTelemetry +import io.opentelemetry.api.trace.Span +import io.opentelemetry.api.trace.SpanKind +import io.opentelemetry.context.Context +import io.opentelemetry.context.propagation.TextMapGetter +import org.springframework.messaging.MessageHeaders +import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent +import uk.gov.justice.digital.hmpps.message.MessageAttributes +import uk.gov.justice.digital.hmpps.message.Notification + +object TelemetryMessagingExtensions { + fun MessageHeaders.withSpanContext(): MessageHeaders { + val map = this.toMutableMap() + val context = Context.current().with(Span.current()) + GlobalOpenTelemetry.getPropagators().textMapPropagator + .inject(context, map) { carrier, key, value -> carrier!![key] = value } + return MessageHeaders(map) + } + + fun MessageAttributes.extractSpanContext(): Context { + val getter = object : TextMapGetter { + override fun keys(carrier: MessageAttributes) = carrier.keys + override fun get(carrier: MessageAttributes?, key: String) = carrier?.get(key)?.value + } + return GlobalOpenTelemetry.getPropagators().textMapPropagator.extract(Context.current(), this, getter) + } + + fun Context.startSpan(scopeName: String, spanName: String, spanKind: SpanKind = SpanKind.INTERNAL): Span { + val tracer = GlobalOpenTelemetry.getTracer(scopeName) + return tracer.spanBuilder(spanName).setParent(this).setSpanKind(spanKind).startSpan() + } + + fun TelemetryService.hmppsEventReceived(hmppsEvent: HmppsDomainEvent) { + trackEvent( + "NotificationReceived", + mapOf("eventType" to hmppsEvent.eventType) + + (hmppsEvent.detailUrl?.let { mapOf("detailUrl" to it) } ?: mapOf()) + + (hmppsEvent.personReference.identifiers.associate { Pair(it.type, it.value) }) + ) + } + + fun TelemetryService.notificationReceived(notification: Notification) { + if (notification.message is HmppsDomainEvent) { + hmppsEventReceived(notification.message) + } else { + trackEvent("NotificationReceived", notification.eventType?.let { mapOf("eventType" to it) } ?: mapOf()) + } + } +} diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryService.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryService.kt deleted file mode 100644 index 1b98da69af..0000000000 --- a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryService.kt +++ /dev/null @@ -1,23 +0,0 @@ -package uk.gov.justice.digital.hmpps.telemetry - -import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent -import uk.gov.justice.digital.hmpps.message.Notification - -fun TelemetryService.hmppsEventReceived(hmppsEvent: HmppsDomainEvent) { - trackEvent( - "${hmppsEvent.eventType.uppercase().replace(".", "_")}_RECEIVED", - mapOf("eventType" to hmppsEvent.eventType) + - (hmppsEvent.detailUrl?.let { mapOf("detailUrl" to it) } ?: mapOf()) + - (hmppsEvent.personReference.identifiers.associate { Pair(it.type, it.value) }) - ) -} - -fun TelemetryService.notificationReceived(notification: Notification) { - if (notification.message is HmppsDomainEvent) { - hmppsEventReceived(notification.message) - } else { - notification.eventType?.let { - trackEvent("${it.uppercase().replace(".", "_")}_RECEIVED", mapOf("eventType" to it)) - } ?: trackEvent("UNKNOWN_EVENT_RECEIVED") - } -} diff --git a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/listener/AwsNotificationListenerTest.kt b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/listener/AwsNotificationListenerTest.kt index ae90e3e426..d438afbce6 100644 --- a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/listener/AwsNotificationListenerTest.kt +++ b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/listener/AwsNotificationListenerTest.kt @@ -1,10 +1,13 @@ package uk.gov.justice.digital.hmpps.listener +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.ObjectMapper import io.awspring.cloud.sqs.listener.AsyncAdapterBlockingExecutionFailedException import io.awspring.cloud.sqs.listener.ListenerExecutionFailedException import io.sentry.Sentry import org.hamcrest.CoreMatchers.equalTo import org.hamcrest.MatcherAssert.assertThat +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.junit.jupiter.api.extension.ExtendWith @@ -12,9 +15,11 @@ import org.mockito.InjectMocks import org.mockito.Mock import org.mockito.Mockito.mockStatic import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.any import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import org.springframework.messaging.support.GenericMessage +import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.NotificationHandler import java.util.concurrent.CompletionException @@ -23,9 +28,18 @@ class AwsNotificationListenerTest { @Mock lateinit var handler: NotificationHandler + @Mock + lateinit var objectMapper: ObjectMapper + @InjectMocks lateinit var listener: AwsNotificationListener + @BeforeEach + fun setUp() { + whenever(objectMapper.readValue(any(), any>>())) + .thenReturn(Notification("message")) + } + @Test fun `messages are dispatched to handler`() { listener.receive("message") diff --git a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryServiceTest.kt b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryMessagingExtensionsTest.kt similarity index 77% rename from libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryServiceTest.kt rename to libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryMessagingExtensionsTest.kt index 9652b83ff0..dabcad6af1 100644 --- a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryServiceTest.kt +++ b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/telemetry/TelemetryMessagingExtensionsTest.kt @@ -2,9 +2,7 @@ package uk.gov.justice.digital.hmpps.telemetry import com.microsoft.applicationinsights.TelemetryClient import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.equalTo -import org.hamcrest.Matchers.hasProperty -import org.hamcrest.Matchers.not +import org.hamcrest.Matchers.* import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -14,15 +12,13 @@ import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.check import org.mockito.kotlin.eq import org.mockito.kotlin.verify -import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent -import uk.gov.justice.digital.hmpps.message.MessageAttributes -import uk.gov.justice.digital.hmpps.message.Notification -import uk.gov.justice.digital.hmpps.message.PersonIdentifier -import uk.gov.justice.digital.hmpps.message.PersonReference +import uk.gov.justice.digital.hmpps.message.* +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.hmppsEventReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import java.time.ZonedDateTime @ExtendWith(MockitoExtension::class) -class TelemetryServiceTest { +class TelemetryMessagingExtensionsTest { @Mock private lateinit var telemetryClient: TelemetryClient @@ -52,7 +48,7 @@ class TelemetryServiceTest { ) verify(telemetryClient).trackEvent( - eq("SOME_SPECIAL_EVENT_RECEIVED"), + eq("NotificationReceived"), check { assertThat(it["eventType"], equalTo(eventType)) assertThat(it["detailUrl"], equalTo(detailUrl)) @@ -73,7 +69,7 @@ class TelemetryServiceTest { ) verify(telemetryClient).trackEvent( - eq("SOME_SPECIAL_EVENT_RECEIVED"), + eq("NotificationReceived"), check { assertThat(it, not(hasProperty("detailUrl"))) }, anyMap() ) @@ -88,13 +84,13 @@ class TelemetryServiceTest { ) ) - verify(telemetryClient).trackEvent(eq("TEST_EVENT_RECEIVED"), anyMap(), anyMap()) + verify(telemetryClient).trackEvent(eq("NotificationReceived"), anyMap(), anyMap()) } @Test fun `handles events with no event type`() { telemetryService.notificationReceived(Notification(message = "this is a string")) - verify(telemetryClient).trackEvent(eq("UNKNOWN_EVENT_RECEIVED"), anyMap(), anyMap()) + verify(telemetryClient).trackEvent(eq("NotificationReceived"), anyMap(), anyMap()) } } diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index f298633c71..7421031983 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -10,6 +10,7 @@ import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.service.ApprovedPremisesService +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import java.net.URI @@ -35,6 +36,7 @@ class Handler( ] ) override fun handle(notification: Notification) { + telemetryService.notificationReceived(notification) val event = notification.message try { when (event.eventType) { diff --git a/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 491951f818..d034e9c00e 100644 --- a/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/approved-premises-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -11,7 +11,6 @@ import org.mockito.Mock import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.verify import uk.gov.justice.digital.hmpps.converter.NotificationConverter -import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.message.PersonIdentifier @@ -19,7 +18,6 @@ import uk.gov.justice.digital.hmpps.message.PersonReference import uk.gov.justice.digital.hmpps.prepEvent import uk.gov.justice.digital.hmpps.service.ApprovedPremisesService import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.time.ZonedDateTime @ExtendWith(MockitoExtension::class) diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 0602978fc3..0c48626a16 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -12,8 +12,8 @@ import uk.gov.justice.digital.hmpps.integrations.oasys.OrdsClient import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.service.AssessmentSubmitted +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI const val AssessmentSummaryProduced = "assessment.summary.produced" diff --git a/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index c18d2fd8a0..ebc1c47a6b 100644 --- a/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/cas2-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -19,8 +19,8 @@ import uk.gov.justice.digital.hmpps.entity.ContactRepository import uk.gov.justice.digital.hmpps.entity.ContactType.Companion.REFERRAL_SUBMITTED import uk.gov.justice.digital.hmpps.entity.ContactType.Companion.REFERRAL_UPDATED import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.time.LocalDate import java.time.ZonedDateTime diff --git a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 5612c27d37..a4a7d14b5c 100644 --- a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -12,8 +12,8 @@ import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.service.Cas2Service +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component @Channel("cas2-and-delius-queue") diff --git a/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt b/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt index b2b64eacf3..7c6b194c73 100644 --- a/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt +++ b/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt @@ -26,8 +26,8 @@ import uk.gov.justice.digital.hmpps.integrations.delius.entity.PersonRepository import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.messaging.crn import uk.gov.justice.digital.hmpps.resourceloader.ResourceLoader +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.time.ZonedDateTime @AutoConfigureMockMvc diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 9927a9a9ce..84730672fc 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -15,8 +15,8 @@ import uk.gov.justice.digital.hmpps.integrations.delius.entity.PersonRepository import uk.gov.justice.digital.hmpps.integrations.delius.entity.getByCrn import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index c42bc9dbb7..ec410c8631 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -16,8 +16,8 @@ import uk.gov.justice.digital.hmpps.integrations.courtcase.CourtCaseNote import uk.gov.justice.digital.hmpps.integrations.delius.service.DeliusIntegrationService import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component diff --git a/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index a12abe6242..7a0b6bbfb4 100644 --- a/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/custody-key-dates-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -23,8 +23,8 @@ import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.contact.Con import uk.gov.justice.digital.hmpps.message.MessageAttributes import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.time.LocalDate import java.time.ZonedDateTime import java.time.temporal.ChronoUnit diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index c190c1af81..4b06b16216 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -13,8 +13,8 @@ import uk.gov.justice.digital.hmpps.integrations.delius.custody.date.CustodyDate import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonRepository import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component @Channel("custody-key-dates-and-delius-queue") diff --git a/projects/make-recall-decisions-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/RecommendationIntegrationTest.kt b/projects/make-recall-decisions-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/RecommendationIntegrationTest.kt index 87dd7a0eb3..6d358676c4 100644 --- a/projects/make-recall-decisions-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/RecommendationIntegrationTest.kt +++ b/projects/make-recall-decisions-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/RecommendationIntegrationTest.kt @@ -16,8 +16,8 @@ import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.UserGenerator import uk.gov.justice.digital.hmpps.integrations.delius.recommendation.contact.entity.Contact import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @SpringBootTest internal class RecommendationIntegrationTest { diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index e4569b0a06..8df068ac9b 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -10,8 +10,8 @@ import uk.gov.justice.digital.hmpps.integrations.makerecalldecisions.MakeRecallD import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.service.RecommendationService +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component diff --git a/projects/make-recall-decisions-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/make-recall-decisions-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 6f259d2194..f8a870ea16 100644 --- a/projects/make-recall-decisions-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/make-recall-decisions-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -17,8 +17,8 @@ import uk.gov.justice.digital.hmpps.message.MessageAttributes import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.message.PersonReference import uk.gov.justice.digital.hmpps.service.RecommendationService +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @ExtendWith(MockitoExtension::class) diff --git a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index fd6753d1c3..396ba17e63 100644 --- a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -19,8 +19,8 @@ import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.repository.DetailedOffenceRepository import uk.gov.justice.digital.hmpps.repository.ReferenceDataRepository import uk.gov.justice.digital.hmpps.repository.findCourtCategory +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component @Transactional diff --git a/projects/manage-offences-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/manage-offences-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 499c245721..16cca4eb55 100644 --- a/projects/manage-offences-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/manage-offences-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -24,8 +24,8 @@ import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.repository.DetailedOffenceRepository import uk.gov.justice.digital.hmpps.repository.ReferenceDataRepository import uk.gov.justice.digital.hmpps.resourceloader.ResourceLoader +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.time.LocalDate @ExtendWith(MockitoExtension::class) diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/PomCaseMessageHandler.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/PomCaseMessageHandler.kt index a89bd15377..577724ebed 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/PomCaseMessageHandler.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/PomCaseMessageHandler.kt @@ -20,8 +20,8 @@ import uk.gov.justice.digital.hmpps.message.PersonIdentifier import uk.gov.justice.digital.hmpps.message.PersonReference import uk.gov.justice.digital.hmpps.services.HandoverDatesChanged import uk.gov.justice.digital.hmpps.services.PomAllocated +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component @Channel("manage-pom-cases-and-delius-queue") diff --git a/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrCompletedIntegrationTest.kt b/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrCompletedIntegrationTest.kt index e81cba927b..42e39b21c4 100644 --- a/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrCompletedIntegrationTest.kt +++ b/projects/pre-sentence-reports-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PsrCompletedIntegrationTest.kt @@ -16,8 +16,8 @@ import uk.gov.justice.digital.hmpps.data.generator.DocumentGenerator import uk.gov.justice.digital.hmpps.integrations.alfresco.AlfrescoUploadClient import uk.gov.justice.digital.hmpps.integrations.delius.document.DocumentRepository import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @SpringBootTest class PsrCompletedIntegrationTest { diff --git a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index d719e27da3..70f6cd8d42 100644 --- a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -9,8 +9,8 @@ import uk.gov.justice.digital.hmpps.integrations.delius.document.DocumentService import uk.gov.justice.digital.hmpps.integrations.psr.PsrClient import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index d150635be2..0b02ef8e98 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -18,8 +18,8 @@ import uk.gov.justice.digital.hmpps.integrations.prison.PrisonCaseNotesClient import uk.gov.justice.digital.hmpps.integrations.prison.toDeliusCaseNote import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component diff --git a/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index c23ba7a4fa..c706d05883 100644 --- a/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -152,7 +152,7 @@ internal class HandlerTest { whenever(deliusService.mergeCaseNote(any())).thenThrow(OffenderNotFoundException("A001")) handler.handle(poe) - verify(telemetryService).trackEvent(eq("PRISON_CASE-NOTE_PUBLISHED_RECEIVED"), any(), any()) + verify(telemetryService).trackEvent(eq("NotificationReceived"), any(), any()) verify(telemetryService).trackEvent(eq("CaseNoteMergeFailed"), any(), any()) } @@ -176,7 +176,7 @@ internal class HandlerTest { whenever(deliusService.mergeCaseNote(any())).thenThrow(StaffCodeExhaustedException("A999")) assertThrows { handler.handle(poe) } - verify(telemetryService).trackEvent(eq("PRISON_CASE-NOTE_PUBLISHED_RECEIVED"), any(), any()) + verify(telemetryService).trackEvent(eq("NotificationReceived"), any(), any()) verify(telemetryService).trackEvent(eq("CaseNoteMergeFailed"), any(), any()) } } diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 9fde4fd413..44ee153116 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -16,6 +16,7 @@ import uk.gov.justice.digital.hmpps.integrations.prison.PrisonApiClient import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.DomainEventType.* +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import java.time.ZonedDateTime @@ -41,6 +42,7 @@ class Handler( ] ) override fun handle(notification: Notification) { + telemetryService.notificationReceived(notification) val message = notification.message val eventType = DomainEventType.of(message.eventType) try { diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 62712b5fdd..21a92a8edd 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -11,8 +11,8 @@ import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.model.logResult import uk.gov.justice.digital.hmpps.service.PrisonMatchingService import uk.gov.justice.digital.hmpps.service.ProbationMatchingService +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component @Channel("prison-identifier-and-delius-queue") diff --git a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 08bd88527e..92ca45873f 100644 --- a/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/risk-assessment-scores-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -8,8 +8,8 @@ import uk.gov.justice.digital.hmpps.integrations.delius.RiskAssessmentService import uk.gov.justice.digital.hmpps.integrations.delius.RiskScoreService import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component class Handler( diff --git a/projects/risk-assessment-scores-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/risk-assessment-scores-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 1fc97faf81..485f5e88fc 100644 --- a/projects/risk-assessment-scores-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/risk-assessment-scores-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -18,8 +18,8 @@ import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.MessageAttributes import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.message.PersonReference +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @ExtendWith(MockitoExtension::class) internal class HandlerTest { diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 332a4074e5..1aa67805db 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -10,8 +10,8 @@ import uk.gov.justice.digital.hmpps.integrations.tier.TierClient import uk.gov.justice.digital.hmpps.integrations.tier.TierService import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component diff --git a/projects/tier-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/tier-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index d32c8eb863..72edcda053 100644 --- a/projects/tier-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/tier-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -13,8 +13,8 @@ import uk.gov.justice.digital.hmpps.integrations.tier.TierClient import uk.gov.justice.digital.hmpps.integrations.tier.TierService import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.prepMessage +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI import java.time.ZonedDateTime.now diff --git a/projects/unpaid-work-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AssessmentCompleteIntegrationTest.kt b/projects/unpaid-work-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AssessmentCompleteIntegrationTest.kt index 9141918c61..6bcac57d34 100644 --- a/projects/unpaid-work-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AssessmentCompleteIntegrationTest.kt +++ b/projects/unpaid-work-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AssessmentCompleteIntegrationTest.kt @@ -18,8 +18,8 @@ import uk.gov.justice.digital.hmpps.integrations.common.entity.contact.ContactRe import uk.gov.justice.digital.hmpps.integrations.common.entity.contact.type.ContactTypeCode import uk.gov.justice.digital.hmpps.integrations.document.DocumentRepository import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @AutoConfigureMockMvc @SpringBootTest(webEnvironment = RANDOM_PORT) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index b53006b390..ecb3ab4a3b 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -8,8 +8,8 @@ import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.integrations.upwassessment.UPWAssessmentService import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component @Channel("unpaid-work-and-delius-queue") diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocatePersonIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocatePersonIntegrationTest.kt index 51f68fd4cf..d8ac15c5f5 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocatePersonIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocatePersonIntegrationTest.kt @@ -15,16 +15,11 @@ import org.springframework.data.repository.findByIdOrNull import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator import uk.gov.justice.digital.hmpps.data.generator.PersonManagerGenerator import uk.gov.justice.digital.hmpps.data.generator.ResponsibleOfficerGenerator -import uk.gov.justice.digital.hmpps.integrations.delius.person.Person -import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonManager -import uk.gov.justice.digital.hmpps.integrations.delius.person.PersonManagerRepository -import uk.gov.justice.digital.hmpps.integrations.delius.person.ResponsibleOfficer -import uk.gov.justice.digital.hmpps.integrations.delius.person.ResponsibleOfficerRepository +import uk.gov.justice.digital.hmpps.integrations.delius.person.* import uk.gov.justice.digital.hmpps.integrations.workforceallocations.AllocationDetail import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.resourceloader.ResourceLoader import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.time.ZonedDateTime @SpringBootTest diff --git a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateRequirementIntegrationTest.kt b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateRequirementIntegrationTest.kt index 8fa3185928..4a326aadc6 100644 --- a/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateRequirementIntegrationTest.kt +++ b/projects/workforce-allocations-to-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/AllocateRequirementIntegrationTest.kt @@ -21,7 +21,6 @@ import uk.gov.justice.digital.hmpps.integrations.workforceallocations.Allocation import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.resourceloader.ResourceLoader import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.time.ZonedDateTime @SpringBootTest diff --git a/templates/projects/message-listener-with-api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/templates/projects/message-listener-with-api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index b68acb58f1..60d06af963 100644 --- a/templates/projects/message-listener-with-api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/templates/projects/message-listener-with-api-client-and-server/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -17,7 +17,7 @@ import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import java.util.concurrent.TimeoutException @AutoConfigureMockMvc diff --git a/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 0107ffb74c..c865ae9d77 100644 --- a/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -7,7 +7,7 @@ import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived @Component @Channel("$SERVICE_NAME-queue") diff --git a/templates/projects/message-listener-with-api-client-and-server/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/templates/projects/message-listener-with-api-client-and-server/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 117e0f2ee9..5345a539df 100644 --- a/templates/projects/message-listener-with-api-client-and-server/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/templates/projects/message-listener-with-api-client-and-server/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -11,7 +11,7 @@ import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived @ExtendWith(MockitoExtension::class) internal class HandlerTest { diff --git a/templates/projects/message-listener-with-api-client/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/templates/projects/message-listener-with-api-client/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index e8fd3efbdc..2c6461b551 100644 --- a/templates/projects/message-listener-with-api-client/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/templates/projects/message-listener-with-api-client/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -11,7 +11,7 @@ import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import java.util.concurrent.TimeoutException @SpringBootTest diff --git a/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 0107ffb74c..c865ae9d77 100644 --- a/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -7,7 +7,7 @@ import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived @Component @Channel("$SERVICE_NAME-queue") diff --git a/templates/projects/message-listener-with-api-client/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/templates/projects/message-listener-with-api-client/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 117e0f2ee9..5345a539df 100644 --- a/templates/projects/message-listener-with-api-client/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/templates/projects/message-listener-with-api-client/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -11,7 +11,7 @@ import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived @ExtendWith(MockitoExtension::class) internal class HandlerTest { diff --git a/templates/projects/message-listener/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/templates/projects/message-listener/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index e8fd3efbdc..2c6461b551 100644 --- a/templates/projects/message-listener/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/templates/projects/message-listener/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -11,7 +11,7 @@ import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.HmppsChannelManager import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived import java.util.concurrent.TimeoutException @SpringBootTest diff --git a/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 0107ffb74c..c865ae9d77 100644 --- a/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -7,7 +7,7 @@ import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived @Component @Channel("$SERVICE_NAME-queue") diff --git a/templates/projects/message-listener/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/templates/projects/message-listener/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 117e0f2ee9..5345a539df 100644 --- a/templates/projects/message-listener/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/templates/projects/message-listener/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -11,7 +11,7 @@ import uk.gov.justice.digital.hmpps.data.generator.MessageGenerator import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.telemetry.TelemetryService -import uk.gov.justice.digital.hmpps.telemetry.notificationReceived +import uk.gov.justice.digital.hmpps.telemetry.TelemetryMessagingExtensions.notificationReceived @ExtendWith(MockitoExtension::class) internal class HandlerTest {