Skip to content

Bug: Flushing empty metrics prints JSON with dimension values #165

@phipag

Description

@phipag

Hello team,

Philipp here from Powertools for AWS Lambda (Java). I found an issue where EMF logs a JSON object when flushing even if the customer did not add any metrics. I believe that this is a bug but wanted to confirm with you if this is expected.

Related issue in Powertools for AWS Lambda (Java) repository: aws-powertools/powertools-lambda-java#1890

For example, if I do this:

emfLogger = new software.amazon.cloudwatchlogs.emf.logger.MetricsLogger(environmentProvider,
                metricsContext);

emfLogger.setNamespace("MyNamespace");
emfLogger.putDimensions(DimensionSet.of("Service", "MyService");
emfLogger.flush()

I see this in my logs when running on AWS Lambda with Java 11 runtime:

{"Service":"MyService"}

My expectation is that nothing should be logged because I did not call putMetric at any point. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions