-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: advanced logging #1539
feat: advanced logging #1539
Conversation
💾 Artifacts Size Report
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## v2 #1539 +/- ##
=====================================
Coverage ? 78.32%
Complexity ? 593
=====================================
Files ? 66
Lines ? 2265
Branches ? 319
=====================================
Hits ? 1774
Misses ? 373
Partials ? 118 ☔ View full report in Codecov by Sentry. |
}; | ||
|
||
private final EventResolver internalResolver; | ||
|
||
private static final Map<String, EventResolver> eventResolverMap = Stream.of(new Object[][] { | ||
private static final Map<String, EventResolver> eventResolverMap = Collections.unmodifiableMap(Stream.of(new Object[][] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move to Java 11 to declare this more easily... ? :(
powertools-logging/src/main/java/software/amazon/lambda/powertools/logging/LoggingUtils.java
Outdated
Show resolved
Hide resolved
...ng/src/main/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspect.java
Show resolved
Hide resolved
...ng/src/main/java/software/amazon/lambda/powertools/logging/internal/LambdaLoggingAspect.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial feedback - I believe the approach makes sense and represents an improvement to the UX. I would love to review the whole thing once you've done the docs too.
powertools-logging/src/main/java/software/amazon/lambda/powertools/logging/LoggingUtils.java
Outdated
Show resolved
Hide resolved
...-logging/src/main/java/software/amazon/lambda/powertools/logging/argument/ArrayArgument.java
Show resolved
Hide resolved
...s-logging/src/main/java/software/amazon/lambda/powertools/logging/argument/JsonArgument.java
Show resolved
Hide resolved
...logging/src/main/java/software/amazon/lambda/powertools/logging/internal/JsonSerializer.java
Outdated
Show resolved
Hide resolved
...ng/src/main/java/software/amazon/lambda/powertools/logging/argument/StructuredArguments.java
Show resolved
Hide resolved
...est/java/software/amazon/lambda/powertools/logging/internal/handler/PowertoolsArguments.java
Outdated
Show resolved
Hide resolved
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 5 New issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some doc feedback
@@ -563,35 +444,35 @@ we provide [built-in JMESPath expressions](#built-in-correlation-id-expressions) | |||
|
|||
#### Custom keys | |||
|
|||
???+ warning "Custom keys are persisted across warm invocations" | |||
Always set additional keys as part of your handler method to ensure they have the latest value, or explicitly clear them with [`clearState=true`](#clearing-state). | |||
** Using StructuredArguments ** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Appending Additional Keys" ? So that the heading reflects when you can learn to do, not a detail of how to do it
|
||
** Using MDC ** | ||
|
||
Mapped Diagnostic Context (MDC) is essentially a Key-Value store. It is supported by the [SLF4J API](https://www.slf4j.org/manual.html#mdc){target="_blank"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key-value, no need to capitalise
|
||
### Removing additional keys | ||
|
||
You can remove additional keys added with the MDC using `MDC.remove("key")`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Typically, you'd remove additional keys at the end of your request handler, so they do not apply to subsequent requests"
|
||
### Removing additional keys | ||
|
||
You can remove additional keys added with the MDC using `MDC.remove("key")`. | ||
|
||
#### Clearing state | ||
|
||
Logger is commonly initialized in the global scope. Due to [Lambda Execution Context reuse](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html){target="_blank"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logger is
|
||
#### Clearing state | ||
|
||
Logger is commonly initialized in the global scope. Due to [Lambda Execution Context reuse](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html){target="_blank"}, | ||
this means that custom keys can be persisted across invocations. If you want all custom keys to be deleted, you can use | ||
this means that custom keys, added with the MDC can be persisted across invocations. If you want all custom keys to be deleted, you can use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capitalisation "This"
@@ -1071,33 +1005,6 @@ If you need to customize format and timezone, you can change use the following: | |||
</encoder> | |||
``` | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more custom object mapper?
Quality Gate passedIssues Measures |
🎉 |
Issue #, if available: #965 #1508
Description of changes:
MDC
: I removed theLoggingUtils.appendKey
to use the standard MDCStructuredArguments
: I've introduced this as suggested in RFC: Switch to logback, SLF4J and logstash as logging framework #965 by @roamingthings. But I did not introduce the library. I've created something similar but lighter in Powertools. Structured arguments can be any kind of object, JSON, ... and will be logged as such.Checklist
Breaking change checklist
Breaking change on the Jackson ObjectMapper that now comes with default config (ignore null fields)
RFC issue #:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.