Skip to content

Commit

Permalink
feat: add type as key type (like zerolog)
Browse files Browse the repository at this point in the history
  • Loading branch information
stergiotis committed Jan 4, 2025
1 parent b2db684 commit 77c089d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions public/observability/eh/eb/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"hash"
"net"
"net/netip"
"reflect"
"time"
)

Expand Down Expand Up @@ -39,6 +40,9 @@ func (inst *ErrorBuilder) Reset() {
inst.encoder.Reset()
inst.open = true
}
func (inst *ErrorBuilder) Type(key string, val any) *ErrorBuilder {
return inst.Str(key, reflect.TypeOf(val).String())
}
func (inst *ErrorBuilder) Str(key string, val string) *ErrorBuilder {
if !inst.open {
return inst
Expand Down
1 change: 1 addition & 0 deletions public/semistructured/cbor/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type CborKVBuilder[R any] interface {
Time(key string, t time.Time) R
Times(key string, t []time.Time) R
IPAddr(key string, ip net.IP) R
Type(key string, val any) R
}

var _ CborKVBuilder[*zerolog.Event] = (*zerolog.Event)(nil)

0 comments on commit 77c089d

Please sign in to comment.