AsperforMias opened a new pull request, #3853:
URL: https://github.com/apache/dubbo-go/pull/3853

   ### Description
   Fixes #3852
   
   Dubbo Admin's log pages search logs by Trace ID, but only business code that 
logs through `CtxLogger` carried one. The framework's own logs never did, so 
the lines that explain a rejected or failed request could not be found from its 
trace.
   
   Changes:
   
   - **Loggers**: the zap and logrus loggers always implement `CtxLogger`. 
`logger.trace-integration.enabled` now only decides whether trace fields are 
added and errors recorded to the span; with it off, output is unchanged. 
`NewZapCtxLogger` / `NewLogrusCtxLogger` keep their behavior.
   - **API**: add `logger.GetCtxLogger()` and package-level 
`logger.CtxDebugf/CtxInfof/CtxWarnf/CtxErrorf` (and the non-f variants). Call 
sites read `dubboLogger.CtxWarnf(ctx, ...)`, parallel to `logger.Warnf(...)`. 
The package functions log through `ZapCtxLogger.CallerSkipped()`, so zap still 
reports the call site rather than the logger package. A custom logger without 
`Ctx*` methods is adapted, and the context is dropped.
   - **Call sites**: 28 request-path logs in filters (access log, active, auth, 
execute limit, generic, graceful shutdown, seata, TPS) and cluster invokers 
(adaptive service, broadcast, failback, failover, failsafe) now pass the 
request `ctx`. Logs in background goroutines without a request are unchanged.
   - **Access log**: lines end with `trace_id=... span_id=...` when the request 
has a span. Admin's log dashboards already extract `trace_id` from the line.
   - **Provider filter order**: the OpenTelemetry server filter was appended to 
the end of the provider chain, so every other provider filter ran before the 
server span existed. It now runs first, as `ObservationReceiverFilter` does in 
Dubbo Java. The server span therefore also covers the provider filters, and 
requests rejected by a filter get a server span. The consumer chain order is 
not changed.
   
   Verified with a Triple provider (trace integration on, access log on, 
`execute.limit=1`) and a consumer sending concurrent requests, both exporting 
spans to stdout:
   
   - execute limit rejection logs and access log lines carry `trace_id`, 
matching the server span and the consumer's span of the same request
   - before this change neither carried a trace ID, since both filters ran 
before the server span
   
   Tests check the reported caller for the package functions, the `CtxLogger` 
methods and the plain gost functions, with trace integration on and off; they 
fail if the package functions skip `CallerSkipped`.
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] I have run `make fmt` to format my code
   - [x] I have run `make test` to run local tests
   - [x] I have added tests that prove my fix is effective or that my feature 
works
   


-- 
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