Skip to content

Commit

Permalink
PI-2584 Don't log if no messages received (#4396)
Browse files Browse the repository at this point in the history
* PI-2584 Don't log if no messages received

* Remove automated logging of published messages
  • Loading branch information
marcus-bcl authored Nov 6, 2024
1 parent 8ef5f5e commit 137a9c3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 137a9c3

Please sign in to comment.