Skip to content

Maintenance: Thread-safety for Metrics Utility #2289

@phipag

Description

@phipag

Summary

The Metrics utility can be used from within the parallel batch processor. The current operating model is:

  • Create Metrics singleton using MetricsFactory or MetricsBuilder
  • Use it from anywhere within your Lambda handler
  • Flush once when the handler finishes (or max batch size is reached)

The problem in multi-threaded scenarios is that metrics configurations such as dimensions / metadata or similar will leak across threads even when flushing manually from within a thread.

Why is this needed?

This is needed to propose the expected thread-safety quality bar to customers.

Which area does this relate to?

Metrics

Solution

Use InheritableThreadLocal to manage Metrics instances.

Acknowledgment

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Coming soon

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions