Skip to content

Metrics: Problem with default dimension creation #75

Closed
@to-mc

Description

@to-mc

When metrics are being emitted during function execution using the log_metrics decorator e.g.:

from aws_lambda_powertools.metrics import Metrics

metrics = Metrics(service="cart-service")

@metrics.log_metrics
def lambda_handler(event, context):
    metrics.add_metric(name="CartUpdated", unit="Count", value=1)

The function runs successfully on cold starts, but throws an error due to missing dimensions on subsequent executions.

What were you trying to accomplish?

Expected Behavior

The default "service" dimension should be added to every metric created, not just the first one.

Current Behavior

The default "service" dimension is only being added to the first metric serialized, causing schema validation errors

Environment

  • Powertools version used: 0.10.0
  • Packaging format (Layers, PyPi): PyPi
  • AWS Lambda function runtime: 3.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions