Add propertiesSupplier support to EmfMetricLoggingPublisher#6735
Open
humanzz wants to merge 1 commit intoaws:masterfrom
Open
Add propertiesSupplier support to EmfMetricLoggingPublisher#6735humanzz wants to merge 1 commit intoaws:masterfrom
humanzz wants to merge 1 commit intoaws:masterfrom
Conversation
Enable `EmfMetricLoggingPublisher` to accept an optional `Supplier<Map<String, String>>` for enriching EMF records with custom properties at publish time - Add `propertiesSupplier` field and builder method to `EmfMetricLoggingPublisher.Builder` - Add `propertiesSupplier` field, accessor, and builder setter to `EmfMetricConfiguration`, defaulting to empty map when null - Add `resolveProperties()` to `MetricEmfConverter` which invokes the supplier from config once per convert call, handling null returns and exceptions gracefully - Add `writeCustomProperties()` to `MetricEmfConverter` which writes properties first in the EMF JSON so `_aws`, dimensions, and metrics overwrite any key collisions Closes aws#6595
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6595
Enable
EmfMetricLoggingPublisherto accept an optionalSupplier<Map<String, String>>for enriching EMF records with custom properties at publish time.Motivation and Context
Users of
EmfMetricLoggingPublisherhave no way to add custom metadata (e.g. Lambda request IDs, trace IDs) to EMF records. The aws-embedded-metrics-java library supports this viaputProperty(), but the SDK's built-in publisher does not. This change adds apropertiesSupplierto the builder, evaluated on eachpublish()call, allowing dynamic enrichment of EMF output with searchable properties in CloudWatch Logs Insights.Modifications
propertiesSupplierfield and builder method toEmfMetricLoggingPublisher.BuilderpropertiesSupplierfield, accessor, and builder setter toEmfMetricConfiguration, defaulting to empty map when nullresolveProperties()toMetricEmfConverterwhich invokes the supplier from config once per convert call, handling null returns and exceptions gracefullywriteCustomProperties()toMetricEmfConverterwhich writes properties first in the EMF JSON so_aws, dimensions, and metrics overwrite any key collisionsTesting
Added 7 tests to
MetricEmfConverterTest:_awsis overwritten by the real_awsobjectAdded 3 tests to
EmfMetricLoggingPublisherTest:All 26 tests pass.
mvn clean install -pl :emf-metric-logging-publishersucceeds (compile, checkstyle, tests, javadoc, API compatibility).Screenshots (if appropriate)
N/A
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License