census-ecosystem / opencensus-go-exporter-stackdriver

OpenCensus Go exporter for Stackdriver Monitoring and Trace
Apache License 2.0
67 stars 79 forks source link

MetricDescriptor should be created as soon as the view is registered #281

Open yegle opened 3 years ago

yegle commented 3 years ago

Please answer these questions before submitting a bug report.

What version of the Exporter are you using?

0.13.4

What version of OpenCensus are you using?

0.22.5

What version of Go are you using?

1.15.7

What did you do?

We have a metric that are only recorded rarely. (i.e. the call to stat.Record() is in an if-statement and rarely reached). The metric may not get recorded for days.

What did you expect to see?

Regardless of how frequently the data point is produced, the MetricDescriptor is created ~instantly after the views are generated.

What did you see instead?

The MetricDescriptor is not created long after the new metric is added.

Additional context

I created https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/pull/277 to try to manage the MetricDescriptor by ourselves, but I think the root issue is the delayed MetricDescriptor.

miroslavLalev commented 3 years ago

Any update on this? We also have the same problem and would love for it to be fixed, as we try to create Stackdriver alerts for the metrics.

yegle commented 3 years ago

FWIW this is our workaround (StartExporter will be called during server startup): https://github.com/google/exposure-notifications-server/blob/7841200f6face7b648944be241362218d6f04588/pkg/observability/stackdriver.go#L116-L127

miroslavLalev commented 3 years ago

Hey, thanks for the idea! I did not check what is exported from the package and what isn't. We will give this approach a shot, but sadly, it is awkward to implement because conventionally, the views are separated from the exporters.