(t *testing.T)
| 470 | } |
| 471 | |
| 472 | func TestNativeHistogram(t *testing.T) { |
| 473 | now := time.Now() |
| 474 | |
| 475 | scenarios := []struct { |
| 476 | name string |
| 477 | observations []float64 // With simulated interval of 1m. |
| 478 | factor float64 |
| 479 | zeroThreshold float64 |
| 480 | maxBuckets uint32 |
| 481 | minResetDuration time.Duration |
| 482 | maxZeroThreshold float64 |
| 483 | want *dto.Histogram |
| 484 | }{ |
| 485 | { |
| 486 | name: "no sparse buckets", |
| 487 | observations: []float64{1, 2, 3}, |
| 488 | factor: 1, |
| 489 | want: &dto.Histogram{ |
| 490 | SampleCount: proto.Uint64(3), |
| 491 | SampleSum: proto.Float64(6), |
| 492 | Bucket: []*dto.Bucket{ |
| 493 | {CumulativeCount: proto.Uint64(0), UpperBound: proto.Float64(0.005)}, |
| 494 | {CumulativeCount: proto.Uint64(0), UpperBound: proto.Float64(0.01)}, |
| 495 | {CumulativeCount: proto.Uint64(0), UpperBound: proto.Float64(0.025)}, |
| 496 | {CumulativeCount: proto.Uint64(0), UpperBound: proto.Float64(0.05)}, |
| 497 | {CumulativeCount: proto.Uint64(0), UpperBound: proto.Float64(0.1)}, |
| 498 | {CumulativeCount: proto.Uint64(0), UpperBound: proto.Float64(0.25)}, |
| 499 | {CumulativeCount: proto.Uint64(0), UpperBound: proto.Float64(0.5)}, |
| 500 | {CumulativeCount: proto.Uint64(1), UpperBound: proto.Float64(1)}, |
| 501 | {CumulativeCount: proto.Uint64(2), UpperBound: proto.Float64(2.5)}, |
| 502 | {CumulativeCount: proto.Uint64(3), UpperBound: proto.Float64(5)}, |
| 503 | {CumulativeCount: proto.Uint64(3), UpperBound: proto.Float64(10)}, |
| 504 | }, |
| 505 | CreatedTimestamp: timestamppb.New(now), |
| 506 | }, |
| 507 | }, |
| 508 | { |
| 509 | name: "no observations", |
| 510 | factor: 1.1, |
| 511 | want: &dto.Histogram{ |
| 512 | SampleCount: proto.Uint64(0), |
| 513 | SampleSum: proto.Float64(0), |
| 514 | Schema: proto.Int32(3), |
| 515 | ZeroThreshold: proto.Float64(2.938735877055719e-39), |
| 516 | ZeroCount: proto.Uint64(0), |
| 517 | CreatedTimestamp: timestamppb.New(now), |
| 518 | }, |
| 519 | }, |
| 520 | { |
| 521 | name: "no observations and zero threshold of zero resulting in no-op span", |
| 522 | factor: 1.1, |
| 523 | zeroThreshold: NativeHistogramZeroThresholdZero, |
| 524 | want: &dto.Histogram{ |
| 525 | SampleCount: proto.Uint64(0), |
| 526 | SampleSum: proto.Float64(0), |
| 527 | Schema: proto.Int32(3), |
| 528 | ZeroThreshold: proto.Float64(0), |
| 529 | ZeroCount: proto.Uint64(0), |
nothing calls this directly
no test coverage detected