mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-12 02:28:07 +02:00
test: --20220112 fix histogram instrument unit test (#2507)
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com> Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
This commit is contained in:
parent
07ad32dc38
commit
3dac50a968
@ -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)),
|
||||
@ -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,
|
||||
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user