@@ -35,18 +35,59 @@ func TestHistogram(t *testing.T) {
3535 t .Run ("Float64/Delta/NoSum" , testDeltaHist [float64 ](conf [float64 ]{noSum : true , hPt : hPoint [float64 ]}))
3636 c .Reset ()
3737
38- t .Run ("Int64/Cumulative/Sum" , testCumulativeHist [int64 ](conf [int64 ]{hPt : hPointSummed [int64 ]}))
38+ t .Run ("Int64/Cumulative/Sum" , func (t * testing.T ) {
39+ t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "false" )
40+ testCumulativeHist [int64 ](conf [int64 ]{hPt : hPointSummed [int64 ], perSeriesStartTimeEnabled : false })(t )
41+ })
42+ c .Reset ()
43+
44+ t .Run ("Int64/Cumulative/Sum/PerSeriesStartTimeEnabled" , func (t * testing.T ) {
45+ t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "true" )
46+ testCumulativeHist [int64 ](conf [int64 ]{hPt : hPointSummed [int64 ], perSeriesStartTimeEnabled : true })(t )
47+ })
48+ c .Reset ()
49+
50+ t .Run ("Int64/Cumulative/NoSum" , func (t * testing.T ) {
51+ t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "false" )
52+ testCumulativeHist [int64 ](conf [int64 ]{noSum : true , hPt : hPoint [int64 ], perSeriesStartTimeEnabled : false })(t )
53+ })
54+ c .Reset ()
55+
56+ t .Run ("Int64/Cumulative/NoSum/PerSeriesStartTimeEnabled" , func (t * testing.T ) {
57+ t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "true" )
58+ testCumulativeHist [int64 ](conf [int64 ]{noSum : true , hPt : hPoint [int64 ], perSeriesStartTimeEnabled : true })(t )
59+ })
60+ c .Reset ()
61+
62+ t .Run ("Float64/Cumulative/Sum" , func (t * testing.T ) {
63+ t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "false" )
64+ testCumulativeHist [float64 ](conf [float64 ]{hPt : hPointSummed [float64 ], perSeriesStartTimeEnabled : false })(t )
65+ })
3966 c .Reset ()
40- t .Run ("Int64/Cumulative/NoSum" , testCumulativeHist [int64 ](conf [int64 ]{noSum : true , hPt : hPoint [int64 ]}))
67+
68+ t .Run ("Float64/Cumulative/Sum/PerSeriesStartTimeEnabled" , func (t * testing.T ) {
69+ t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "true" )
70+ testCumulativeHist [float64 ](conf [float64 ]{hPt : hPointSummed [float64 ], perSeriesStartTimeEnabled : true })(t )
71+ })
4172 c .Reset ()
42- t .Run ("Float64/Cumulative/Sum" , testCumulativeHist [float64 ](conf [float64 ]{hPt : hPointSummed [float64 ]}))
73+
74+ t .Run ("Float64/Cumulative/NoSum" , func (t * testing.T ) {
75+ t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "false" )
76+ testCumulativeHist [float64 ](conf [float64 ]{noSum : true , hPt : hPoint [float64 ], perSeriesStartTimeEnabled : false })(t )
77+ })
78+ c .Reset ()
79+
80+ t .Run ("Float64/Cumulative/NoSum/PerSeriesStartTimeEnabled" , func (t * testing.T ) {
81+ t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "true" )
82+ testCumulativeHist [float64 ](conf [float64 ]{noSum : true , hPt : hPoint [float64 ], perSeriesStartTimeEnabled : true })(t )
83+ })
4384 c .Reset ()
44- t .Run ("Float64/Cumulative/NoSum" , testCumulativeHist [float64 ](conf [float64 ]{noSum : true , hPt : hPoint [float64 ]}))
4585}
4686
4787type conf [N int64 | float64 ] struct {
48- noSum bool
49- hPt func (attribute.Set , N , uint64 , time.Time , time.Time ) metricdata.HistogramDataPoint [N ]
88+ noSum bool
89+ hPt func (attribute.Set , N , uint64 , time.Time , time.Time ) metricdata.HistogramDataPoint [N ]
90+ perSeriesStartTimeEnabled bool
5091}
5192
5293func testDeltaHist [N int64 | float64 ](c conf [N ]) func (t * testing.T ) {
@@ -142,6 +183,27 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
142183 Filter : attrFltr ,
143184 AggregationLimit : 3 ,
144185 }.ExplicitBucketHistogram (bounds , noMinMax , c .noSum )
186+
187+ aliceStartTime := y2kPlus (0 )
188+ bobStartTime := y2kPlus (0 )
189+ overflowStartTime := y2kPlus (0 )
190+
191+ timeStep1 := y2kPlus (2 )
192+ timeStep2 := y2kPlus (3 )
193+ timeStep3 := y2kPlus (4 )
194+ timeStep4 := y2kPlus (5 )
195+
196+ if c .perSeriesStartTimeEnabled {
197+ aliceStartTime = y2kPlus (2 )
198+ bobStartTime = y2kPlus (3 )
199+ overflowStartTime = y2kPlus (7 )
200+
201+ timeStep1 = y2kPlus (4 )
202+ timeStep2 = y2kPlus (5 )
203+ timeStep3 = y2kPlus (6 )
204+ timeStep4 = y2kPlus (8 )
205+ }
206+
145207 ctx := context .Background ()
146208 return test [N ](in , out , []teststep [N ]{
147209 {
@@ -167,8 +229,8 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
167229 agg : metricdata.Histogram [N ]{
168230 Temporality : metricdata .CumulativeTemporality ,
169231 DataPoints : []metricdata.HistogramDataPoint [N ]{
170- c .hPt (fltrAlice , 2 , 3 , y2kPlus ( 0 ), y2kPlus ( 2 ) ),
171- c .hPt (fltrBob , 10 , 2 , y2kPlus ( 0 ), y2kPlus ( 2 ) ),
232+ c .hPt (fltrAlice , 2 , 3 , aliceStartTime , timeStep1 ),
233+ c .hPt (fltrBob , 10 , 2 , bobStartTime , timeStep1 ),
172234 },
173235 },
174236 },
@@ -183,8 +245,8 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
183245 agg : metricdata.Histogram [N ]{
184246 Temporality : metricdata .CumulativeTemporality ,
185247 DataPoints : []metricdata.HistogramDataPoint [N ]{
186- c .hPt (fltrAlice , 2 , 4 , y2kPlus ( 0 ), y2kPlus ( 3 ) ),
187- c .hPt (fltrBob , 10 , 3 , y2kPlus ( 0 ), y2kPlus ( 3 ) ),
248+ c .hPt (fltrAlice , 2 , 4 , aliceStartTime , timeStep2 ),
249+ c .hPt (fltrBob , 10 , 3 , bobStartTime , timeStep2 ),
188250 },
189251 },
190252 },
@@ -196,8 +258,8 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
196258 agg : metricdata.Histogram [N ]{
197259 Temporality : metricdata .CumulativeTemporality ,
198260 DataPoints : []metricdata.HistogramDataPoint [N ]{
199- c .hPt (fltrAlice , 2 , 4 , y2kPlus ( 0 ), y2kPlus ( 4 ) ),
200- c .hPt (fltrBob , 10 , 3 , y2kPlus ( 0 ), y2kPlus ( 4 ) ),
261+ c .hPt (fltrAlice , 2 , 4 , aliceStartTime , timeStep3 ),
262+ c .hPt (fltrBob , 10 , 3 , bobStartTime , timeStep3 ),
201263 },
202264 },
203265 },
@@ -213,9 +275,9 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
213275 agg : metricdata.Histogram [N ]{
214276 Temporality : metricdata .CumulativeTemporality ,
215277 DataPoints : []metricdata.HistogramDataPoint [N ]{
216- c .hPt (fltrAlice , 2 , 4 , y2kPlus ( 0 ), y2kPlus ( 5 ) ),
217- c .hPt (fltrBob , 10 , 3 , y2kPlus ( 0 ), y2kPlus ( 5 ) ),
218- c .hPt (overflowSet , 1 , 2 , y2kPlus ( 0 ), y2kPlus ( 5 ) ),
278+ c .hPt (fltrAlice , 2 , 4 , aliceStartTime , timeStep4 ),
279+ c .hPt (fltrBob , 10 , 3 , bobStartTime , timeStep4 ),
280+ c .hPt (overflowSet , 1 , 2 , overflowStartTime , timeStep4 ),
219281 },
220282 },
221283 },
0 commit comments