@@ -30,6 +30,52 @@ type worker struct {
30
30
index int // worker index
31
31
}
32
32
33
+ var histogramBucketSamples = []struct {
34
+ bucketCounts []uint64
35
+ sum int64
36
+ }{
37
+ {
38
+ []uint64 {0 , 0 , 1 , 0 , 0 , 0 , 3 , 4 , 1 , 1 , 0 , 0 , 0 , 0 , 0 },
39
+ 3940 ,
40
+ },
41
+ {
42
+ []uint64 {0 , 0 , 0 , 0 , 0 , 0 , 2 , 4 , 4 , 0 , 0 , 0 , 0 , 0 , 0 },
43
+ 4455 ,
44
+ },
45
+ {
46
+ []uint64 {0 , 0 , 0 , 0 , 0 , 0 , 1 , 4 , 3 , 2 , 0 , 0 , 0 , 0 , 0 },
47
+ 5337 ,
48
+ },
49
+ {
50
+ []uint64 {0 , 0 , 1 , 0 , 1 , 0 , 2 , 2 , 1 , 3 , 0 , 0 , 0 , 0 , 0 },
51
+ 4477 ,
52
+ },
53
+ {
54
+ []uint64 {0 , 0 , 0 , 0 , 0 , 1 , 3 , 2 , 2 , 2 , 0 , 0 , 0 , 0 , 0 },
55
+ 4670 ,
56
+ },
57
+ {
58
+ []uint64 {0 , 0 , 0 , 1 , 1 , 0 , 1 , 1 , 1 , 5 , 0 , 0 , 0 , 0 , 0 },
59
+ 5670 ,
60
+ },
61
+ {
62
+ []uint64 {0 , 0 , 0 , 0 , 0 , 2 , 1 , 1 , 4 , 2 , 0 , 0 , 0 , 0 , 0 },
63
+ 5091 ,
64
+ },
65
+ {
66
+ []uint64 {0 , 0 , 2 , 0 , 0 , 0 , 2 , 4 , 1 , 1 , 0 , 0 , 0 , 0 , 0 },
67
+ 3420 ,
68
+ },
69
+ {
70
+ []uint64 {0 , 0 , 0 , 0 , 0 , 0 , 1 , 3 , 2 , 4 , 0 , 0 , 0 , 0 , 0 },
71
+ 5917 ,
72
+ },
73
+ {
74
+ []uint64 {0 , 0 , 1 , 0 , 1 , 0 , 0 , 4 , 4 , 0 , 0 , 0 , 0 , 0 , 0 },
75
+ 3988 ,
76
+ },
77
+ }
78
+
33
79
func (w worker ) simulateMetrics (res * resource.Resource , exporterFunc func () (sdkmetric.Exporter , error ), signalAttrs []attribute.KeyValue ) {
34
80
limiter := rate .NewLimiter (w .limitPerSecond , 1 )
35
81
@@ -82,6 +128,29 @@ func (w worker) simulateMetrics(res *resource.Resource, exporterFunc func() (sdk
82
128
},
83
129
},
84
130
})
131
+ case metricTypeHistogram :
132
+ iteration := uint64 (i ) % 10
133
+ sum := histogramBucketSamples [iteration ].sum
134
+ bucketCounts := histogramBucketSamples [iteration ].bucketCounts
135
+ metrics = append (metrics , metricdata.Metrics {
136
+ Name : w .metricName ,
137
+ Data : metricdata.Histogram [int64 ]{
138
+ Temporality : metricdata .CumulativeTemporality ,
139
+ DataPoints : []metricdata.HistogramDataPoint [int64 ]{
140
+ {
141
+ StartTime : time .Now ().Add (- 1 * time .Second ),
142
+ Time : time .Now (),
143
+ Attributes : attribute .NewSet (signalAttrs ... ),
144
+ Exemplars : w .exemplars ,
145
+ Count : iteration ,
146
+ Sum : sum ,
147
+ // Bounds from https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#explicit-bucket-histogram-aggregation
148
+ Bounds : []float64 {0 , 5 , 10 , 25 , 50 , 75 , 100 , 250 , 500 , 750 , 1000 , 2500 , 5000 , 7500 , 10000 },
149
+ BucketCounts : bucketCounts ,
150
+ },
151
+ },
152
+ },
153
+ })
85
154
default :
86
155
w .logger .Fatal ("unknown metric type" )
87
156
}
0 commit comments