AsperforMias opened a new issue, #3852:
URL: https://github.com/apache/dubbo-go/issues/3852

   ### What problem would this solve?
   
   Dubbo Admin's log pages search logs by Trace ID, and `CtxLogger` already 
adds `trace_id`, `span_id` and `trace_flags` to logs when 
`logger.trace-integration.enabled` is on. But only business code that calls 
`CtxLogger` benefits. The framework's own logs never carry a trace ID, so the 
lines that explain a failed request cannot be found from its trace:
   
   - Every framework log call goes through the context-free `logger.Xxxf`. 
Request-path logs in filters and cluster invokers (rate limiting and execute 
limit rejections, auth failures, generic invocation errors, graceful shutdown 
rejections, failover/failback/forking retries, ...) have `ctx` at hand but do 
not pass it.
   - Access log lines carry no trace ID.
   - On the provider side the OpenTelemetry server filter is appended to the 
end of the filter chain, so every provider filter (access log, TPS limit, 
execute limit, generic service, graceful shutdown) runs before the server span 
exists. Even with `ctx`, those filters cannot see a trace. Dubbo Java orders 
`ObservationReceiverFilter` first (`Integer.MIN_VALUE + 50`).
   - `CtxLogger` is only returned when trace integration is on, so framework 
code cannot call `Ctx*` methods unconditionally, and there is no accessor for 
it.
   
   Part of #3562 (Workstream 2, structured logging).
   
   ### Proposed solution (optional)
   
   1. The zap and logrus loggers always implement `CtxLogger`; 
`logger.trace-integration.enabled` only decides whether trace fields are added 
(and errors recorded to the span). With the switch off, output is unchanged.
   2. Add `logger.GetCtxLogger()`, which returns the global logger as a 
`CtxLogger`. Custom loggers that do not implement it are adapted, and `Ctx*` 
falls back to the plain method.
   3. Switch request-path logs in filters and cluster invokers to `CtxLogger` 
with the request `ctx`.
   4. Append `trace_id=... span_id=...` to access log lines when the request 
has a span. Admin's log dashboards already extract `trace_id` from the line.
   5. Put the OpenTelemetry server filter first in the provider filter chain, 
as Dubbo Java does, so provider filters run inside the server span.
   
   The consumer filter chain order is not changed. Cluster invoker logs carry 
the caller's trace when the caller's `ctx` has a span, for example when a 
provider calls a downstream service while handling a request.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to