Skip to content

Add LiveActivities metrics#1838

Merged
vlbee merged 13 commits into
mainfrom
live/metrics
Jul 2, 2026
Merged

Add LiveActivities metrics#1838
vlbee merged 13 commits into
mainfrom
live/metrics

Conversation

@vlbee

@vlbee vlbee commented Jun 19, 2026

Copy link
Copy Markdown
Member

What does this change?

Adds a metrics class with liveactivity lambda namespaces.

Adds metrics for:
APNS Responses to track 2xx/5xx/4xx and network erros
Our various "do not process" scenarios - these messages will still end up in the DLQ for investigation but we can see how frequently they occur over time with metrics.

This will allow us to easily spot problems talking to APNS, as well as the frequency overtime of outlier behaviour we are handling.

How has this change been tested?

Ran in CODE.
Metrics observed in Cloudwatch.

How can we measure success?

Have we considered potential risks?

Images

Accessibility

@vlbee
vlbee requested a review from a team as a code owner June 19, 2026 12:18
@vlbee vlbee added the feature Departmental tracking: work on a new feature label Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Comment thread liveactivities/src/main/scala/com/gu/liveactivities/util/Metrics.scala Outdated
httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString()).whenComplete((response, err) => {
if (response == null) {
logger.error(s"Failed to create channel due to error ${err.getMessage}")
metrics.recordApnsNetworkError()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though sendAsync is used for the APNS call, I think CloudWatchClient.putMetricData is synchronous and blocks the whenComplete thread for handling the APNS response until CloudWatch responds. Have you considered Consider using CloudWatchAsyncClient

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics are fire once after the broadcast to APNS goes out so there no impact on the service if metrics are fired synchronously.

For the channel creation its a very low volume metric count so would only fire once per invocation and not during a live event so again the extra time would be negligible.

For channel deletions, this is a chron job unrelated to the service performance so it doesn't need to be the fastest.

Overall it's a very low volume service and there is also a risk that the main lambda process terminates before the async cloud watch thread is finished and we loose metrics on a separate thread.

For these reasons I think firing synchronously is fine.

@vlbee
vlbee merged commit fd79e80 into main Jul 2, 2026
11 checks passed
@vlbee
vlbee deleted the live/metrics branch July 2, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Departmental tracking: work on a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants