-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: limit tags and tag values search #4320
Open
javiermolinar
wants to merge
2
commits into
grafana:main
Choose a base branch
from
javiermolinar:search-tags-limit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+678
−383
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -360,6 +360,8 @@ Parameters: | |||||
Optional. Along with `end`, defines a time range from which tags should be returned. | ||||||
- `end = (unix epoch seconds)` | ||||||
Optional. Along with `start`, defines a time range from which tags should be returned. Providing both `start` and `end` includes blocks for the specified time range only. | ||||||
- `limit = (integer)` | ||||||
Optional. Limits the maximum number of tags | ||||||
|
||||||
|
||||||
### Search tags V2 | ||||||
|
@@ -385,6 +387,8 @@ Parameters: | |||||
Optional. Along with `end` define a time range from which tags should be returned. | ||||||
- `end = (unix epoch seconds)` | ||||||
Optional. Along with `start` define a time range from which tags should be returned. Providing both `start` and `end` includes blocks for the specified time range only. | ||||||
- `limit = (integer)` | ||||||
Optional. Limits the maximum number of tags per scope | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
#### Example | ||||||
|
||||||
|
@@ -515,6 +519,8 @@ Parameters: | |||||
Optional. Along with `end`, defines a time range from which tags should be returned. | ||||||
- `end = (unix epoch seconds)` | ||||||
Optional. Along with `start`, defines a time range from which tags should be returned. Providing both `start` and `end` includes blocks for the specified time range only. | ||||||
- `limit = (integer)` | ||||||
Optional. Limits the maximum number of tags values | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
### Search tag values V2 | ||||||
|
@@ -561,7 +567,16 @@ $ curl -G -s http://localhost:3200/api/v2/search/tag/.service.name/values | jq | |||||
} | ||||||
} | ||||||
``` | ||||||
This endpoint can also receive `start` and `end` optional parameters. These parameters define the time range from which the tags are fetched | ||||||
Parameters: | ||||||
- `start = (unix epoch seconds)` | ||||||
Optional. Along with `end`, defines a time range from which tags values should be returned. | ||||||
- `end = (unix epoch seconds)` | ||||||
Optional. Along with `start`, defines a time range from which tags values should be returned. Providing both `start` and `end` includes blocks for the specified time range only. | ||||||
- `q = (traceql query)` | ||||||
Optional. A TraceQL query to filter tag values by. Currently only works for a single spanset of `&&`ed conditions. For example: `{ span.foo = "bar" && resource.baz = "bat" ...}`. See also [Filtered tag values](#filtered-tag-values). | ||||||
- `limit = (integer)` | ||||||
Optional. Limits the maximum number of tags values | ||||||
|
||||||
|
||||||
#### Filtered tag values | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ import ( | |
func TestTagsCombiner(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
factory func(int) Combiner | ||
limit int | ||
factory func(int, uint32) Combiner | ||
limitBytes int | ||
result1 proto.Message | ||
result2 proto.Message | ||
expectedResult proto.Message | ||
|
@@ -31,7 +31,7 @@ func TestTagsCombiner(t *testing.T) { | |
expectedResult: &tempopb.SearchTagsResponse{TagNames: []string{"tag1", "tag2", "tag3"}, Metrics: &tempopb.MetadataMetrics{}}, | ||
actualResult: &tempopb.SearchTagsResponse{}, | ||
sort: func(m proto.Message) { sort.Strings(m.(*tempopb.SearchTagsResponse).TagNames) }, | ||
limit: 100, | ||
limitBytes: 100, | ||
}, | ||
{ | ||
name: "SearchTagsV2", | ||
|
@@ -49,7 +49,7 @@ func TestTagsCombiner(t *testing.T) { | |
return scopes[i].Name < scopes[j].Name | ||
}) | ||
}, | ||
limit: 100, | ||
limitBytes: 100, | ||
}, | ||
{ | ||
name: "SearchTagValues", | ||
|
@@ -59,7 +59,7 @@ func TestTagsCombiner(t *testing.T) { | |
expectedResult: &tempopb.SearchTagValuesResponse{TagValues: []string{"tag1", "tag2", "tag3"}, Metrics: &tempopb.MetadataMetrics{}}, | ||
actualResult: &tempopb.SearchTagValuesResponse{}, | ||
sort: func(m proto.Message) { sort.Strings(m.(*tempopb.SearchTagValuesResponse).TagValues) }, | ||
limit: 100, | ||
limitBytes: 100, | ||
}, | ||
{ | ||
name: "SearchTagValuesV2", | ||
|
@@ -73,7 +73,7 @@ func TestTagsCombiner(t *testing.T) { | |
return m.(*tempopb.SearchTagValuesV2Response).TagValues[i].Value < m.(*tempopb.SearchTagValuesV2Response).TagValues[j].Value | ||
}) | ||
}, | ||
limit: 100, | ||
limitBytes: 100, | ||
}, | ||
// limits | ||
{ | ||
|
@@ -85,7 +85,7 @@ func TestTagsCombiner(t *testing.T) { | |
actualResult: &tempopb.SearchTagsResponse{}, | ||
sort: func(m proto.Message) { sort.Strings(m.(*tempopb.SearchTagsResponse).TagNames) }, | ||
expectedShouldQuit: true, | ||
limit: 5, | ||
limitBytes: 5, | ||
}, | ||
{ | ||
name: "SearchTagsV2 - limited", | ||
|
@@ -104,7 +104,7 @@ func TestTagsCombiner(t *testing.T) { | |
}) | ||
}, | ||
expectedShouldQuit: true, | ||
limit: 2, | ||
limitBytes: 2, | ||
}, | ||
{ | ||
name: "SearchTagValues - limited", | ||
|
@@ -115,7 +115,7 @@ func TestTagsCombiner(t *testing.T) { | |
actualResult: &tempopb.SearchTagValuesResponse{}, | ||
sort: func(m proto.Message) { sort.Strings(m.(*tempopb.SearchTagValuesResponse).TagValues) }, | ||
expectedShouldQuit: true, | ||
limit: 5, | ||
limitBytes: 5, | ||
}, | ||
{ | ||
name: "SearchTagValuesV2 - limited", | ||
|
@@ -130,7 +130,7 @@ func TestTagsCombiner(t *testing.T) { | |
}) | ||
}, | ||
expectedShouldQuit: true, | ||
limit: 10, | ||
limitBytes: 10, | ||
}, | ||
// with metrics | ||
{ | ||
|
@@ -141,7 +141,7 @@ func TestTagsCombiner(t *testing.T) { | |
expectedResult: &tempopb.SearchTagsResponse{TagNames: []string{"tag1", "tag2", "tag3"}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 2}}, | ||
actualResult: &tempopb.SearchTagsResponse{}, | ||
sort: func(m proto.Message) { sort.Strings(m.(*tempopb.SearchTagsResponse).TagNames) }, | ||
limit: 100, | ||
limitBytes: 100, | ||
}, | ||
{ | ||
name: "SearchTagsV2 - metrics", | ||
|
@@ -159,7 +159,7 @@ func TestTagsCombiner(t *testing.T) { | |
return scopes[i].Name < scopes[j].Name | ||
}) | ||
}, | ||
limit: 100, | ||
limitBytes: 100, | ||
}, | ||
{ | ||
name: "SearchTagValues - metrics", | ||
|
@@ -169,7 +169,7 @@ func TestTagsCombiner(t *testing.T) { | |
expectedResult: &tempopb.SearchTagValuesResponse{TagValues: []string{"tag1", "tag2", "tag3"}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 2}}, | ||
actualResult: &tempopb.SearchTagValuesResponse{}, | ||
sort: func(m proto.Message) { sort.Strings(m.(*tempopb.SearchTagValuesResponse).TagValues) }, | ||
limit: 100, | ||
limitBytes: 100, | ||
}, | ||
{ | ||
name: "SearchTagValuesV2 - metrics", | ||
|
@@ -183,12 +183,13 @@ func TestTagsCombiner(t *testing.T) { | |
return m.(*tempopb.SearchTagValuesV2Response).TagValues[i].Value < m.(*tempopb.SearchTagValuesV2Response).TagValues[j].Value | ||
}) | ||
}, | ||
limit: 100, | ||
limitBytes: 100, | ||
}, | ||
} | ||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
combiner := tc.factory(tc.limit) | ||
// TODO ADD LIMIT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 :) |
||
combiner := tc.factory(tc.limitBytes, 0) | ||
|
||
err := combiner.AddResponse(toHTTPResponse(t, tc.result1, 200)) | ||
assert.NoError(t, err) | ||
|
@@ -228,7 +229,7 @@ func metrics(message proto.Message) *tempopb.MetadataMetrics { | |
} | ||
|
||
func TestTagsGRPCCombiner(t *testing.T) { | ||
c := NewTypedSearchTags(0) | ||
c := NewTypedSearchTags(0, 0) | ||
res1 := &tempopb.SearchTagsResponse{TagNames: []string{"tag1"}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
res2 := &tempopb.SearchTagsResponse{TagNames: []string{"tag1", "tag2"}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
diff1 := &tempopb.SearchTagsResponse{TagNames: []string{"tag1"}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
|
@@ -238,7 +239,7 @@ func TestTagsGRPCCombiner(t *testing.T) { | |
} | ||
|
||
func TestTagsV2GRPCCombiner(t *testing.T) { | ||
c := NewTypedSearchTagsV2(0) | ||
c := NewTypedSearchTagsV2(0, 0) | ||
res1 := &tempopb.SearchTagsV2Response{Scopes: []*tempopb.SearchTagsV2Scope{{Name: "scope1", Tags: []string{"tag1"}}}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
res2 := &tempopb.SearchTagsV2Response{Scopes: []*tempopb.SearchTagsV2Scope{{Name: "scope1", Tags: []string{"tag1", "tag2"}}, {Name: "scope2", Tags: []string{"tag3"}}}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
diff1 := &tempopb.SearchTagsV2Response{Scopes: []*tempopb.SearchTagsV2Scope{{Name: "scope1", Tags: []string{"tag1"}}}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
|
@@ -255,7 +256,7 @@ func TestTagsV2GRPCCombiner(t *testing.T) { | |
} | ||
|
||
func TestTagValuesGRPCCombiner(t *testing.T) { | ||
c := NewTypedSearchTagValues(0) | ||
c := NewTypedSearchTagValues(0, 0) | ||
res1 := &tempopb.SearchTagValuesResponse{TagValues: []string{"tag1"}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
res2 := &tempopb.SearchTagValuesResponse{TagValues: []string{"tag1", "tag2"}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
diff1 := &tempopb.SearchTagValuesResponse{TagValues: []string{"tag1"}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
|
@@ -265,7 +266,7 @@ func TestTagValuesGRPCCombiner(t *testing.T) { | |
} | ||
|
||
func TestTagValuesV2GRPCCombiner(t *testing.T) { | ||
c := NewTypedSearchTagValuesV2(0) | ||
c := NewTypedSearchTagValuesV2(0, 0) | ||
res1 := &tempopb.SearchTagValuesV2Response{TagValues: []*tempopb.TagValue{{Value: "v1", Type: "string"}}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
res2 := &tempopb.SearchTagValuesV2Response{TagValues: []*tempopb.TagValue{{Value: "v1", Type: "string"}, {Value: "v2", Type: "string"}}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
diff1 := &tempopb.SearchTagValuesV2Response{TagValues: []*tempopb.TagValue{{Value: "v1", Type: "string"}}, Metrics: &tempopb.MetadataMetrics{InspectedBytes: 1}} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.