Avoid expensive log.Valuer evaluation for disallowed level#5297
Merged
alvinlin123 merged 2 commits intocortexproject:masterfrom May 10, 2023
Merged
Avoid expensive log.Valuer evaluation for disallowed level#5297alvinlin123 merged 2 commits intocortexproject:masterfrom
alvinlin123 merged 2 commits intocortexproject:masterfrom
Conversation
a77c82f to
95975ad
Compare
2 tasks
19b2fbc to
f6cfaea
Compare
alanprot
reviewed
May 3, 2023
| @@ -72,24 +69,32 @@ type PrometheusLogger struct { | |||
| // NewPrometheusLogger creates a new instance of PrometheusLogger which exposes | |||
| // Prometheus counters for various log levels. | |||
| func NewPrometheusLogger(l logging.Level, format logging.Format) (log.Logger, error) { | |||
Member
There was a problem hiding this comment.
This is not being used anymore?
Contributor
Author
There was a problem hiding this comment.
This is used by other packages.
Member
|
Can you explain what is the functional change here? are we missing/changing something? |
Contributor
Author
|
@alanprot I agree, the change is simple but not easy to understand, the old code is like this: the new code is like this: the order matters since the logger2.Log does level filtering first then call the logger1.Log on demand, the logger1.Log evaluates the log.Valuer such as log.Caller.. I have add the reference link in the comments: go-kit/log#14 (comment) |
Signed-off-by: Xiaochao Dong (@damnever) <the.xcdong@gmail.com>
Member
|
NIce! Ok.. |
alanprot
approved these changes
May 9, 2023
alanprot
approved these changes
May 9, 2023
Signed-off-by: Xiaochao Dong <the.xcdong@gmail.com>
alvinlin123
approved these changes
May 10, 2023
Contributor
alvinlin123
left a comment
There was a problem hiding this comment.
This is an awesome enhancement, thank you so much!
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.
A lot of failed operations in memcach_client.SetAsync will consume a lot of CPU:

Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]