Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.3
github.com/axiomhq/hyperloglog v0.2.6
github.com/bytedance/sonic v1.14.2
github.com/evanphx/json-patch v5.9.11+incompatible
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8
github.com/googleapis/gax-go/v2 v2.16.0
Expand Down Expand Up @@ -165,12 +166,15 @@ require (
github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect
github.com/bytedance/sonic/loader v0.4.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/clipperhouse/displaywidth v0.6.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.6.0 // indirect
Expand Down Expand Up @@ -323,6 +327,7 @@ require (
github.com/tinylib/msgp v1.6.1 // indirect
github.com/tklauser/go-sysconf v0.3.15 // indirect
github.com/tklauser/numcpus v0.10.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/twmb/franz-go/pkg/sasl/kerberos v1.1.0 // indirect
github.com/twmb/franz-go/plugin/kzap v1.1.2 // indirect
github.com/twmb/murmur3 v1.1.8 // indirect
Expand Down Expand Up @@ -407,6 +412,7 @@ require (
go.opentelemetry.io/otel/sdk/log v0.14.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.39.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
golang.org/x/mod v0.31.0 // indirect
Expand Down
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
github.com/bytedance/sonic v1.14.2 h1:k1twIoe97C1DtYUo+fZQy865IuHia4PR5RPiuGPPIIE=
github.com/bytedance/sonic v1.14.2/go.mod h1:T80iDELeHiHKSc0C9tubFygiuXoGzrkjKzX2quAx980=
github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o=
github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
Expand All @@ -176,6 +182,8 @@ github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfa
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4=
github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f h1:Y8xYupdHxryycyPlc9Y+bSQAYZnetRJ70VMVKm5CKI0=
Expand Down Expand Up @@ -904,6 +912,7 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
Expand All @@ -918,6 +927,8 @@ github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nE
github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso=
github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/twmb/franz-go v1.7.0/go.mod h1:PMze0jNfNghhih2XHbkmTFykbMF5sJqmNJB31DOOzro=
github.com/twmb/franz-go v1.20.6 h1:TpQTt4QcixJ1cHEmQGPOERvTzo99s8jAutmS7rbSD6w=
github.com/twmb/franz-go v1.20.6/go.mod h1:u+FzH2sInp7b9HNVv2cZN8AxdXy6y/AQ1Bkptu4c0FM=
Expand Down Expand Up @@ -1224,6 +1235,8 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
12 changes: 6 additions & 6 deletions tempodb/backend/block_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"slices"
"time"

"github.com/bytedance/sonic"
"github.com/cespare/xxhash/v2"
"github.com/google/uuid"

"github.com/grafana/tempo/pkg/tempopb"
"github.com/grafana/tempo/pkg/traceql"
)
Expand Down Expand Up @@ -179,13 +179,13 @@ func (dc *DedicatedColumn) MarshalJSON() ([]byte, error) {
if cpy.Type == DefaultDedicatedColumnType {
cpy.Type = ""
}
return json.Marshal(&cpy)
return sonic.Marshal(&cpy)
}

func (dc *DedicatedColumn) UnmarshalJSON(b []byte) error {
type dcAlias DedicatedColumn // alias required to avoid recursive calls of UnmarshalJSON

err := json.Unmarshal(b, (*dcAlias)(dc))
err := sonic.Unmarshal(b, (*dcAlias)(dc))
if err != nil {
return err
}
Expand All @@ -210,7 +210,7 @@ func (dcs *DedicatedColumns) UnmarshalJSON(b []byte) error {
}

type dcsAlias DedicatedColumns // alias required to avoid recursive calls of UnmarshalJSON
err := json.Unmarshal(b, (*dcsAlias)(dcs))
err := sonic.Unmarshal(b, (*dcsAlias)(dcs))
if err != nil {
return err
}
Expand Down Expand Up @@ -408,7 +408,7 @@ func (dcs DedicatedColumns) Marshal() ([]byte, error) {
}

// NOTE: The json bytes interned in a map to avoid re-unmarshalling the same byte slice.
return json.Marshal(dcs)
return sonic.Marshal(dcs)
}

func (dcs DedicatedColumns) MarshalTo(data []byte) (n int, err error) {
Expand All @@ -427,7 +427,7 @@ func (dcs *DedicatedColumns) Unmarshal(data []byte) error {
}

// NOTE: The json bytes interned in a map to avoid re-unmarshalling the same byte slice.
return json.Unmarshal(data, &dcs)
return sonic.Unmarshal(data, &dcs)
}

func (b *CompactedBlockMeta) UnmarshalJSON(data []byte) error {
Expand Down
73 changes: 72 additions & 1 deletion tempodb/backend/block_meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestBlockMetaObjectAdded(t *testing.T) {
}
}

func TestBlockMetaJSONRoundTrip(t *testing.T) {
func TestBlockMetaJSONProtoRoundTrip(t *testing.T) {
timeParse := func(s string) time.Time {
date, err := time.Parse(time.RFC3339Nano, s)
require.NoError(t, err)
Expand Down Expand Up @@ -147,6 +147,7 @@ func TestBlockMetaJSONRoundTrip(t *testing.T) {
]
}`

// JSON
metaJSON, err := json.Marshal(meta)
require.NoError(t, err)
assert.JSONEq(t, expectedJSON, string(metaJSON))
Expand All @@ -155,6 +156,76 @@ func TestBlockMetaJSONRoundTrip(t *testing.T) {
err = json.Unmarshal(metaJSON, &metaRoundtrip)
require.NoError(t, err)
assert.Equal(t, meta, metaRoundtrip)

// proto
protoData, err := meta.Marshal()
require.NoError(t, err)
newMeta := BlockMeta{}
require.NoError(t, newMeta.Unmarshal(protoData))

assert.Equal(t, meta, newMeta)
}

func BenchmarkBlockMetaMarshalUnmarshal(b *testing.B) {
timeParse := func(s string) time.Time {
date, err := time.Parse(time.RFC3339Nano, s)
require.NoError(b, err)
return date
}

meta := BlockMeta{
Version: "vParquet3",
BlockID: MustParse("00000000-0000-0000-0000-000000000000"),
TenantID: "single-tenant",
StartTime: timeParse("2021-01-01T00:00:00.0000000Z"),
EndTime: timeParse("2021-01-02T00:00:00.0000000Z"),
TotalObjects: 10,
Size_: 12345,
CompactionLevel: 1,
Encoding: EncZstd,
IndexPageSize: 250000,
TotalRecords: 124356,
DataEncoding: "",
BloomShardCount: 244,
FooterSize: 15775,
DedicatedColumns: DedicatedColumns{
{Scope: "resource", Name: "namespace", Type: "string"},
{Scope: "resource", Name: "net.host.port", Type: "int"},
{Scope: "span", Name: "http.method", Type: "string"},
{Scope: "span", Name: "namespace", Type: "string"},
{Scope: "span", Name: "http.response.body.size", Type: "int"},
{Scope: "span", Name: "http.request.header.accept", Type: "string", Options: DedicatedColumnOptions{DedicatedColumnOptionArray}},

{Name: "test.span.str-01", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
{Name: "test.span.str-02", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
{Name: "test.span.str-03", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
{Name: "test.span.str-04", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
{Name: "test.span.str-05", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
{Name: "test.span.str-06", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
{Name: "test.span.str-07", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
{Name: "test.span.str-08", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
{Name: "test.span.str-09", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
{Name: "test.span.str-10", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString},
},
}

b.Run("marshal", func(b *testing.B) {
_, err := meta.Marshal()
require.NoError(b, err, "marshal should not fail")
for b.Loop() {
meta.Marshal() // nolint:errcheck // skipping error check for benchmark, checked above
}
})

b.Run("unmarshal", func(b *testing.B) {
data, err := meta.Marshal()
require.NoError(b, err)
require.NoError(b, meta.Unmarshal(data), "unmarshal should not fail")

for b.Loop() {
meta.Unmarshal(data) // nolint:errcheck // skipping error check for benchmark, checked above
}
})
}

func TestDedicatedColumnsFromTempopb(t *testing.T) {
Expand Down
Loading
Loading