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

Remove interface for exporting ViewData

Open songy23 opened this issue 6 years ago • 6 comments

A placeholder for rolling forward #188.

songy23 avatar Aug 30 '19 19:08 songy23

Can we install the metrics exporter instead of the viewdata for the users, so we keep the public API?

At least I would like to avoid duplicate code to translate from viewdata to SD metrics and metrics data to Sd

bogdandrutu avatar Aug 30 '19 19:08 bogdandrutu

The major problem is for now lots of users still do

view.RegisterExporter(stackdriverExporter)

That requires Stackdriver exporter to implement the interface ExportView(viewData *Data) (https://godoc.org/go.opencensus.io/stats/view#Exporter). If we just remove this interface from Stackdriver exporter, the above code will break. We can translate View.Data to Metric under the hood though I don't see that simplifies things a lot (still need to add the mapping from View.Data to Metric).

songy23 avatar Aug 30 '19 19:08 songy23

The mapping is already implemented in the opencensus we can re-use that.

bogdandrutu avatar Aug 30 '19 19:08 bogdandrutu

We have a mapping from the internal representation of ViewData (called viewInternal) to Metric: https://github.com/census-instrumentation/opencensus-go/blob/29aa3cabbf25be9f1c3c6d78cecfbe0c3e20cf5a/stats/view/view_to_metric.go#L128-L149. (This method and viewInternal are not exposed btw). However we don't currently have a method to directly convert ViewData to Metric that we can reuse here.

In addition I think the performance of ExportView will get worse if we do that, because it added an extra intermediate step (ViewData -> SDMetric vs. ViewData -> Metric -> SDMetric).

songy23 avatar Aug 30 '19 19:08 songy23

Oh my...

I've spent more than a week to investigate why we have an excessive export issue in our code base and I just realized we called both view.RegisterExporter(stackdriverExporter) and exporter.StartMetricsExporter() somehow.

If we can't remove the view.Exporter interface, can we at least add a warning log when both view.RegisterExporter and exporter.StartMetricsExporter are used?

yegle avatar Sep 28 '20 23:09 yegle

And FWIW, the official guide on writing a metric exporter still uses view.Exporter interface: https://opencensus.io/exporters/custom-exporter/go/metrics/

yegle avatar Sep 29 '20 00:09 yegle