-
Notifications
You must be signed in to change notification settings - Fork 326
Check if Stackdriver MetricDescriptor is compatible with the view #162
Conversation
a = &stats.DistributionAggregation{} | ||
} | ||
|
||
if reflect.TypeOf(agg) != reflect.TypeOf(a) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also check whether agg is a pointer or not, or disallow concrete types to be passed as aggregators.
if reflect.TypeOf(agg) != reflect.TypeOf(a) { | ||
return false | ||
} | ||
if reflect.TypeOf(window) != reflect.TypeOf(w) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, though I think we also need to check the label descriptors of MetricDescriptor if it exisits. Uploading TimeSeries with missing labels will also introduce an error.
54313eb
to
40abbb2
Compare
Added the labels, and addressed the concrete type vs pointers. |
@@ -189,26 +191,36 @@ func (e *Exporter) makeReq(vds []*stats.ViewData) *monitoringpb.CreateTimeSeries | |||
} | |||
} | |||
|
|||
// createMeasure creates a MetricDescriptor for the given view data in Stackdriver Monitoring. | |||
// If there is already a metric descriptor created with the same name | |||
// and the metric descriptor has a different aggregation/window, it returns an error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: aggregation/window -> aggregation/window/tag keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
_, ok := e.createdViews[viewName] | ||
if ok { | ||
if md, ok := e.createdViews[viewName]; ok { | ||
// Check agg and window. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: and tag keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
}) | ||
if err := equalAggWindowTagKeys(md, agg, window, tagKeys); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call to equalAggWindowTagKeys should be moved inside the "if err == nil" block below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…nterceptor and exporter are enabled (census-instrumentation#162)
Fixes #146.