Skip to content

Bug: metadata and dimensions not cleared on publish #1115

Closed
@perpil

Description

@perpil

Bug description

When you invoke publishStoredMetrics, it clears the storedMetrics, but doesn't clear the metadata or dimensions. My understanding is that metadata and dimensions are per request, where defaultDimensions should persist between requests. The python implementation clears metadata and dimensions on publish.

Expected Behavior

Request 1:

metrics.addMetadata('field', 'value');

Log entry for metric has: field: value

Request 2:

metrics.addMetadata('field2', 'value2');

Log entry for metric has: field2: value2

Current Behavior

Request 1:

metrics.addMetadata('field', 'value');

Log entry for metric has: field: value

Request 2:

metrics.addMetadata('field2', 'value2');

Log entry for metric has: field: value and field2: value2

Possible Solution

Invoke clearMetadata() and clearDimensions() as part of publishStoredMetrics()

Steps to Reproduce

See current behavior

Environment

  • Powertools version used: 1.2.1
  • Packaging format (Layers, npm): npm
  • AWS Lambda function runtime: node 16
  • Debugging logs: N/A

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompletedThis item is complete and has been merged/shippedgood-first-issueSomething that is suitable for those who want to start contributingmetricsThis item relates to the Metrics Utility

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions