Skip to content
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(log): Prevent log.Helper sprintf from running early #3209 #3221

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

sendya
Copy link
Contributor

@sendya sendya commented Mar 4, 2024

Description (what this PR does / why we need it):

log 在在开发中会使用很多 Debug / Debugf 日志,在生产服务中可能会配置为 Info 级以上
但 log.Helper 函数中会在进入

h.logger.Log(LevelDebug, h.msgKey, h.sprintf...  )

提前运行了 fmt.Sprintfmt.Sprintf 在较高并发的情况下,带来了非常高的字符串拼接耗损。

307262318-7376dd08-d8c9-4ee0-be41-dba6e2ea4901

Which issue(s) this PR fixes (resolves / be part of):

fixes/resolves #3209

Other special notes for the reviewers:

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 4, 2024
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 84.45%. Comparing base (50cad79) to head (38452dc).

❗ Current head 38452dc differs from pull request most recent head 8a92d3a. Consider uploading reports for the commit 8a92d3a to get more accurate results

Files Patch % Lines
log/helper.go 40.00% 6 Missing and 6 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3221      +/-   ##
==========================================
- Coverage   84.72%   84.45%   -0.28%     
==========================================
  Files          88       88              
  Lines        3993     4013      +20     
==========================================
+ Hits         3383     3389       +6     
- Misses        438      446       +8     
- Partials      172      178       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dosubot dosubot bot added the LGTM label Mar 11, 2024
@daemon365 daemon365 merged commit d4edd44 into go-kratos:main Mar 15, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LGTM size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] log Helper sprint, sprintf is executed before Filter Level, the performance consumption is very high
5 participants