go-zero
go-zero copied to clipboard
When using otel, the logc print log will be deformed
Describe the bug My service uses otel. When printing logs through logc, the log format is deformed. I understand that traceid and spanid should be inside json, not in the outer layer.
-
The code is
logc.Infow(context.Background(), "CallBack request successfully.", logc.Field("reqId", params.Spec.ReqId)) -
The error is
trace_id=dfac27371ea9966e8da25340b5924dc7 span_id=6fe11f97dfa23e52{"@timestamp":"2025-08-26T13:49:09.815+08:00","caller":"task/task.go:88","content":"CallBack request successfully.","level":"info","reqId":"1960191682599202817","span":"6fe11f97dfa23e52","trace":"dfac27371ea9966e8da25340b5924dc7"}
Expected behavior
{"@timestamp":"2025-08-26T13:49:09.815+08:00","caller":"task/task.go:88","content":"CallBack request successfully.","level":"info","reqId":"1960191682599202817","span":"6fe11f97dfa23e52","trace":"dfac27371ea9966e8da25340b5924dc7"}
Environments (please complete the following information):
- OS: Ubuntu
- go-zero version:v1.7.3
- goctl version:1.23.0
More description Add any other context about the problem here.
Try the latest version please. It's fixed long time ago.
Try the latest version please. It's fixed long time ago.
The latest version 1.9.0, the log format problem still exists