Skip to content

Commit

Permalink
Copy in quantile functions instead of exporting them from Prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
jhesketh committed Nov 18, 2024
1 parent b471cea commit d89bbab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions pkg/streamingpromql/operators/functions/histograms.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type groupWithLabels struct {

type bucketGroup struct {
groupedMetricName string // The metric name of the group. May be duplicate between groups.
pointBuckets []promql.Buckets // Buckets for the grouped series at each step
pointBuckets []buckets // Buckets for the grouped series at each step
nativeHistograms *[]promql.HPoint // Histograms should only ever exist once per group
remainingSeriesCount uint // The number of series remaining before this group is fully collated.
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func (h *HistogramFunctionOverInstantVector) SeriesMetadata(ctx context.Context)
g.labels = lb.Labels()
g.group = bucketGroupPool.Get()
g.group.groupedMetricName = series.Labels.Get(labels.MetricName)
g.group.pointBuckets = make([]promql.Buckets, h.timeRange.StepCount)
g.group.pointBuckets = make([]buckets, h.timeRange.StepCount)
groups[string(b)] = g
}
g.group.remainingSeriesCount++
Expand All @@ -150,7 +150,7 @@ func (h *HistogramFunctionOverInstantVector) SeriesMetadata(ctx context.Context)
g.labels = lb.Labels()
g.group = bucketGroupPool.Get()
g.group.groupedMetricName = series.Labels.Get(labels.MetricName)
g.group.pointBuckets = make([]promql.Buckets, h.timeRange.StepCount)
g.group.pointBuckets = make([]buckets, h.timeRange.StepCount)
groups[string(b)] = g
}
g.group.remainingSeriesCount++
Expand Down Expand Up @@ -242,7 +242,7 @@ func (h *HistogramFunctionOverInstantVector) saveFloatsToGroup(fPoints []promql.
pointIdx := h.timeRange.PointIndex(f.T)
g.pointBuckets[pointIdx] = append(
g.pointBuckets[pointIdx],
promql.Bucket{
bucket{
UpperBound: upperBound,
Count: f.F,
},
Expand Down Expand Up @@ -307,7 +307,7 @@ func (h *HistogramFunctionOverInstantVector) computeOutputSeriesForGroup(_ conte
}

if len(g.pointBuckets[pointIdx]) > 0 {
res, forcedMonotonicity, _ := promql.BucketQuantile(ph, g.pointBuckets[pointIdx])
res, forcedMonotonicity, _ := bucketQuantile(ph, g.pointBuckets[pointIdx])
floatPoints = append(floatPoints, promql.FPoint{
T: h.timeRange.IndexTime(int64(pointIdx)),
F: res,
Expand All @@ -323,7 +323,7 @@ func (h *HistogramFunctionOverInstantVector) computeOutputSeriesForGroup(_ conte
}

if currentHPoint != nil && h.timeRange.PointIndex(currentHPoint.T) == int64(pointIdx) {
res := promql.HistogramQuantile(ph, currentHPoint.H)
res := histogramQuantile(ph, currentHPoint.H)

floatPoints = append(floatPoints, promql.FPoint{
T: h.timeRange.IndexTime(int64(pointIdx)),
Expand Down
6 changes: 3 additions & 3 deletions vendor/github.com/prometheus/prometheus/promql/functions.go

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

22 changes: 11 additions & 11 deletions vendor/github.com/prometheus/prometheus/promql/quantile.go

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

0 comments on commit d89bbab

Please sign in to comment.