From 3f9d18980623effde6afc608662c9cc21974f6bc Mon Sep 17 00:00:00 2001 From: Ge Song Date: Fri, 5 Jan 2024 17:12:28 +0800 Subject: [PATCH] logotel/optimize default span for logs; --- logotel/go.mod | 5 +++++ logotel/go.sum | 5 +++++ logotel/processor.go | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/logotel/go.mod b/logotel/go.mod index 432754c..1146822 100644 --- a/logotel/go.mod +++ b/logotel/go.mod @@ -7,3 +7,8 @@ require ( go.opentelemetry.io/otel v1.13.0 go.opentelemetry.io/otel/trace v1.13.0 ) + +require ( + github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect +) diff --git a/logotel/go.sum b/logotel/go.sum index 6f418a7..19b82ec 100644 --- a/logotel/go.sum +++ b/logotel/go.sum @@ -1,6 +1,11 @@ git.blauwelle.com/go/crate/log v0.9.0 h1:H01AQIKcYybeCZGdReBzMoWhkXPQJAoY1t+K0J1asEk= git.blauwelle.com/go/crate/log v0.9.0/go.mod h1:jfVfpRODZTA70A8IkApVeGsS1zfLk1D77sLWZM/w+L0= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= diff --git a/logotel/processor.go b/logotel/processor.go index 3dec5ce..27fc66b 100644 --- a/logotel/processor.go +++ b/logotel/processor.go @@ -37,7 +37,11 @@ func (processor *Processor) Process(ctx context.Context, entry logsdk.ReadonlyEn span := trace.SpanFromContext(ctx) if !span.IsRecording() { if processor.defaultSpan { - ctx, span = otel.Tracer("git.blauwelle.com/go/crate/logotel").Start(ctx, "default") //nolint:ineffassign,staticcheck,wastedassign + name := entry.Message + if name == "" { + name = "default" + } + ctx, span = otel.Tracer("git.blauwelle.com/go/crate/logotel").Start(ctx, name) //nolint:ineffassign,staticcheck,wastedassign defer span.End() } }