log/升级对log的依赖;

develop
Ge Song 2 years ago
parent f21f93b713
commit f58f914826

@ -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
)

@ -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=

@ -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

@ -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=

@ -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)

@ -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, "<nil>")

Loading…
Cancel
Save