Closed zargarpur closed 4 years ago
/assign @nilebox
Looks like start and end times are the same, and Stackdriver rejects such counter?
AFAICT the start and end times are coming from the view.Data
structure: https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/blob/1905f4643248273f1ed512fdf1b6473d2e4445b4/stats.go#L249
They are set in https://github.com/census-instrumentation/opencensus-go/blob/1901b56b9515b0c34f5d25a5bce982dfc543d64b/stats/view/worker.go#L352-L353
And there is a condition under which both Start
and End
will be set to "now":
https://github.com/census-instrumentation/opencensus-go/blob/1901b56b9515b0c34f5d25a5bce982dfc543d64b/stats/view/worker.go#L346-L349
This is likely what is causing the problem for you.
Potential ways to fix the issue:
opencensus-go
: prevent setting both start and end times to "now" for non-gaugesopencensus-go-exporter-stackdriver
: Implement some hack to add a nanosecond to make start and end times different - this may break the accuracy thoughopencensus-go-exporter-stackdriver
: Drop views which have equal start and end times - this leads to data lossNot sure if there is a good way to fix that.
/cc @james-bebbington @rghetia
In opencensus-go, could start be set either during view registration or initial record?
Currently, the startTimes
map is initialized as empty and the initial startTime is set on the first export in https://github.com/census-instrumentation/opencensus-go/blob/1901b56b9515b0c34f5d25a5bce982dfc543d64b/stats/view/worker.go#L346-L349
We should be able to init start time when handling view registration in https://github.com/census-instrumentation/opencensus-go/blob/785d8992f1ac50097e9140accb05630e0eadfb5e/stats/view/worker.go#L295
@zargarpur @ian-mi Feel free to send a PR with a fix to https://github.com/census-instrumentation/opencensus-go/ as described in https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/issues/266#issuecomment-645068812, or I will get back to it myself within a few days.
Released opencensus-go v0.22.4 with the bugfix.
What version of the Exporter are you using?
contrib.go.opencensus.io/exporter/stackdriver => contrib.go.opencensus.io/exporter/stackdriver v0.12.9-0.20191108183826-59d068f8d8ff
What version of OpenCensus are you using?
go.opencensus.io => go.opencensus.io v0.22.1
What version of Go are you using?
go version go1.14.2 linux/amd64
What did you do?
We have that count metric here https://github.com/google/knative-gcp/blob/d0a452483985c0f1d775efa2ea54fddaed2ed107/pkg/metrics/ingress_reporter.go#L59
Invoked here https://github.com/google/knative-gcp/blob/d0a452483985c0f1d775efa2ea54fddaed2ed107/pkg/metrics/ingress_reporter.go#L103
And we're seeing this error occasionally in our E2E tests that prevents our metrics from being uploaded
If possible, provide a recipe for reproducing the error. We have a continuous E2E test runs that occasionally run into this issue which is exercising the code path above https://testgrid.knative.dev/knative-gcp#continuous&include-filter-by-regex=TestGCPBrokerMetrics
What did you expect to see?
Metrics consistently uploaded to Stackdriver without this error
What did you see instead?
This error message
Additional context
Add any other context about the problem here.