kratos
kratos copied to clipboard
fix: Logging middleware will be missing trace_id when logger is filterlogger
Description (what this PR does / why we need it):
修复启用链路追逐后log中间件使用logfilter后,打印的请求日志中缺失trace.id值,如下
INFO ts=2022-12-08T15:46:40+08:00 caller=log/log.go:30 trace.id= kind=server component=grpc operation=/video.basics.v1.notification.NotificationSrv/GetNotification args=webmaster_id:1595665043859443712 limit:20 code=0 reason= stack= latency=0.000850499
Which issue(s) this PR fixes (resolves / be part of):
fix/logfilter #2570
Other special notes for the reviewers:
应该在log.WithContext()方法中进一步断言logger类型,并取出初始logger的prefix
Codecov Report
Merging #2571 (dc60dfd) into main (33d51a8) will decrease coverage by
0.02%
. The diff coverage is60.00%
.
@@ Coverage Diff @@
## main #2571 +/- ##
==========================================
- Coverage 85.18% 85.15% -0.03%
==========================================
Files 88 88
Lines 3840 3846 +6
==========================================
+ Hits 3271 3275 +4
- Misses 396 397 +1
- Partials 173 174 +1
Impacted Files | Coverage Δ | |
---|---|---|
log/log.go | 88.57% <60.00%> (-4.77%) |
:arrow_down: |
transport/http/codec.go | 60.37% <0.00%> (+0.76%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
@Cynicism-zx please fix lint failed
@shenqidebaozi fixed
@Cynicism-zx @shenqidebaozi Could you please comment?
don't simple to using origin logger, It will cause the Filter not working.