Skip to content

Conversation

@svozza
Copy link
Contributor

@svozza svozza commented Oct 28, 2025

Summary

Last week we had to revert several PRs due to an issue with the InvokeStore module. This module has now been patched.

This PR re-introduces support for using an async context in the Metrics utility. This allows users to emit metrics that are isolated specifically to the current lambda invocation, isolated from any other executions.

Changes

  • Added specific storage classes for metrics, metadata and dimensions:
    • MetricsStore
    • MetadataStore
    • DimensionStore
  • The Metrics class only accesses the data in these stores through this interface and never touches the stored objects directly.
  • These storage classes check whether they are running in the InvokeStore context: if they are then the metrics are stored in the current async context, otherwise we fallback to a plain instance wide object as per the current implementation.
  • The storage class handle converting the data into the correct format now rather than the Metrics class, e.g., setMetric will check if the metric already exists and handle converting values into an array if the metric is already there. Likewise with setting timestamps.
  • Added specific concurrency tests to ensure isolation is working as intended for all three stores and the Metrics class as a whole.

Issue number: closes #4662


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@pull-request-size pull-request-size bot added the size/XXL PRs with 1K+ LOC, largely documentation related label Oct 28, 2025
@boring-cyborg boring-cyborg bot added dependencies Changes that touch dependencies, e.g. Dependabot, etc. metrics This item relates to the Metrics Utility tests PRs that add or change tests labels Oct 28, 2025
@svozza svozza requested a review from sdangol October 28, 2025 21:36
@svozza svozza self-assigned this Oct 28, 2025
@sonarqubecloud
Copy link

@svozza svozza merged commit 2e08f74 into main Oct 28, 2025
47 checks passed
@svozza svozza deleted the revert-metrics-revert branch October 28, 2025 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Changes that touch dependencies, e.g. Dependabot, etc. metrics This item relates to the Metrics Utility size/XXL PRs with 1K+ LOC, largely documentation related tests PRs that add or change tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Allow use of InvokeStore in Metrics

2 participants