-
Notifications
You must be signed in to change notification settings - Fork 57
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
Implement Native histogram Binary operations and Change Functions for Compatibility with v3.1.0 #503
base: update-prometheus-3.0
Are you sure you want to change the base?
Implement Native histogram Binary operations and Change Functions for Compatibility with v3.1.0 #503
Conversation
4018238
to
c3a5bbd
Compare
I would suggest updating the title to better reflect what you are actually doing. Are those PRs part of the Prometheus 3.0 update? |
Yeah, this PR is for the Prometheus 3.0 update. |
execution/aggregate/accumulator.go
Outdated
@@ -389,6 +406,14 @@ func (a *avgAcc) AddVector(vs []float64, hs []*histogram.FloatHistogram) error { | |||
} | |||
for _, h := range hs { | |||
if err := a.Add(0, h); err != nil { | |||
if errors.Is(err, histogram.ErrHistogramsIncompatibleSchema) { | |||
// skip warning |
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.
Why dont we also write a warning here ( and in the other cases )?
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.
At the Prometheus it is a warning
but we get the fail
if we return the error. So, I temporality return nil
.
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 can add warnings too here - we have a package for it "execution/warning" 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.
I think delayed name removal has couple bugs; as some functions are not implemented in the function operator and either have special operators or are pushed into the vector operator (like timestamp) or matrix operator (like any range vector function). I would vote that we ignore delayed name removal for now since its behind feature flag in prometheus anyway. If its decided that its going to be removed we have spent effort here that we need to roll back later. Otherwise looks great, thank you for the effort!
@MichaHoffmann |
c3a5bbd
to
9b14ea6
Compare
@MichaHoffmann |
@SungJin1212 - Could you also change the branch name in the workflow configuration to https://github.com/thanos-io/promql-engine/blob/update-prometheus-3.0/.github/workflows/test.yaml#L7 |
I think should not implement the delayed name removal flag here yet! Or at least it should be a separate PR but I think we should not do it unless it's the default in Prometheus |
@SungJin1212 Maybe let's do what @MichaHoffmann to temporarily remove the delayed name removal flag. If the only failed test is warning and info comparison, I think we are ok to merge to unblock 3.0 upgrade even if it failed the CI. |
execution/aggregate/accumulator.go
Outdated
@@ -287,6 +309,7 @@ func (c *countAcc) Reset(_ float64) { | |||
} | |||
|
|||
type avgAcc struct { | |||
ctx context.Context |
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.
can we just add it to the "Add" and "AddVector" method as first argument instead as a struct field of the accumulator?
execution/aggregate/vector_table.go
Outdated
@@ -50,7 +52,7 @@ func (t *vectorTable) timestamp() int64 { | |||
|
|||
func (t *vectorTable) aggregate(vector model.StepVector) error { |
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.
can we add ctx here instead of using it as a struct field?
if err != nil { | ||
return nil, err | ||
} | ||
if ok { | ||
if h != nil { | ||
sv.AppendHistogram(o.pool, uint64(sampleId), h) | ||
} else { | ||
sv.AppendSample(o.pool, uint64(sampleId), f) | ||
} else if f != nil { |
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.
@MichaHoffmann
I made the float64 to pointer to skip the value append when the engine should append nothing.
9d2e6ce
to
1c3604e
Compare
741014f
to
a904f7b
Compare
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
Signed-off-by: SungJin1212 <[email protected]>
a904f7b
to
f99e6db
Compare
execution/binary/vector.go
Outdated
@@ -12,6 +12,8 @@ import ( | |||
|
|||
"github.com/cespare/xxhash/v2" | |||
"github.com/efficientgo/core/errors" | |||
"github.com/prometheus/prometheus/promql/parser/posrange" |
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.
can we group with the other prometheus imports?
execution/binary/vector.go
Outdated
if err != nil { | ||
return model.StepVector{}, err | ||
if errors.Is(err, annotations.PromQLInfo) || errors.Is(err, annotations.PromQLWarning) { |
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.
why does computeBinaryPairing produce an "info/warning" error? that should not happen 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.
If the vectorElemBinop
return err, it produces err containing info/warnings.
The reason why use continue
is to ignore append. The current implementation return model.StepVector{}, nil
, then it appends 0
.
We get the fail like this test caes:
eval_info range from 0 to 24m step 6m left_histograms == bool right_floats_for_histograms
# No results.
execution/binary/vector.go
Outdated
case parser.DIV: | ||
return 0, hlhs.Copy().Div(rhs).Compact(0), true, nil | ||
case parser.ADD, parser.SUB, parser.POW, parser.MOD, parser.EQLC, parser.NEQ, parser.GTR, parser.LSS, parser.GTE, parser.LTE, parser.ATAN2: | ||
err := annotations.NewIncompatibleTypesInBinOpInfo("histogram", opName, "float", posrange.PositionRange{}) |
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.
I dont think we should return an error and an annotation at this point; that feels redundant.
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.
Prometheus also does it, but can we at least add the annotations somewhere else then?
engine/sort.go
Outdated
@@ -7,6 +7,7 @@ import ( | |||
"math" | |||
|
|||
"github.com/facette/natsort" | |||
|
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.
nit: Some of these files contain changes that are not relevant like adding whitespace or re-ordering the imports. Could you remove them?
Signed-off-by: SungJin1212 <[email protected]>
f60cb6c
to
85b9e94
Compare
Signed-off-by: SungJin1212 <[email protected]>
c2252cf
to
5d75bd3
Compare
Implement missing part to address these PRs.
sum
andavg
over mixed custom and exponential buckets, or incompatible custom buckets prometheus/prometheus#14611 and more - Added annotations to native histogramUpdate
Implement v3.1.0 Prometheus PRs
changes()
for mix of histograms and floats prometheus/prometheus#15469The
Delayed name dropping
implementation exists in another PR.