MCPcopy
hub / github.com/prometheus/prometheus / TestBucketLimitAppender

Function TestBucketLimitAppender

scrape/target_test.go:526–676  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

524}
525
526func TestBucketLimitAppender(t *testing.T) {
527 example := histogram.Histogram{
528 Schema: 0,
529 Count: 21,
530 Sum: 33,
531 ZeroThreshold: 0.001,
532 ZeroCount: 3,
533 PositiveSpans: []histogram.Span{
534 {Offset: 0, Length: 3},
535 },
536 PositiveBuckets: []int64{3, 0, 0},
537 NegativeSpans: []histogram.Span{
538 {Offset: 0, Length: 3},
539 },
540 NegativeBuckets: []int64{3, 0, 0},
541 }
542
543 bigGap := histogram.Histogram{
544 Schema: 0,
545 Count: 21,
546 Sum: 33,
547 ZeroThreshold: 0.001,
548 ZeroCount: 3,
549 PositiveSpans: []histogram.Span{
550 {Offset: 1, Length: 1}, // in (1, 2]
551 {Offset: 2, Length: 1}, // in (8, 16]
552 },
553 PositiveBuckets: []int64{1, 0}, // 1, 1
554 }
555
556 customBuckets := histogram.Histogram{
557 Schema: histogram.CustomBucketsSchema,
558 Count: 9,
559 Sum: 33,
560 PositiveSpans: []histogram.Span{
561 {Offset: 0, Length: 3},
562 },
563 PositiveBuckets: []int64{3, 0, 0},
564 CustomValues: []float64{1, 2, 3},
565 }
566
567 cases := []struct {
568 h histogram.Histogram
569 limit int
570 expectError bool
571 expectBucketCount int
572 expectSchema int32
573 }{
574 {
575 h: example,
576 limit: 3,
577 expectError: true,
578 },
579 {
580 h: example,
581 limit: 4,
582 expectError: false,
583 expectBucketCount: 4,

Callers

nothing calls this directly

Calls 12

AppendMethod · 0.95
NewAppendableFunction · 0.92
FromStringsFunction · 0.92
ToFloatMethod · 0.80
RunMethod · 0.65
AppenderMethod · 0.65
CopyMethod · 0.65
AppendHistogramMethod · 0.65
ErrorMethod · 0.65
CommitMethod · 0.65
AppenderV2Method · 0.65
ContextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…