awslabs / awslabs/aws-embedded-metrics-java
Bug: Flushing empty metrics prints JSON with dimension values
- Dominant language
- Java
- Stars
- 48
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
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: https://github.com/aws-powertools/powertools-lambda-java/issues/1890
For example, if I do this:
```java
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:
```json
{"Service":"MyService"}
```
My expectation is that nothing should be logged because I did not call `putMetric` at any point. What do you think?
Contributor guide
Assessment
This issue has not been assessed yet.