Bring back TraceID and SpanID fields in access logs
Co-authored-by: Kevin Pollet <pollet.kevin@gmail.com>
This commit is contained in:
parent
020ab5f347
commit
4ce4bd7121
4 changed files with 18 additions and 32 deletions
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/traefik/traefik/v3/pkg/types"
|
||||
"go.opentelemetry.io/collector/pdata/plog/plogotlp"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.opentelemetry.io/otel/trace/noop"
|
||||
)
|
||||
|
||||
const delta float64 = 1e-10
|
||||
|
@ -409,6 +410,8 @@ func TestLoggerJSON(t *testing.T) {
|
|||
"time": assertNotEmpty(),
|
||||
"StartLocal": assertNotEmpty(),
|
||||
"StartUTC": assertNotEmpty(),
|
||||
TraceID: assertNotEmpty(),
|
||||
SpanID: assertNotEmpty(),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -452,6 +455,8 @@ func TestLoggerJSON(t *testing.T) {
|
|||
"time": assertNotEmpty(),
|
||||
StartLocal: assertNotEmpty(),
|
||||
StartUTC: assertNotEmpty(),
|
||||
TraceID: assertNotEmpty(),
|
||||
SpanID: assertNotEmpty(),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -627,6 +632,8 @@ func TestLogger_AbortedRequest(t *testing.T) {
|
|||
"downstream_Content-Type": assertString("text/plain"),
|
||||
"downstream_Transfer-Encoding": assertString("chunked"),
|
||||
"downstream_Cache-Control": assertString("no-cache"),
|
||||
TraceID: assertNotEmpty(),
|
||||
SpanID: assertNotEmpty(),
|
||||
}
|
||||
|
||||
config := &types.AccessLog{
|
||||
|
@ -945,6 +952,10 @@ func doLoggingTLSOpt(t *testing.T, config *types.AccessLog, enableTLS bool) {
|
|||
}
|
||||
}
|
||||
|
||||
tracer := noop.Tracer{}
|
||||
spanCtx, _ := tracer.Start(req.Context(), "test")
|
||||
req = req.WithContext(spanCtx)
|
||||
|
||||
chain := alice.New()
|
||||
chain = chain.Append(capture.Wrap)
|
||||
chain = chain.Append(WrapHandler(logger))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue