MCPcopy
hub / github.com/grafana/tempo / TestHistogramAggregator_EdgeCases

Function TestHistogramAggregator_EdgeCases

pkg/traceql/engine_metrics_test.go:3470–3553  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3468}
3469
3470func TestHistogramAggregator_EdgeCases(t *testing.T) {
3471 // Use fixed timestamps to ensure deterministic behavior
3472 baseTime := time.Unix(1257894000, 0) // Fixed timestamp
3473 req := &tempopb.QueryRangeRequest{
3474 Start: uint64(baseTime.UnixNano()),
3475 End: uint64(baseTime.Add(1 * time.Hour).UnixNano()),
3476 Step: uint64(15 * time.Second.Nanoseconds()),
3477 Exemplars: 5,
3478 }
3479
3480 tests := []struct {
3481 name string
3482 timeSeries []*tempopb.TimeSeries
3483 quantiles []float64
3484 expectFunc func(t *testing.T, results SeriesSet)
3485 }{
3486 {
3487 name: "no exemplars",
3488 quantiles: []float64{0.5, 0.9},
3489 timeSeries: []*tempopb.TimeSeries{
3490 {
3491 Labels: []commonv1proto.KeyValue{
3492 {Key: "service", Value: &commonv1proto.AnyValue{Value: &commonv1proto.AnyValue_StringValue{StringValue: "test"}}},
3493 {Key: internalLabelBucket, Value: &commonv1proto.AnyValue{Value: &commonv1proto.AnyValue_DoubleValue{DoubleValue: 2.0}}},
3494 },
3495 Samples: []tempopb.Sample{
3496 {TimestampMs: baseTime.UnixMilli(), Value: 5},
3497 },
3498 Exemplars: []tempopb.Exemplar{}, // No exemplars
3499 },
3500 },
3501 expectFunc: func(t *testing.T, results SeriesSet) {
3502 for _, series := range results {
3503 require.Empty(t, series.Exemplars, "Should have no exemplars")
3504 }
3505 },
3506 },
3507 {
3508 name: "exemplars outside bucket ranges",
3509 quantiles: []float64{0.5},
3510 timeSeries: []*tempopb.TimeSeries{
3511 {
3512 Labels: []commonv1proto.KeyValue{
3513 {Key: "service", Value: &commonv1proto.AnyValue{Value: &commonv1proto.AnyValue_StringValue{StringValue: "test"}}},
3514 {Key: internalLabelBucket, Value: &commonv1proto.AnyValue{Value: &commonv1proto.AnyValue_DoubleValue{DoubleValue: 2.0}}},
3515 },
3516 Samples: []tempopb.Sample{
3517 {TimestampMs: baseTime.UnixMilli(), Value: 5},
3518 },
3519 Exemplars: []tempopb.Exemplar{
3520 {
3521 Value: 10.0, // Much larger than bucket, should not match
3522 TimestampMs: baseTime.UnixMilli(),
3523 },
3524 },
3525 },
3526 },
3527 expectFunc: func(t *testing.T, results SeriesSet) {

Callers

nothing calls this directly

Calls 6

CombineMethod · 0.95
ResultsMethod · 0.95
Log2BucketizeFunction · 0.85
NewHistogramAggregatorFunction · 0.85
AddMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected