From f58f91482662b9755b2ba1416aae333befe69ba2 Mon Sep 17 00:00:00 2001 From: Ge Song Date: Wed, 12 Apr 2023 17:29:19 +0800 Subject: [PATCH] =?UTF-8?q?log/=E5=8D=87=E7=BA=A7=E5=AF=B9log=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/http-reflect-server/go.mod | 7 +------ cmd/http-reflect-server/go.sum | 8 ++------ logotel/go.mod | 5 +---- logotel/go.sum | 8 ++------ logotel/option.go | 14 ++++++++------ logotel/processor.go | 8 ++++---- 6 files changed, 18 insertions(+), 32 deletions(-) diff --git a/cmd/http-reflect-server/go.mod b/cmd/http-reflect-server/go.mod index 4913589..d172a7b 100644 --- a/cmd/http-reflect-server/go.mod +++ b/cmd/http-reflect-server/go.mod @@ -4,10 +4,5 @@ go 1.20 require ( git.blauwelle.com/go/crate/exegroup v0.3.0 - git.blauwelle.com/go/crate/log v0.4.0 -) - -require ( - git.blauwelle.com/go/crate/runtimehelper v0.1.0 // indirect - git.blauwelle.com/go/crate/synchelper v0.1.0 // indirect + git.blauwelle.com/go/crate/log v0.6.0 ) diff --git a/cmd/http-reflect-server/go.sum b/cmd/http-reflect-server/go.sum index c04048f..e538182 100644 --- a/cmd/http-reflect-server/go.sum +++ b/cmd/http-reflect-server/go.sum @@ -1,8 +1,4 @@ git.blauwelle.com/go/crate/exegroup v0.3.0 h1:TBLygDztECKc67NeIIBsFDxlA4KcJpbOmafqqRuKRcM= git.blauwelle.com/go/crate/exegroup v0.3.0/go.mod h1:DJoID54YI5WFHGHoTCjBao8oS3HFRzwbWMZW6P57AIQ= -git.blauwelle.com/go/crate/log v0.4.0 h1:wK/qwO+a2YE51F6LdC9pZXL2AIARCRW0+AvFIF2Txt8= -git.blauwelle.com/go/crate/log v0.4.0/go.mod h1:NfiG7YKQCTnLIcn6fVkaa2qEu+DuYi1Kz783Sc/F3jI= -git.blauwelle.com/go/crate/runtimehelper v0.1.0 h1:qNhtnt9YmHXNHKsGRbwD3AZ3pezpOwrbmX1o9Bz532I= -git.blauwelle.com/go/crate/runtimehelper v0.1.0/go.mod h1:yVMA0GkO9AS7iuPmalHKeWyv9en0JWj25rY1vpTuHhk= -git.blauwelle.com/go/crate/synchelper v0.1.0 h1:4yEXpshkklaws/57P94xN5bA3NmyyKGcZqYmzd6QIK4= -git.blauwelle.com/go/crate/synchelper v0.1.0/go.mod h1:2JkfH+7sF0Q0wiIaDOqG42ZLO5JxpcMfSoyy7db4Y2g= +git.blauwelle.com/go/crate/log v0.6.0 h1:s/TeJUaV/Y8hHaz/3FumdbwQWCbRMmOx8prrNmByJHs= +git.blauwelle.com/go/crate/log v0.6.0/go.mod h1:jfVfpRODZTA70A8IkApVeGsS1zfLk1D77sLWZM/w+L0= diff --git a/logotel/go.mod b/logotel/go.mod index bd442fd..f04e500 100644 --- a/logotel/go.mod +++ b/logotel/go.mod @@ -3,10 +3,7 @@ module git.blauwelle.com/go/crate/logotel go 1.20 require ( - git.blauwelle.com/go/crate/log v0.3.0 - git.blauwelle.com/go/crate/synchelper v0.1.0 + git.blauwelle.com/go/crate/log v0.6.0 go.opentelemetry.io/otel v1.13.0 go.opentelemetry.io/otel/trace v1.13.0 ) - -require git.blauwelle.com/go/crate/runtimehelper v0.1.0 // indirect diff --git a/logotel/go.sum b/logotel/go.sum index 5d404b7..b9c173f 100644 --- a/logotel/go.sum +++ b/logotel/go.sum @@ -1,9 +1,5 @@ -git.blauwelle.com/go/crate/log v0.3.0 h1:oLXMAShuPFQgHc5fNjWU3kcESaS8lpS88P2t5G2b2yA= -git.blauwelle.com/go/crate/log v0.3.0/go.mod h1:NfiG7YKQCTnLIcn6fVkaa2qEu+DuYi1Kz783Sc/F3jI= -git.blauwelle.com/go/crate/runtimehelper v0.1.0 h1:qNhtnt9YmHXNHKsGRbwD3AZ3pezpOwrbmX1o9Bz532I= -git.blauwelle.com/go/crate/runtimehelper v0.1.0/go.mod h1:yVMA0GkO9AS7iuPmalHKeWyv9en0JWj25rY1vpTuHhk= -git.blauwelle.com/go/crate/synchelper v0.1.0 h1:4yEXpshkklaws/57P94xN5bA3NmyyKGcZqYmzd6QIK4= -git.blauwelle.com/go/crate/synchelper v0.1.0/go.mod h1:2JkfH+7sF0Q0wiIaDOqG42ZLO5JxpcMfSoyy7db4Y2g= +git.blauwelle.com/go/crate/log v0.6.0 h1:s/TeJUaV/Y8hHaz/3FumdbwQWCbRMmOx8prrNmByJHs= +git.blauwelle.com/go/crate/log v0.6.0/go.mod h1:jfVfpRODZTA70A8IkApVeGsS1zfLk1D77sLWZM/w+L0= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/logotel/option.go b/logotel/option.go index fbaf05d..b7de4c0 100644 --- a/logotel/option.go +++ b/logotel/option.go @@ -1,6 +1,8 @@ package logotel -import "git.blauwelle.com/go/crate/synchelper" +import ( + "git.blauwelle.com/go/crate/log/logsdk/logjson" +) func newConfig(opts ...Option) *config { cfg := defaultConfig() @@ -8,7 +10,7 @@ func newConfig(opts ...Option) *config { opt.apply(cfg) } if !cfg.hasPool { - cfg.bufferPool = synchelper.NewBytesBufferPool(512, 4096) + cfg.bytesBufferPool = logjson.NewBytesBufferPool(512, 4096) } return cfg } @@ -20,9 +22,9 @@ func defaultConfig() *config { } // WithBufferPool 指定缓冲池 -func WithBufferPool(pool synchelper.BytesBufferPool) Option { +func WithBufferPool(pool logjson.BytesBufferPool) Option { return optionFunc(func(cfg *config) { - cfg.bufferPool = pool + cfg.bytesBufferPool = pool cfg.hasPool = true }) } @@ -33,8 +35,8 @@ type Option interface { } type config struct { - bufferPool synchelper.BytesBufferPool - hasPool bool + bytesBufferPool logjson.BytesBufferPool + hasPool bool } type optionFunc func(cfg *config) diff --git a/logotel/processor.go b/logotel/processor.go index 0ab9785..09f4193 100644 --- a/logotel/processor.go +++ b/logotel/processor.go @@ -7,7 +7,7 @@ import ( "strconv" "git.blauwelle.com/go/crate/log/logsdk" - "git.blauwelle.com/go/crate/synchelper" + "git.blauwelle.com/go/crate/log/logsdk/logjson" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" semconv "go.opentelemetry.io/otel/semconv/v1.17.0" @@ -18,7 +18,7 @@ import ( func New(opts ...Option) *Processor { cfg := newConfig(opts...) return &Processor{ - bufferPool: cfg.bufferPool, + bufferPool: cfg.bytesBufferPool, } } @@ -26,7 +26,7 @@ var _ logsdk.EntryProcessor = &Processor{} // Processor 用于把日志和 opentelemetry 对接 type Processor struct { - bufferPool synchelper.BytesBufferPool + bufferPool logjson.BytesBufferPool } func (processor *Processor) Process(entry logsdk.ReadonlyEntry) { @@ -66,7 +66,7 @@ func (processor *Processor) Process(entry logsdk.ReadonlyEntry) { } } -func fieldToKV(field logsdk.Field) attribute.KeyValue { +func fieldToKV(field logsdk.KV) attribute.KeyValue { switch value := field.Value.(type) { case nil: return attribute.String(field.Key, "")