log/升级对log的依赖;

develop
Ge Song 2 years ago
parent f21f93b713
commit f58f914826

@ -4,10 +4,5 @@ go 1.20
require ( require (
git.blauwelle.com/go/crate/exegroup v0.3.0 git.blauwelle.com/go/crate/exegroup v0.3.0
git.blauwelle.com/go/crate/log v0.4.0 git.blauwelle.com/go/crate/log v0.6.0
)
require (
git.blauwelle.com/go/crate/runtimehelper v0.1.0 // indirect
git.blauwelle.com/go/crate/synchelper v0.1.0 // indirect
) )

@ -1,8 +1,4 @@
git.blauwelle.com/go/crate/exegroup v0.3.0 h1:TBLygDztECKc67NeIIBsFDxlA4KcJpbOmafqqRuKRcM= 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/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.6.0 h1:s/TeJUaV/Y8hHaz/3FumdbwQWCbRMmOx8prrNmByJHs=
git.blauwelle.com/go/crate/log v0.4.0/go.mod h1:NfiG7YKQCTnLIcn6fVkaa2qEu+DuYi1Kz783Sc/F3jI= git.blauwelle.com/go/crate/log v0.6.0/go.mod h1:jfVfpRODZTA70A8IkApVeGsS1zfLk1D77sLWZM/w+L0=
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=

@ -3,10 +3,7 @@ module git.blauwelle.com/go/crate/logotel
go 1.20 go 1.20
require ( require (
git.blauwelle.com/go/crate/log v0.3.0 git.blauwelle.com/go/crate/log v0.6.0
git.blauwelle.com/go/crate/synchelper v0.1.0
go.opentelemetry.io/otel v1.13.0 go.opentelemetry.io/otel v1.13.0
go.opentelemetry.io/otel/trace v1.13.0 go.opentelemetry.io/otel/trace v1.13.0
) )
require git.blauwelle.com/go/crate/runtimehelper v0.1.0 // indirect

@ -1,9 +1,5 @@
git.blauwelle.com/go/crate/log v0.3.0 h1:oLXMAShuPFQgHc5fNjWU3kcESaS8lpS88P2t5G2b2yA= git.blauwelle.com/go/crate/log v0.6.0 h1:s/TeJUaV/Y8hHaz/3FumdbwQWCbRMmOx8prrNmByJHs=
git.blauwelle.com/go/crate/log v0.3.0/go.mod h1:NfiG7YKQCTnLIcn6fVkaa2qEu+DuYi1Kz783Sc/F3jI= git.blauwelle.com/go/crate/log v0.6.0/go.mod h1:jfVfpRODZTA70A8IkApVeGsS1zfLk1D77sLWZM/w+L0=
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=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

@ -1,6 +1,8 @@
package logotel package logotel
import "git.blauwelle.com/go/crate/synchelper" import (
"git.blauwelle.com/go/crate/log/logsdk/logjson"
)
func newConfig(opts ...Option) *config { func newConfig(opts ...Option) *config {
cfg := defaultConfig() cfg := defaultConfig()
@ -8,7 +10,7 @@ func newConfig(opts ...Option) *config {
opt.apply(cfg) opt.apply(cfg)
} }
if !cfg.hasPool { if !cfg.hasPool {
cfg.bufferPool = synchelper.NewBytesBufferPool(512, 4096) cfg.bytesBufferPool = logjson.NewBytesBufferPool(512, 4096)
} }
return cfg return cfg
} }
@ -20,9 +22,9 @@ func defaultConfig() *config {
} }
// WithBufferPool 指定缓冲池 // WithBufferPool 指定缓冲池
func WithBufferPool(pool synchelper.BytesBufferPool) Option { func WithBufferPool(pool logjson.BytesBufferPool) Option {
return optionFunc(func(cfg *config) { return optionFunc(func(cfg *config) {
cfg.bufferPool = pool cfg.bytesBufferPool = pool
cfg.hasPool = true cfg.hasPool = true
}) })
} }
@ -33,7 +35,7 @@ type Option interface {
} }
type config struct { type config struct {
bufferPool synchelper.BytesBufferPool bytesBufferPool logjson.BytesBufferPool
hasPool bool hasPool bool
} }
type optionFunc func(cfg *config) type optionFunc func(cfg *config)

@ -7,7 +7,7 @@ import (
"strconv" "strconv"
"git.blauwelle.com/go/crate/log/logsdk" "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/attribute"
"go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/codes"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0" semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
@ -18,7 +18,7 @@ import (
func New(opts ...Option) *Processor { func New(opts ...Option) *Processor {
cfg := newConfig(opts...) cfg := newConfig(opts...)
return &Processor{ return &Processor{
bufferPool: cfg.bufferPool, bufferPool: cfg.bytesBufferPool,
} }
} }
@ -26,7 +26,7 @@ var _ logsdk.EntryProcessor = &Processor{}
// Processor 用于把日志和 opentelemetry 对接 // Processor 用于把日志和 opentelemetry 对接
type Processor struct { type Processor struct {
bufferPool synchelper.BytesBufferPool bufferPool logjson.BytesBufferPool
} }
func (processor *Processor) Process(entry logsdk.ReadonlyEntry) { 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) { switch value := field.Value.(type) {
case nil: case nil:
return attribute.String(field.Key, "<nil>") return attribute.String(field.Key, "<nil>")

Loading…
Cancel
Save