Updating dependencies:
- uk.gov.justice.hmpps.gradle-spring-boot:uk.gov.justice.hmpps.gradle-spring-boot.gradle.plugin [6.1.0 -> 6.1.1]
- org.springframework.boot:spring-boot-dependencies [3.4.0 -> 3.4.1]
- io.spring.dependency-management:io.spring.dependency-management.gradle.plugin [1.1.6 -> 1.1.7]
We now allow the parameter messageGroupId in HmppsTopic.publish method. This is required when you want to publish a message on a FIFO topic.
Updating dependencies:
- uk.gov.justice.hmpps.gradle-spring-boot:uk.gov.justice.hmpps.gradle-spring-boot.gradle.plugin [6.0.8 -> 6.1.0]
- org.springframework.boot:spring-boot-dependencies [3.3.5 -> 3.4.0]
- software.amazon.awssdk:bom [2.28.29 -> 2.29.20]
- io.awspring.cloud:spring-cloud-aws-sns [3.2.0 -> 3.2.1]
- com.amazonaws:aws-java-sdk-core [1.12.777 -> 1.12.778]
- com.microsoft.azure:applicationinsights-agent [3.6.1 -> 3.6.2]
- org.testcontainers:localstack [1.20.3 -> 1.20.4]
Allow Java applications to use distributed tracing.
Previous versions would throw an exception when trying to initialise MessageAttributes when consuming each message, although message consumption works as expected.
We now set the status code to ERROR
and record the exception in the span when a message is processed. This means that
the AppRequest
will now be recorded with Success
of false
if the listener throws an exception. The exception will
then also be linked by OperationId
and have an OperationName
set correctly too.
The downside of this approach is that the exception is also thrown by
io.awspring.cloud.sqs.listener.sink.AbstractMessageProcessingPipelineSink
, however since that exception processing
happens outside the span, the OperationId
isn't recorded. Exception logging is quite expensive in Log Analytics,
since it contains a full stack trace. This means that it is important not to record the same exception twice, so we
now have to ensure that the one without the OperationId
is discarded.
The recommended approach to discarding the exception outside our span is to add
{
"sampling": {
"overrides": [
{
"telemetryType": "exception",
"attributes": [
{
"key": "exception.type",
"value": "java.util.concurrent.CompletionException",
"matchType": "strict"
}
],
"percentage": 10
}
]
}
}
to your applicationinsights.json
. Note that we choose to sample at 10% rather than at 0, in case there are some
circumstances where the RECEIVE span isn't operational e.g. invalid message. We would only see 1 in 10 of those
messages, but that is better than not seeing any at all and sending lots of unnecessary logging to Log Analytics.
Script to add in the above sampling to existing application insights files:
for file in $(ls application*);do
jq '.sampling.overrides += [{ telemetryType: "exception", attributes: [ { key: "exception.type", value: "java.util.concurrent.CompletionException", "matchType": "strict" } ], percentage: 10 }]' $file > bob
mv bob $file
done
Note that jq
doesn't come with an edit inplace option (-i
) like sed
or yq
so have to output to temporary file
and then move it to the original.
As a side note - it is worth removing any @WithSpan
annotations from your listeners otherwise you will be creating
extra AppRequests
unnecessarily since this library will also start a new span for you.
Updating dependencies:
- uk.gov.justice.hmpps.gradle-spring-boot:uk.gov.justice.hmpps.gradle-spring-boot.gradle.plugin [6.0.6 -> 6.0.8]
- org.springframework.boot:spring-boot-dependencies [3.3.4 -> 3.3.5]
- org.jetbrains.kotlin:kotlin-stdlib [2.0.20 -> 2.0.21]
- org.wiremock:wiremock-standalone [3.9.1 -> 3.9.2]
Bug fix - ignore null
MessageAttributes in the payload and attempt then to parse message attributes instead.
HmppsQueueService.eventTypeMessageAttributesNoTracing
has been removed, in preference to an additional noTracing
boolean parameter on
HmppsQueueServiceeventTypeMessageAttributes
that defaults to false.
Helper methods HmppsQueueService.eventTypeSnsMap
and HmppsQueueService.eventTypeSqsMap
to make it easier to add a
eventType
message attribute.