MCPcopy
hub / github.com/prometheus/prometheus / ReduceResolution

Method ReduceResolution

model/histogram/histogram.go:627–654  ·  view source on GitHub ↗

ReduceResolution reduces the histogram's spans, buckets into target schema. An error is returned in the following cases: - The target schema is not smaller than the current histogram's schema. - The histogram has custom buckets. - The target schema is a custom buckets schema. - Any spans have an inv

(targetSchema int32)

Source from the content-addressed store, hash-verified

625// - Any spans have an invalid offset.
626// - The spans are inconsistent with the number of buckets.
627func (h *Histogram) ReduceResolution(targetSchema int32) error {
628 // Note that the follow three returns are not returning a
629 // histogram.Error because they are programming errors.
630 if h.UsesCustomBuckets() {
631 return errors.New("cannot reduce resolution when there are custom buckets")
632 }
633 if IsCustomBucketsSchema(targetSchema) {
634 return errors.New("cannot reduce resolution to custom buckets schema")
635 }
636 if targetSchema >= h.Schema {
637 return fmt.Errorf("cannot reduce resolution from schema %d to %d", h.Schema, targetSchema)
638 }
639
640 var err error
641
642 if h.PositiveSpans, h.PositiveBuckets, err = reduceResolution(
643 h.PositiveSpans, h.PositiveBuckets, h.Schema, targetSchema, true, true,
644 ); err != nil {
645 return err
646 }
647 if h.NegativeSpans, h.NegativeBuckets, err = reduceResolution(
648 h.NegativeSpans, h.NegativeBuckets, h.Schema, targetSchema, true, true,
649 ); err != nil {
650 return err
651 }
652 h.Schema = targetSchema
653 return nil
654}

Callers 15

histogramSamplesV1Method · 0.45
histogramSamplesV2Method · 0.45
AtHistogramMethod · 0.45
AtFloatHistogramMethod · 0.45
AtFloatHistogramMethod · 0.45
setCurrentHistogramMethod · 0.45
AppendHistogramMethod · 0.45
AppendMethod · 0.45

Calls 3

UsesCustomBucketsMethod · 0.95
IsCustomBucketsSchemaFunction · 0.85
reduceResolutionFunction · 0.85

Tested by 2