Don't return incorrect position information from annotations generated by sharded query legs #9536
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.
What this PR does
This PR fixes an issue where annotations could be returned to a user with incorrect position information if the query is sharded and the sharded legs generate annotations.
For example, running the query
avg(rate(up[1m]))
can produce two annotations:PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: "up" (1:10)
PromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: "up" (1:12)
...but
up
appears at position 10 on line 1, so the second annotation at position 12 is misleading or confusing. It comes about becauseavg(...)
is rewritten assum(...) / count(...)
for sharding and the second annotation is generated by queriers for the shardedcount(rate(up[1m]))
legs.Another example: running the query
ceil(sum(rate(up[1m])))
returnsPromQL info: metric might not be a counter, name does not end in _total/_sum/_count/_bucket: "up" (1:10)
(becausesum(rate(up[1m]))
is what is run in queriers), butup
appears at position 15.We already remove position information for annotations generated by the parent query (ie. the one run in query-frontends to combine the results of the sharded legs), so this PR does the same for annotations from sharded legs.
Which issue(s) this PR fixes or relates to
Related to #9138
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.