Skip to content

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

Closed
@leandrodamascena

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions