Closed
Description
Expected Behaviour
https://awslabs.github.io/aws-lambda-powertools-python/latest/core/metrics/#getting-started
Tip
You can initialize Metrics in any other module too. It'll keep track of your aggregate metrics in memory to optimize costs (one blob instead of multiples).
I may be wrong but I think this behavior should also apply to add_dimension. I expect to be able to add_dimension or add_metrics to any Metrics
instance. When serializing any one of the instances, an EMF blob is created and it has all metrics and dimensions.
Current Behaviour
When serializing a Metrics
instance, dimensions added to other instances do not appear.
Code snippet
def test_metrics_reuse_dimension_set(metric, dimension, namespace):
# GIVEN Metrics is initialized
my_metrics = Metrics(namespace=namespace)
my_metrics.add_dimension(**dimension)
my_metrics.add_metric(**metric)
# WHEN Metrics is initialized one more time
my_metrics_2 = Metrics(namespace=namespace)
# THEN Both class instances should have the same dimension set
assert my_metrics_2.dimension_set == my_metrics.dimension_set
### Possible Solution
_No response_
### Steps to Reproduce
1. Create two `Metrics` instances
2. Pick one to add_metric and add_dimension
3. Serialize another one
### AWS Lambda Powertools for Python version
latest
### AWS Lambda function runtime
3.8
### Packaging format used
PyPi
### Debugging logs
_No response_