Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test units of histogram instrument kind #2507

Merged
merged 10 commits into from Mar 23, 2022
56 changes: 53 additions & 3 deletions exporters/otlp/otlpmetric/exporter_test.go
Expand Up @@ -225,9 +225,9 @@ func TestNoGroupingExport(t *testing.T) {
)
}

func TestHistogramMetricGroupingExport(t *testing.T) {
func TestHistogramInt64MetricGroupingExport(t *testing.T) {
r := record(
"histogram",
"int64-histogram",
sdkapi.HistogramInstrumentKind,
number.Int64Kind,
append(baseKeyValues, cpuKey.Int(1)),
Expand All @@ -240,7 +240,7 @@ func TestHistogramMetricGroupingExport(t *testing.T) {
{
Metrics: []*metricpb.Metric{
{
Name: "histogram",
Name: "int64-histogram",
Data: &metricpb.Metric_Histogram{
Histogram: &metricpb.Histogram{
AggregationTemporality: metricpb.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE,
Expand Down Expand Up @@ -275,6 +275,56 @@ func TestHistogramMetricGroupingExport(t *testing.T) {
runMetricExportTests(t, nil, resource.Empty(), []testRecord{r, r}, expected)
}

func TestHistogramFloat64MetricGroupingExport(t *testing.T) {
r := record(
"float64-histogram",
sdkapi.HistogramInstrumentKind,
number.Float64Kind,
append(baseKeyValues, cpuKey.Int(1)),
testLibName,
)
expected := []*metricpb.ResourceMetrics{
{
Resource: nil,
InstrumentationLibraryMetrics: []*metricpb.InstrumentationLibraryMetrics{
{
Metrics: []*metricpb.Metric{
{
Name: "float64-histogram",
Data: &metricpb.Metric_Histogram{
Histogram: &metricpb.Histogram{
AggregationTemporality: metricpb.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE,
DataPoints: []*metricpb.HistogramDataPoint{
{
Attributes: cpu1Labels,
StartTimeUnixNano: startTime(),
TimeUnixNano: pointTime(),
Count: 2,
Sum: 11.0,
ExplicitBounds: testHistogramBoundaries,
BucketCounts: []uint64{1, 0, 0, 1},
},
{
Attributes: cpu1Labels,
Count: 2,
Sum: 11.0,
ExplicitBounds: testHistogramBoundaries,
BucketCounts: []uint64{1, 0, 0, 1},
StartTimeUnixNano: startTime(),
TimeUnixNano: pointTime(),
},
},
},
},
},
},
},
},
},
}
runMetricExportTests(t, nil, resource.Empty(), []testRecord{r, r}, expected)
}

func TestCountInt64MetricGroupingExport(t *testing.T) {
r := record(
"int64-count",
Expand Down