@@ -18,6 +18,8 @@ import (
18
18
"go.opentelemetry.io/collector/pdata/pmetric"
19
19
"go.opentelemetry.io/collector/pdata/ptrace"
20
20
"go.opentelemetry.io/collector/processor/processortest"
21
+ "go.opentelemetry.io/otel/attribute"
22
+ "go.opentelemetry.io/otel/sdk/metric/metricdata"
21
23
)
22
24
23
25
var (
@@ -270,8 +272,8 @@ func TestComplexAttributeGrouping(t *testing.T) {
270
272
inputMetrics := someComplexMetrics (tt .withResourceAttrIndex , tt .inputResourceCount , tt .inputInstrumentationLibraryCount , 2 )
271
273
inputHistogramMetrics := someComplexHistogramMetrics (tt .withResourceAttrIndex , tt .inputResourceCount , tt .inputInstrumentationLibraryCount , 2 , 2 )
272
274
273
- tel := setupTelemetry ()
274
- gap , err := createGroupByAttrsProcessor (tel .NewProcessorCreateSettings (), tt .groupByKeys )
275
+ tel := setupTestTelemetry ()
276
+ gap , err := createGroupByAttrsProcessor (tel .NewSettings (), tt .groupByKeys )
275
277
require .NoError (t , err )
276
278
277
279
processedLogs , err := gap .processLogs (context .Background (), inputLogs )
@@ -371,23 +373,213 @@ func TestComplexAttributeGrouping(t *testing.T) {
371
373
}
372
374
}
373
375
}
374
-
375
- expected := expectedMetrics {}
376
+ var want []metricdata.Metrics
376
377
if tt .shouldMoveCommonGroupedAttr {
377
- expected .mDistLogGroups = int64 (tt .outputResourceCount )
378
- expected .mNumGroupedLogs = int64 (tt .outputTotalRecordsCount )
379
-
380
- expected .mDistMetricGroups = int64 (tt .outputResourceCount )
381
- expected .mNumGroupedMetrics = 4 * int64 (tt .outputTotalRecordsCount )
382
-
383
- expected .mDistSpanGroups = int64 (tt .outputResourceCount )
384
- expected .mNumGroupedSpans = int64 (tt .outputTotalRecordsCount )
378
+ want = []metricdata.Metrics {
379
+ {
380
+ Name : "otelcol_processor_groupbyattrs_num_grouped_logs" ,
381
+ Description : "Number of logs that had attributes grouped" ,
382
+ Unit : "1" ,
383
+ Data : metricdata.Sum [int64 ]{
384
+ Temporality : metricdata .CumulativeTemporality ,
385
+ IsMonotonic : true ,
386
+ DataPoints : []metricdata.DataPoint [int64 ]{
387
+ {
388
+ Value : int64 (tt .outputTotalRecordsCount ),
389
+ },
390
+ },
391
+ },
392
+ },
393
+ {
394
+ Name : "otelcol_processor_groupbyattrs_num_grouped_metrics" ,
395
+ Description : "Number of metrics that had attributes grouped" ,
396
+ Unit : "1" ,
397
+ Data : metricdata.Sum [int64 ]{
398
+ Temporality : metricdata .CumulativeTemporality ,
399
+ IsMonotonic : true ,
400
+ DataPoints : []metricdata.DataPoint [int64 ]{
401
+ {
402
+ Value : 4 * int64 (tt .outputTotalRecordsCount ),
403
+ },
404
+ },
405
+ },
406
+ },
407
+ {
408
+ Name : "otelcol_processor_groupbyattrs_num_grouped_spans" ,
409
+ Description : "Number of spans that had attributes grouped" ,
410
+ Unit : "1" ,
411
+ Data : metricdata.Sum [int64 ]{
412
+ Temporality : metricdata .CumulativeTemporality ,
413
+ IsMonotonic : true ,
414
+ DataPoints : []metricdata.DataPoint [int64 ]{
415
+ {
416
+ Value : int64 (tt .outputTotalRecordsCount ),
417
+ },
418
+ },
419
+ },
420
+ },
421
+ {
422
+ Name : "otelcol_processor_groupbyattrs_log_groups" ,
423
+ Description : "Distribution of groups extracted for logs" ,
424
+ Unit : "1" ,
425
+ Data : metricdata.Histogram [int64 ]{
426
+ Temporality : metricdata .CumulativeTemporality ,
427
+ DataPoints : []metricdata.HistogramDataPoint [int64 ]{
428
+ {
429
+ Attributes : * attribute .EmptySet (),
430
+ Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
431
+ BucketCounts : []uint64 {0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
432
+ Count : 1 ,
433
+ Min : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
434
+ Max : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
435
+ Sum : int64 (tt .outputResourceCount ),
436
+ },
437
+ },
438
+ },
439
+ },
440
+ {
441
+ Name : "otelcol_processor_groupbyattrs_metric_groups" ,
442
+ Description : "Distribution of groups extracted for metrics" ,
443
+ Unit : "1" ,
444
+ Data : metricdata.Histogram [int64 ]{
445
+ Temporality : metricdata .CumulativeTemporality ,
446
+ DataPoints : []metricdata.HistogramDataPoint [int64 ]{
447
+ {
448
+ Attributes : * attribute .EmptySet (),
449
+ Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
450
+ BucketCounts : []uint64 {0 , 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
451
+ Count : 2 ,
452
+ Min : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
453
+ Max : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
454
+ Sum : 2 * int64 (tt .outputResourceCount ),
455
+ },
456
+ },
457
+ },
458
+ },
459
+ {
460
+ Name : "otelcol_processor_groupbyattrs_span_groups" ,
461
+ Description : "Distribution of groups extracted for spans" ,
462
+ Unit : "1" ,
463
+ Data : metricdata.Histogram [int64 ]{
464
+ Temporality : metricdata .CumulativeTemporality ,
465
+ DataPoints : []metricdata.HistogramDataPoint [int64 ]{
466
+ {
467
+ Attributes : * attribute .EmptySet (),
468
+ Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
469
+ BucketCounts : []uint64 {0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
470
+ Count : 1 ,
471
+ Min : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
472
+ Max : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
473
+ Sum : int64 (tt .outputResourceCount ),
474
+ },
475
+ },
476
+ },
477
+ },
478
+ }
385
479
} else {
386
- expected .mNumNonGroupedLogs = int64 (tt .outputTotalRecordsCount )
387
- expected .mNumNonGroupedMetrics = 4 * int64 (tt .outputTotalRecordsCount )
388
- expected .mNumNonGroupedSpans = int64 (tt .outputTotalRecordsCount )
480
+ want = []metricdata.Metrics {
481
+ {
482
+ Name : "otelcol_processor_groupbyattrs_num_non_grouped_logs" ,
483
+ Description : "Number of logs that did not have attributes grouped" ,
484
+ Unit : "1" ,
485
+ Data : metricdata.Sum [int64 ]{
486
+ Temporality : metricdata .CumulativeTemporality ,
487
+ IsMonotonic : true ,
488
+ DataPoints : []metricdata.DataPoint [int64 ]{
489
+ {
490
+ Value : int64 (tt .outputTotalRecordsCount ),
491
+ },
492
+ },
493
+ },
494
+ },
495
+ {
496
+ Name : "otelcol_processor_groupbyattrs_num_non_grouped_metrics" ,
497
+ Description : "Number of metrics that did not have attributes grouped" ,
498
+ Unit : "1" ,
499
+ Data : metricdata.Sum [int64 ]{
500
+ Temporality : metricdata .CumulativeTemporality ,
501
+ IsMonotonic : true ,
502
+ DataPoints : []metricdata.DataPoint [int64 ]{
503
+ {
504
+ Value : 4 * int64 (tt .outputTotalRecordsCount ),
505
+ },
506
+ },
507
+ },
508
+ },
509
+ {
510
+ Name : "otelcol_processor_groupbyattrs_num_non_grouped_spans" ,
511
+ Description : "Number of spans that did not have attributes grouped" ,
512
+ Unit : "1" ,
513
+ Data : metricdata.Sum [int64 ]{
514
+ Temporality : metricdata .CumulativeTemporality ,
515
+ IsMonotonic : true ,
516
+ DataPoints : []metricdata.DataPoint [int64 ]{
517
+ {
518
+ Value : int64 (tt .outputTotalRecordsCount ),
519
+ },
520
+ },
521
+ },
522
+ },
523
+ {
524
+ Name : "otelcol_processor_groupbyattrs_log_groups" ,
525
+ Description : "Distribution of groups extracted for logs" ,
526
+ Unit : "1" ,
527
+ Data : metricdata.Histogram [int64 ]{
528
+ Temporality : metricdata .CumulativeTemporality ,
529
+ DataPoints : []metricdata.HistogramDataPoint [int64 ]{
530
+ {
531
+ Attributes : * attribute .EmptySet (),
532
+ Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
533
+ BucketCounts : []uint64 {0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
534
+ Count : 1 ,
535
+ Min : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
536
+ Max : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
537
+ Sum : int64 (tt .outputResourceCount ),
538
+ },
539
+ },
540
+ },
541
+ },
542
+ {
543
+ Name : "otelcol_processor_groupbyattrs_metric_groups" ,
544
+ Description : "Distribution of groups extracted for metrics" ,
545
+ Unit : "1" ,
546
+ Data : metricdata.Histogram [int64 ]{
547
+ Temporality : metricdata .CumulativeTemporality ,
548
+ DataPoints : []metricdata.HistogramDataPoint [int64 ]{
549
+ {
550
+ Attributes : * attribute .EmptySet (),
551
+ Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
552
+ BucketCounts : []uint64 {0 , 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
553
+ Count : 2 ,
554
+ Min : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
555
+ Max : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
556
+ Sum : 2 * int64 (tt .outputResourceCount ),
557
+ },
558
+ },
559
+ },
560
+ },
561
+ {
562
+ Name : "otelcol_processor_groupbyattrs_span_groups" ,
563
+ Description : "Distribution of groups extracted for spans" ,
564
+ Unit : "1" ,
565
+ Data : metricdata.Histogram [int64 ]{
566
+ Temporality : metricdata .CumulativeTemporality ,
567
+ DataPoints : []metricdata.HistogramDataPoint [int64 ]{
568
+ {
569
+ Attributes : * attribute .EmptySet (),
570
+ Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
571
+ BucketCounts : []uint64 {0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
572
+ Count : 1 ,
573
+ Min : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
574
+ Max : metricdata .NewExtrema (int64 (tt .outputResourceCount )),
575
+ Sum : int64 (tt .outputResourceCount ),
576
+ },
577
+ },
578
+ },
579
+ },
580
+ }
389
581
}
390
- tel .assertMetrics (t , expected )
582
+ tel .assertMetrics (t , want )
391
583
})
392
584
}
393
585
}
0 commit comments