Skip to content

Conversation

phipag
Copy link
Contributor

@phipag phipag commented Jun 16, 2025

Issue #, if available: #1890

Description of changes:

Flushing without metrics has unexpected behavior in the aws-embedded-metrics library. It prints the root-level section of the _aws EMF dict to STDOUT which we don't want. We want to log a simple warning only.

Before:

{"Service":"payment","logStreamId":"$LATEST","functionVersion":"$LATEST","executionEnvironment":"AWS_Lambda_java11"}

After:

// No output

I added a unit test catching this bug.

Note: The PMD linting about Empty Catch Blocks is expected. We don't want to bubble up EMF exceptions to the consumer because we already do our own validation.

Checklist

Copy link

@phipag phipag merged commit 8a040ac into main Jun 16, 2025
15 checks passed
@phipag phipag deleted the phipag/issue1890 branch June 16, 2025 15:00
@github-project-automation github-project-automation bot moved this from Pending review to Coming soon in Powertools for AWS Lambda (Java) Jun 16, 2025
phipag added a commit that referenced this pull request Jun 18, 2025
…ng root-level _aws dict (#1891)

* fix(metrics): Do not flush when no metrics were added to avoid printing root-level _aws dict.

* Fix pmd linting failures.
phipag added a commit that referenced this pull request Jun 18, 2025
* Add initial code for KafkaJson and KafkaAvro request handlers.

* Add deserialization via @Deserialization annotation.

* Add TODOs in code.

* Fix typos and make AbstractKafkaDeserializer package private.

* Remove request handler implementation in favor for @Deserialization annotation.

* Parse Timestamp type correctly.

* Remove custom RequestHandler implementation example.

* Make AspectJ version compatible with min version Java 11.

* Clarify exception message when deserialization fails.

* Add more advanced JSON escpaing to JSONSerializer in logging module.

* Add protobuf deserialization logic and fully working example.

* Add Maven profile to compile a JAR with different dependency combinations.

* Add minimal kafka example.

* Add missing copyright.

* Add unit tests for kafka utility.

* Add minimal kafka example to examples module in pom.xml.

* Add some comments.

* Update powertools-examples-kafka with README and make it more minimalistic. Remove powertools-examples-kafka-minimal.

* Implement PR feedback from Karthik.

* Fix SAM outputs.

* Do not fail on unknown properties when deserializating into KafkaEvent.

* Allow customers to bring their own kafka-clients dependency.

* Add Kafka utility documentation.

* Update project version consistently to 2.0.0.

* fix: Fix bug where abbreviated _HANDLER env var did not detect the Deserialization annotation.

* fix: Bug when trying to deserialize a type into itself for Lambda default behavior. We can just return the type itself. Relevant for simple String and InputStream handlers.

* When falling back to Lambda default, handle conversion between InputStream and String.

* Raise a runtime exception when the KafkaEvent is invalid.

* docs: Announce deprecation of v1

* fix(metrics): Do not flush when no metrics were added to avoid printing root-level _aws dict (#1891)

* fix(metrics): Do not flush when no metrics were added to avoid printing root-level _aws dict.

* Fix pmd linting failures.

* Rename docs to Kafka Consumer and add line highlights for code examples.

* Fix Spotbug issues.

* Reduce cognitive complexity of DeserializationUtils making it more modular and representing handler information in a simple HandlerInfo class.

* Reduce cognitive complexity of AbstractKafkaDeserializer.

* Enable removal policy DESTROY on e2e test for kinesis streams and SQS queues to avoid exceeding account limit.

* Replace System.out with Powertools Logging.

* Add notice about kafka-clients compatibility.

* Add sentence stating that Avro / Protobuf classes can be autogenerated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working metrics size/S
Projects
Status: Coming soon
Development

Successfully merging this pull request may close these issues.

Bug: EMF Metrics Logger emits root dict without metrics when no metrics are added
2 participants