-
Notifications
You must be signed in to change notification settings - Fork 832
Fix TestNativeHistogramFuzz to cover queries that contain count_values #6751
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
Fix TestNativeHistogramFuzz to cover queries that contain count_values #6751
Conversation
Signed-off-by: SungJin1212 <[email protected]>
@harry671003 Can you help take a look at this? |
|
||
fetchValuesFromNH := func(nhString string) []float64 { | ||
// Regex to match float numbers | ||
re := regexp.MustCompile(`-?\d+(\.\d+)?`) |
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.
Instead of using a regex here can we use parser.ParseSeriesDesc() to parse this into a real histogram?
See: https://github.com/prometheus/prometheus/blob/main/promql/parser/parse.go#L252
value := r.Metric.Get("value")
lbls, val, err := parser.ParseSeriesDesc(value)
This worked for me.
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.
Thanks, but it doesn't seem to work for me..
The query result is like:
status": "success",
"data": {
"resultType": "matrix",
"result": [
{
"metric": {
"value": "{count:102, sum:202.39999999999998, [-4,-2.82842712474619):11, [-2.82842712474619,-2):11, [-1.414213562373095,-1):12, [-1,-0.7071067811865475):11, [-0.001,0.001]:12, (0.7071067811865475,1]:11, (1,1.414213562373095]:12, (2,2.82842712474619]:11, (2.82842712474619,4]:11}"
},
"values": [
[
1747623681,
"1"
]
]
},
I got the error: err 1:7: parse error: unexpected character inside braces: ':'
when the input of ParseSeriesDesc
. is "{count:102, sum:202.39999999999998, [-4,-2.82842712474619):11, [-2.82842712474619,-2):11, [-1.414213562373095,-1):12, [-1,-0.7071067811865475):11, [-0.001,0.001]:12, (0.7071067811865475,1]:11, (1,1.414213562373095]:12, (2,2.82842712474619]:11, (2.82842712474619,4]:11}"
.
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.
Probably parser.ParseSeriesDesc
doesn't support NH format now. We can go ahead with the regex I think
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.
You're right. I was mistaken earlier.
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.
Thanks a lot!
This PR fixes
TestNativeHistogramFuzz
test to cover queries that containcount_values
.For example, the query
the result is
So, we need to cover this case in
TestNativeHistogramFuzz
.Which issue(s) this PR fixes:
Fixes #6724
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]