-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Structured logging with ClientLogger #25247
Conversation
API changes have been detected in |
1 similar comment
API changes have been detected in |
8307552
to
a098062
Compare
API changes have been detected in |
a098062
to
e705725
Compare
API changes have been detected in |
With this change we now support 2 ways to log (Fluent vs non-fluent) - should we long term consolidate to only one style? |
It's possible we could do this, but in terms of backwards compatibility, I wouldn't worry too much. This is exactly the pattern SLF4J is taking in its 2.0.0 release. |
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.
Looking really promising!
sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
Show resolved
Hide resolved
sdk/core/azure-core/src/main/java/com/azure/core/util/logging/LoggingEventBuilder.java
Show resolved
Hide resolved
I meant should we think of only exposing Fluent way of doing things moving forward (whenever we think it is the right time) ? I understand our ecosystem supports multiple ways of doing the same thing but shouldn't our SDKs have a single way of doing everything. |
@lmolkova this is pretty cool. I love how you are adding benchmarks to the PRs. |
Fluent way is a bit less performant (you have to allocate the builder), a bit more verbose ( |
c48d9c3
to
6a2d3df
Compare
a19ceda
to
00d00b3
Compare
sdk/core/azure-core/src/main/java/com/azure/core/implementation/logging/LoggingUtil.java
Outdated
Show resolved
Hide resolved
sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
Outdated
Show resolved
Hide resolved
sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
Outdated
Show resolved
Hide resolved
sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
Outdated
Show resolved
Hide resolved
sdk/core/azure-core/src/main/java/com/azure/core/util/logging/LoggingEventBuilder.java
Show resolved
Hide resolved
00d00b3
to
fc7aa8f
Compare
Fresh benchmark, ~same results
|
Description: https://gist.github.com/lmolkova/04f6484595fdd7edded9f4d82619291f
Inspired by SLF4J v2 API
Usage
Outcome:
2021-11-08 15:04:42.407 [ForkJoinPool-1-worker-3] [WARN] com.azure.core.util.logging.ClientLoggerTests - hello, argument = 1, az.sdk.context={"connectionId":"foo", "linkName":"bar"}
Micro-benchmarks:
Fluent pattern (
loggingAtEnabledLevelWithContext
) vs explicit context (loggingAtEnabledLevelWithContext2
) don't show significant difference in perf: