1
0
mirror of https://github.com/go-kratos/kratos.git synced 2026-05-22 10:15:24 +02:00

middleware/logging client add traceid (#878)

This commit is contained in:
包子
2021-04-28 16:23:55 +08:00
committed by GitHub
parent 8dc92ef8b4
commit f33bd70d75
+7 -1
View File
@@ -101,10 +101,12 @@ func Client(l log.Logger) middleware.Middleware {
var (
path string
method string
component string
args string
component string
query string
traceID string
)
traceID = trace.SpanContextFromContext(ctx).TraceID().String()
if info, ok := http.FromClientContext(ctx); ok {
component = "HTTP"
path = info.Request.URL.Path
@@ -123,6 +125,7 @@ func Client(l log.Logger) middleware.Middleware {
logger.Errorw(
"kind", "client",
"component", component,
"traceID", traceID,
"path", path,
"method", method,
"args", args,
@@ -135,6 +138,7 @@ func Client(l log.Logger) middleware.Middleware {
logger.Infow(
"kind", "client",
"component", component,
"traceID", traceID,
"path", path,
"method", method,
"args", args,
@@ -146,6 +150,7 @@ func Client(l log.Logger) middleware.Middleware {
logger.Errorw(
"kind", "client",
"component", component,
"traceID", traceID,
"path", path,
"method", method,
"args", args,
@@ -157,6 +162,7 @@ func Client(l log.Logger) middleware.Middleware {
logger.Infow(
"kind", "client",
"component", component,
"traceID", traceID,
"path", path,
"method", method,
"args", args,