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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/ingester/instance_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/grafana/tempo/pkg/tempopb"
"github.com/grafana/tempo/pkg/util"
"github.com/grafana/tempo/pkg/util/test"
"github.com/grafana/tempo/tempodb/search"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -357,7 +358,8 @@ func TestInstanceSearchMetrics(t *testing.T) {

search := func() *tempopb.SearchMetrics {
sr, err := i.Search(context.Background(), &tempopb.SearchRequest{
Tags: map[string]string{"nomatch": "nomatch"},
// Exhaustive search
Tags: map[string]string{search.SecretExhaustiveSearchTag: "!"},
})
require.NoError(t, err)
return sr.Metrics
Expand Down
97 changes: 97 additions & 0 deletions pkg/tempofb/SearchBlockHeader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions pkg/tempofb/SearchBlockHeader_util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package tempofb

import flatbuffers "github.com/google/flatbuffers/go"

type SearchBlockHeaderBuilder struct {
Tags SearchDataMap
MinDur uint64
MaxDur uint64
}

func NewSearchBlockHeaderBuilder() *SearchBlockHeaderBuilder {
return &SearchBlockHeaderBuilder{
Tags: SearchDataMap{},
}
}

func (s *SearchBlockHeaderBuilder) AddEntry(e *SearchEntry) {

kv := &KeyValues{} //buffer

// Record all unique keyvalues
for i, ii := 0, e.TagsLength(); i < ii; i++ {
e.Tags(kv, i)
for j, jj := 0, kv.ValueLength(); j < jj; j++ {
s.AddTag(string(kv.Key()), string(kv.Value(j)))
}
}

// Record min/max durations
dur := e.EndTimeUnixNano() - e.StartTimeUnixNano()
if s.MinDur == 0 || dur < s.MinDur {
s.MinDur = dur
}
if dur > s.MaxDur {
s.MaxDur = dur
}
}

// AddTag adds the unique tag name and value to the search data. No effect if the pair is already present.
func (s *SearchBlockHeaderBuilder) AddTag(k string, v string) {
s.Tags.Add(k, v)
}

func (s *SearchBlockHeaderBuilder) ToBytes() []byte {
b := flatbuffers.NewBuilder(1024)

tags := s.Tags.WriteToBuilder(b)

SearchBlockHeaderStart(b)
SearchBlockHeaderAddMinDurationNanos(b, s.MinDur)
SearchBlockHeaderAddMaxDurationNanos(b, s.MaxDur)
SearchBlockHeaderAddTags(b, tags)
offset := SearchBlockHeaderEnd(b)
b.Finish(offset)
return b.FinishedBytes()
}
12 changes: 12 additions & 0 deletions pkg/tempofb/tempo.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,16 @@ table SearchPage {

// Trace entries
entries : [SearchEntry];
}

table SearchBlockHeader {
// This is a rollup of all distinct tags/values in the
// block for quick elimination.
tags : [KeyValues];

// Smallest trace duration in the block
min_duration_nanos: uint64;

// Largest trace duration in the block
max_duration_nanos: uint64;
}
Loading