diff --git a/exporter/stackdriver/stats.go b/exporter/stackdriver/stats.go index cead12f4ffe..340bd6a34eb 100644 --- a/exporter/stackdriver/stats.go +++ b/exporter/stackdriver/stats.go @@ -404,7 +404,7 @@ func equalMeasureAggTagKeys(md *metricpb.MetricDescriptor, m stats.Measure, agg var aggTypeMatch bool switch md.ValueType { case metricpb.MetricDescriptor_INT64: - if _, ok := m.(*stats.Int64Measure); !ok { + if _, ok := m.(*stats.Int64Measure); !(ok || agg.Type == view.AggTypeCount) { return fmt.Errorf("stackdriver metric descriptor was not created as int64") } aggTypeMatch = agg.Type == view.AggTypeCount || agg.Type == view.AggTypeSum || agg.Type == view.AggTypeLastValue diff --git a/exporter/stackdriver/stats_test.go b/exporter/stackdriver/stats_test.go index e4708476fcd..0838e3f4837 100644 --- a/exporter/stackdriver/stats_test.go +++ b/exporter/stackdriver/stats_test.go @@ -424,7 +424,7 @@ func TestEqualAggWindowTagKeys(t *testing.T) { wantErr bool }{ { - name: "count agg", + name: "count agg with in64 measure", md: &metricpb.MetricDescriptor{ MetricKind: metricpb.MetricDescriptor_CUMULATIVE, ValueType: metricpb.MetricDescriptor_INT64, @@ -434,6 +434,17 @@ func TestEqualAggWindowTagKeys(t *testing.T) { agg: view.Count(), wantErr: false, }, + { + name: "count agg with double measure", + md: &metricpb.MetricDescriptor{ + MetricKind: metricpb.MetricDescriptor_CUMULATIVE, + ValueType: metricpb.MetricDescriptor_INT64, + Labels: []*label.LabelDescriptor{{Key: opencensusTaskKey}}, + }, + m: stats.Float64("name", "", ""), + agg: view.Count(), + wantErr: false, + }, { name: "sum agg double", md: &metricpb.MetricDescriptor{