Skip to content

Commit 3dac50a

Browse files
Jacob953hanyuancheungAneurysm9
authored
test: --20220112 fix histogram instrument unit test (#2507)
Co-authored-by: Chester Cheung <[email protected]> Co-authored-by: Anthony Mirabella <[email protected]>
1 parent 07ad32d commit 3dac50a

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

exporters/otlp/otlpmetric/exporter_test.go

+53-3
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ func TestNoGroupingExport(t *testing.T) {
225225
)
226226
}
227227

228-
func TestHistogramMetricGroupingExport(t *testing.T) {
228+
func TestHistogramInt64MetricGroupingExport(t *testing.T) {
229229
r := record(
230-
"histogram",
230+
"int64-histogram",
231231
sdkapi.HistogramInstrumentKind,
232232
number.Int64Kind,
233233
append(baseKeyValues, cpuKey.Int(1)),
@@ -240,7 +240,7 @@ func TestHistogramMetricGroupingExport(t *testing.T) {
240240
{
241241
Metrics: []*metricpb.Metric{
242242
{
243-
Name: "histogram",
243+
Name: "int64-histogram",
244244
Data: &metricpb.Metric_Histogram{
245245
Histogram: &metricpb.Histogram{
246246
AggregationTemporality: metricpb.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE,
@@ -275,6 +275,56 @@ func TestHistogramMetricGroupingExport(t *testing.T) {
275275
runMetricExportTests(t, nil, resource.Empty(), []testRecord{r, r}, expected)
276276
}
277277

278+
func TestHistogramFloat64MetricGroupingExport(t *testing.T) {
279+
r := record(
280+
"float64-histogram",
281+
sdkapi.HistogramInstrumentKind,
282+
number.Float64Kind,
283+
append(baseKeyValues, cpuKey.Int(1)),
284+
testLibName,
285+
)
286+
expected := []*metricpb.ResourceMetrics{
287+
{
288+
Resource: nil,
289+
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
290+
{
291+
Metrics: []*metricpb.Metric{
292+
{
293+
Name: "float64-histogram",
294+
Data: &metricpb.Metric_Histogram{
295+
Histogram: &metricpb.Histogram{
296+
AggregationTemporality: metricpb.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE,
297+
DataPoints: []*metricpb.HistogramDataPoint{
298+
{
299+
Attributes: cpu1Labels,
300+
StartTimeUnixNano: startTime(),
301+
TimeUnixNano: pointTime(),
302+
Count: 2,
303+
Sum: 11.0,
304+
ExplicitBounds: testHistogramBoundaries,
305+
BucketCounts: []uint64{1, 0, 0, 1},
306+
},
307+
{
308+
Attributes: cpu1Labels,
309+
Count: 2,
310+
Sum: 11.0,
311+
ExplicitBounds: testHistogramBoundaries,
312+
BucketCounts: []uint64{1, 0, 0, 1},
313+
StartTimeUnixNano: startTime(),
314+
TimeUnixNano: pointTime(),
315+
},
316+
},
317+
},
318+
},
319+
},
320+
},
321+
},
322+
},
323+
},
324+
}
325+
runMetricExportTests(t, nil, resource.Empty(), []testRecord{r, r}, expected)
326+
}
327+
278328
func TestCountInt64MetricGroupingExport(t *testing.T) {
279329
r := record(
280330
"int64-count",

0 commit comments

Comments
 (0)