Skip to content

Commit

Permalink
Fix equalMeasureAggTagKeys for Stackdriver exporter. (googleapis#685)
Browse files Browse the repository at this point in the history
Fixes census-instrumentation/opencensus-go#683.

Count aggregation will always be exported as INT64 MetricDescriptor, no
matter whether Measure is INT64 or FLOAT64.
  • Loading branch information
songy23 committed Apr 6, 2018
1 parent 2948f62 commit 53ede72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion exporter/stackdriver/stats.go
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion exporter/stackdriver/stats_test.go
Expand Up @@ -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,
Expand All @@ -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{
Expand Down

0 comments on commit 53ede72

Please sign in to comment.