Vasiliy Tolstov
79438f11e0
All checks were successful
/ autoupdate (push) Successful in 1m13s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
29 lines
606 B
Go
29 lines
606 B
Go
package tracer_test
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"go.unistack.org/micro/v4/logger"
|
|
"go.unistack.org/micro/v4/logger/slog"
|
|
"go.unistack.org/micro/v4/tracer"
|
|
)
|
|
|
|
func TestLoggerWithTracer(t *testing.T) {
|
|
ctx := context.TODO()
|
|
buf := bytes.NewBuffer(nil)
|
|
logger.DefaultLogger = slog.NewLogger(logger.WithOutput(buf))
|
|
|
|
if err := logger.Init(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var span tracer.Span
|
|
ctx, span = tracer.DefaultTracer.Start(ctx, "test")
|
|
logger.Info(ctx, "msg")
|
|
if !strings.Contains(buf.String(), span.TraceID()) {
|
|
t.Fatalf("log does not contains tracer id")
|
|
}
|
|
}
|