@@ -13,6 +13,7 @@ import (
1313 "github.com/stretchr/testify/require"
1414
1515 "go.opentelemetry.io/otel/attribute"
16+ "go.opentelemetry.io/otel/sdk/internal/x"
1617 "go.opentelemetry.io/otel/sdk/metric/metricdata"
1718 "go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
1819)
@@ -37,44 +38,51 @@ func TestHistogram(t *testing.T) {
3738
3839 t .Run ("Int64/Cumulative/Sum" , func (t * testing.T ) {
3940 t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "false" )
40- testCumulativeHist [int64 ](conf [int64 ]{hPt : hPointSummed [int64 ], perSeriesStartTimeEnabled : false })(t )
41+ assert .False (t , x .PerSeriesStartTimestamps .Enabled ())
42+ testCumulativeHist [int64 ](conf [int64 ]{hPt : hPointSummed [int64 ]})(t )
4143 })
4244 c .Reset ()
4345
4446 t .Run ("Int64/Cumulative/Sum/PerSeriesStartTimeEnabled" , func (t * testing.T ) {
4547 t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "true" )
46- testCumulativeHist [int64 ](conf [int64 ]{hPt : hPointSummed [int64 ], perSeriesStartTimeEnabled : true })(t )
48+ assert .True (t , x .PerSeriesStartTimestamps .Enabled ())
49+ testCumulativeHist [int64 ](conf [int64 ]{hPt : hPointSummed [int64 ]})(t )
4750 })
4851 c .Reset ()
4952
5053 t .Run ("Int64/Cumulative/NoSum" , func (t * testing.T ) {
5154 t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "false" )
52- testCumulativeHist [int64 ](conf [int64 ]{noSum : true , hPt : hPoint [int64 ], perSeriesStartTimeEnabled : false })(t )
55+ assert .False (t , x .PerSeriesStartTimestamps .Enabled ())
56+ testCumulativeHist [int64 ](conf [int64 ]{noSum : true , hPt : hPoint [int64 ]})(t )
5357 })
5458 c .Reset ()
5559
5660 t .Run ("Int64/Cumulative/NoSum/PerSeriesStartTimeEnabled" , func (t * testing.T ) {
5761 t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "true" )
58- testCumulativeHist [int64 ](conf [int64 ]{noSum : true , hPt : hPoint [int64 ], perSeriesStartTimeEnabled : true })(t )
62+ assert .True (t , x .PerSeriesStartTimestamps .Enabled ())
63+ testCumulativeHist [int64 ](conf [int64 ]{noSum : true , hPt : hPoint [int64 ]})(t )
5964 })
6065 c .Reset ()
6166
6267 t .Run ("Float64/Cumulative/Sum" , func (t * testing.T ) {
6368 t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "false" )
64- testCumulativeHist [float64 ](conf [float64 ]{hPt : hPointSummed [float64 ], perSeriesStartTimeEnabled : false })(t )
69+ assert .False (t , x .PerSeriesStartTimestamps .Enabled ())
70+ testCumulativeHist [float64 ](conf [float64 ]{hPt : hPointSummed [float64 ]})(t )
6571 })
6672 c .Reset ()
6773
6874 t .Run ("Float64/Cumulative/Sum/PerSeriesStartTimeEnabled" , func (t * testing.T ) {
6975 t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "true" )
70- testCumulativeHist [float64 ](conf [float64 ]{hPt : hPointSummed [float64 ], perSeriesStartTimeEnabled : true })(t )
76+ assert .True (t , x .PerSeriesStartTimestamps .Enabled ())
77+ testCumulativeHist [float64 ](conf [float64 ]{hPt : hPointSummed [float64 ]})(t )
7178 })
7279 c .Reset ()
7380
7481 t .Run ("Float64/Cumulative/NoSum" , func (t * testing.T ) {
7582 t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "false" )
83+ assert .False (t , x .PerSeriesStartTimestamps .Enabled ())
7684 testCumulativeHist [float64 ](
77- conf [float64 ]{noSum : true , hPt : hPoint [float64 ], perSeriesStartTimeEnabled : false },
85+ conf [float64 ]{noSum : true , hPt : hPoint [float64 ]},
7886 )(
7987 t ,
8088 )
@@ -83,8 +91,9 @@ func TestHistogram(t *testing.T) {
8391
8492 t .Run ("Float64/Cumulative/NoSum/PerSeriesStartTimeEnabled" , func (t * testing.T ) {
8593 t .Setenv ("OTEL_GO_X_PER_SERIES_START_TIMESTAMPS" , "true" )
94+ assert .True (t , x .PerSeriesStartTimestamps .Enabled ())
8695 testCumulativeHist [float64 ](
87- conf [float64 ]{noSum : true , hPt : hPoint [float64 ], perSeriesStartTimeEnabled : true },
96+ conf [float64 ]{noSum : true , hPt : hPoint [float64 ]},
8897 )(
8998 t ,
9099 )
@@ -93,9 +102,8 @@ func TestHistogram(t *testing.T) {
93102}
94103
95104type conf [N int64 | float64 ] struct {
96- noSum bool
97- hPt func (attribute.Set , N , uint64 , time.Time , time.Time ) metricdata.HistogramDataPoint [N ]
98- perSeriesStartTimeEnabled bool
105+ noSum bool
106+ hPt func (attribute.Set , N , uint64 , time.Time , time.Time ) metricdata.HistogramDataPoint [N ]
99107}
100108
101109func testDeltaHist [N int64 | float64 ](c conf [N ]) func (t * testing.T ) {
@@ -196,20 +204,10 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
196204 bobStartTime := y2kPlus (0 )
197205 overflowStartTime := y2kPlus (0 )
198206
199- timeStep1 := y2kPlus (2 )
200- timeStep2 := y2kPlus (3 )
201- timeStep3 := y2kPlus (4 )
202- timeStep4 := y2kPlus (5 )
203-
204- if c .perSeriesStartTimeEnabled {
207+ if x .PerSeriesStartTimestamps .Enabled () {
205208 aliceStartTime = y2kPlus (2 )
206209 bobStartTime = y2kPlus (3 )
207210 overflowStartTime = y2kPlus (7 )
208-
209- timeStep1 = y2kPlus (4 )
210- timeStep2 = y2kPlus (5 )
211- timeStep3 = y2kPlus (6 )
212- timeStep4 = y2kPlus (8 )
213211 }
214212
215213 ctx := context .Background ()
@@ -237,8 +235,8 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
237235 agg : metricdata.Histogram [N ]{
238236 Temporality : metricdata .CumulativeTemporality ,
239237 DataPoints : []metricdata.HistogramDataPoint [N ]{
240- c .hPt (fltrAlice , 2 , 3 , aliceStartTime , timeStep1 ),
241- c .hPt (fltrBob , 10 , 2 , bobStartTime , timeStep1 ),
238+ c .hPt (fltrAlice , 2 , 3 , aliceStartTime , y2kPlus ( 4 ) ),
239+ c .hPt (fltrBob , 10 , 2 , bobStartTime , y2kPlus ( 4 ) ),
242240 },
243241 },
244242 },
@@ -253,8 +251,8 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
253251 agg : metricdata.Histogram [N ]{
254252 Temporality : metricdata .CumulativeTemporality ,
255253 DataPoints : []metricdata.HistogramDataPoint [N ]{
256- c .hPt (fltrAlice , 2 , 4 , aliceStartTime , timeStep2 ),
257- c .hPt (fltrBob , 10 , 3 , bobStartTime , timeStep2 ),
254+ c .hPt (fltrAlice , 2 , 4 , aliceStartTime , y2kPlus ( 5 ) ),
255+ c .hPt (fltrBob , 10 , 3 , bobStartTime , y2kPlus ( 5 ) ),
258256 },
259257 },
260258 },
@@ -266,8 +264,8 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
266264 agg : metricdata.Histogram [N ]{
267265 Temporality : metricdata .CumulativeTemporality ,
268266 DataPoints : []metricdata.HistogramDataPoint [N ]{
269- c .hPt (fltrAlice , 2 , 4 , aliceStartTime , timeStep3 ),
270- c .hPt (fltrBob , 10 , 3 , bobStartTime , timeStep3 ),
267+ c .hPt (fltrAlice , 2 , 4 , aliceStartTime , y2kPlus ( 6 ) ),
268+ c .hPt (fltrBob , 10 , 3 , bobStartTime , y2kPlus ( 6 ) ),
271269 },
272270 },
273271 },
@@ -283,9 +281,9 @@ func testCumulativeHist[N int64 | float64](c conf[N]) func(t *testing.T) {
283281 agg : metricdata.Histogram [N ]{
284282 Temporality : metricdata .CumulativeTemporality ,
285283 DataPoints : []metricdata.HistogramDataPoint [N ]{
286- c .hPt (fltrAlice , 2 , 4 , aliceStartTime , timeStep4 ),
287- c .hPt (fltrBob , 10 , 3 , bobStartTime , timeStep4 ),
288- c .hPt (overflowSet , 1 , 2 , overflowStartTime , timeStep4 ),
284+ c .hPt (fltrAlice , 2 , 4 , aliceStartTime , y2kPlus ( 8 ) ),
285+ c .hPt (fltrBob , 10 , 3 , bobStartTime , y2kPlus ( 8 ) ),
286+ c .hPt (overflowSet , 1 , 2 , overflowStartTime , y2kPlus ( 8 ) ),
289287 },
290288 },
291289 },
0 commit comments