Skip to content

Bug: Metrics class is unable to access namespace and service properties #2909

Closed

Description

@leandrodamascena

Expected Behaviour

Before merging PR #2194, we could directly access the service and namespace properties of the Metrics class. With refactoring this is no longer possible.

Current Behaviour

is failing to flush the metrics because there is no Namespace.

Code snippet

from aws_lambda_powertools import Metrics
from aws_lambda_powertools.metrics import MetricUnit

my_metrics = Metrics()

@my_metrics.log_metrics
def lambda_handler(event, context):
    namespace, service = "powertools", "airline"

    my_metrics.namespace = namespace
    my_metrics.service = service

    my_metrics.add_metric(name="booking",unit=MetricUnit.Count, value=2)
    
    return "success"

Possible Solution

No response

Steps to Reproduce

Create a Lambda with the code snippet example.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.11

Packaging format used

PyPi

Debugging logs

No response

Activity

  1. added
    bug
    triage
    on Aug 2, 2023
  2. moved this from Triage to Working on it in Powertools for AWS Lambda (Python)on Aug 2, 2023
  3. removed
    triage
    on Aug 2, 2023
  4. heitorlessa commented on Aug 2, 2023

    @heitorlessa
    Contributor

    looking at the PR

  5. moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python)on Aug 2, 2023
  6. github-actions commented on Aug 2, 2023

    @github-actions
    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.

  7. moved this from Shipped to Coming soon in Powertools for AWS Lambda (Python)on Aug 2, 2023
  8. added
    pending-release
    on Aug 2, 2023
  9. github-actions commented on Aug 18, 2023

    @github-actions
    Contributor

    This is now released under 2.23.0 version!

  10. removed
    pending-release
    on Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions