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 fbd7e244e0..645be2b628 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 @@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.ObjectMapper import io.awspring.cloud.sqs.operations.SqsTemplate import io.opentelemetry.api.trace.Span import io.opentelemetry.api.trace.SpanKind -import io.opentelemetry.instrumentation.annotations.SpanAttribute import io.opentelemetry.instrumentation.annotations.WithSpan import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty @@ -30,7 +29,7 @@ class QueuePublisher( private val permit = Semaphore(limit, true) @WithSpan(kind = SpanKind.PRODUCER) - override fun publish(@SpanAttribute notification: Notification<*>) { + override fun publish(notification: Notification<*>) { Span.current().updateName("PUBLISH ${notification.eventType}").setAttribute("queue", queue) notification.message?.also { _ -> permit.acquire() 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 f841489575..e8e8d3cb29 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 @@ -3,7 +3,6 @@ package uk.gov.justice.digital.hmpps.publisher import io.awspring.cloud.sns.core.SnsTemplate import io.opentelemetry.api.trace.Span import io.opentelemetry.api.trace.SpanKind -import io.opentelemetry.instrumentation.annotations.SpanAttribute import io.opentelemetry.instrumentation.annotations.WithSpan import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty @@ -25,7 +24,7 @@ class TopicPublisher( @Value("\${messaging.producer.topic}") private val topic: String ) : NotificationPublisher { @WithSpan(kind = SpanKind.PRODUCER) - override fun publish(@SpanAttribute notification: Notification<*>) { + override fun publish(notification: Notification<*>) { Span.current().updateName("PUBLISH ${notification.eventType}").setAttribute("topic", topic) notification.message?.let { message -> notificationTemplate.convertAndSend(topic, message) { msg -> diff --git a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/MailboxService.kt b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/MailboxService.kt index e9fcb0e19e..5010ce1716 100644 --- a/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/MailboxService.kt +++ b/projects/justice-email-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/MailboxService.kt @@ -23,6 +23,7 @@ class MailboxService( @WithSpan("POLL mailbox", kind = SpanKind.SERVER) fun publishUnreadMessagesToQueue() { getUnreadMessages() + .ifEmpty { return } .also { telemetryService.trackEvent("ReceivedMessages", mapOf("count" to it.size.toString())) } .forEach { notificationPublisher.publish(it.asNotification())