Skip to content

Bug: Metric.add_dimension doesn't aggregate #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cfchou opened this issue Oct 10, 2022 · 8 comments · Fixed by #1581
Closed

Bug: Metric.add_dimension doesn't aggregate #1579

cfchou opened this issue Oct 10, 2022 · 8 comments · Fixed by #1581
Assignees
Labels
bug Something isn't working

Comments

@cfchou
Copy link

cfchou commented Oct 10, 2022

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_
@cfchou cfchou added bug Something isn't working triage Pending triage from maintainers labels Oct 10, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Oct 10, 2022

Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our AWS Lambda Powertools Discord: Invite link

@heitorlessa
Copy link
Contributor

Thank you @cfchou for raising this - this is a bug. Investigating and once we have a fix we'll make a patch release ASAP

@heitorlessa heitorlessa removed the triage Pending triage from maintainers label Oct 10, 2022
@heitorlessa heitorlessa self-assigned this Oct 10, 2022
@heitorlessa
Copy link
Contributor

Got a fix (thanks to your quick tests too!). Triple checking if I haven't missed anything else before we make a release

@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Oct 10, 2022
@heitorlessa
Copy link
Contributor

Making a patch release and will share more info soon.

@github-actions
Copy link
Contributor

This is now released under 1.31.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Oct 10, 2022
@heitorlessa
Copy link
Contributor

Publishing Lambda Layer across 22 AWS regions, should be live in ~10m. Will post here when done.

@heitorlessa
Copy link
Contributor

Lambda Layer deployment complete - new version is 38 across all regions.

e.g., arn:aws:lambda:eu-west-1:017000801446:layer:AWSLambdaPowertoolsPython:38.

Please let us know if this somehow doesn't solve your end @cfchou. Thank you one more time for this great bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants