opencensus-go-exporter-stackdriver icon indicating copy to clipboard operation
opencensus-go-exporter-stackdriver copied to clipboard

Distribution with zero buckets results in CreateTimeSeries 400 response

Open ascherkus opened this issue 5 years ago • 2 comments

Please answer these questions before submitting a bug report.

What version of the Exporter are you using?

2fdcf7b4087e713a439fe7a489b3c316deaa97f2 v0.12.7

What version of OpenCensus are you using?

9c377598961b706d1542bd2d84d538b5094d596e v0.22.0

What version of Go are you using?

go version go1.12.12 darwin/amd64

What did you do?

Attempted to create a distribution metric and view and export to Stackdriver.

mExample := stats.Int64("example", "example distribution in milliseconds", "ms")
v := &view.View{
  Name: "example"
  Measure: mExample,
  Description: "example description",
  Aggregation: view.Distribution(),
}

What did you expect to see?

Distribution stats uploaded and visible in Stackdriver.

What did you see instead?

400 errors for CreateTimeSeries on the API dashboard: https://console.cloud.google.com/apis/api/monitoring.googleapis.com/metrics

... and the following logs: 2019/11/01 15:41:32.278782 stackdriver.go:421: Failed to export to Stackdriver: rpc error: code = InvalidArgument desc = Field timeSeries[1].points[0].distributionValue had an invalid value: Distribution |explicit_buckets.bounds| does not have at least one entry.

Additional context

Curious whether this is by design or not -- based on the documentation for view.Distribution() it's permissible to not specify any buckets:

// Distribution indicates that the desired aggregation is
// a histogram distribution.
//
// An distribution aggregation may contain a histogram of the values in the
// population. The bucket boundaries for that histogram are described
// by the bounds. This defines len(bounds)+1 buckets.
//
// If len(bounds) >= 2 then the boundaries for bucket index i are:
//
//     [-infinity, bounds[i]) for i = 0
//     [bounds[i-1], bounds[i]) for 0 < i < length
//     [bounds[i-1], +infinity) for i = length
//
// If len(bounds) is 0 then there is no histogram associated with the
// distribution. There will be a single bucket with boundaries
// (-infinity, +infinity).
//
// If len(bounds) is 1 then there is no finite buckets, and that single
// element is the common boundary of the overflow and underflow buckets.

Is there a possible bug here where the (-infinity, +infinity) bucket isn't created when exporting to Stackdriver?

ascherkus avatar Nov 01 '19 15:11 ascherkus

@ascherkus you are probably hitting https://github.com/census-instrumentation/opencensus-go/issues/1169. Can you upgrade to opencensus version v0.22.2?

rghetia avatar Dec 02 '19 22:12 rghetia

@ascherkus any update?

rghetia avatar Dec 20 '19 22:12 rghetia