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

fix(log): WithContext() changed the ctx field of the parent log.Filter #3069

Merged
merged 4 commits into from
Nov 22, 2023

Conversation

ionling
Copy link
Contributor

@ionling ionling commented Nov 6, 2023

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

Fix the concurrent problem of log.WithContext() function.

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

Fix #3061

Other special notes for the reviewers:

@shenqidebaozi
Copy link
Member

Do we need to determine if f.ctx=ctx when f.ctx=nil? Can we also supplement UT to prove that the modifications have solved the problem and are compatible forward and backward

@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1e4e37a) 84.32% compared to head (44795c6) 84.33%.

❗ Current head 44795c6 differs from pull request most recent head cfa9fb8. Consider uploading reports for the commit cfa9fb8 to get more accurate results

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3069      +/-   ##
==========================================
+ Coverage   84.32%   84.33%   +0.01%     
==========================================
  Files          88       88              
  Lines        3993     3984       -9     
==========================================
- Hits         3367     3360       -7     
  Misses        449      449              
+ Partials      177      175       -2     

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

@ionling
Copy link
Contributor Author

ionling commented Nov 8, 2023

I have added a UT for this.

About f.ctx=ctx when f.ctx=nil, I think setting a default value is a better solution.
As for backwards compatibility, I think it's a breakable change if there's any code that relies on it.

@shenqidebaozi
Copy link
Member

The submitted fix appears to have data race issues

@ionling
Copy link
Contributor Author

ionling commented Nov 10, 2023

The data race problem was introduced by #2869.
I fixed it using a simpler solution.

@shenqidebaozi shenqidebaozi merged commit ff105d5 into go-kratos:main Nov 22, 2023
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The trace_id between requests is getting mixed up
4 participants