I was able to write a small Go program that uses OpenCensus to send metrics to Google Cloud Monitoring (formerly known as Stackdriver Monitoring) using this exporter.
I found it strange that the documentation at https://pkg.go.dev/contrib.go.opencensus.io/exporter/stackdriver#Exporter.StartMetricsExporter says:
Previously, it required registering exporter to export stats collected by opencensus. ... Now, it requires to call StartMetricsExporter() to export stats and metrics collected by opencensus.
It shows a code example that demonstrates that the "new way" to register the exporter is to use the following code:
exporter := stackdriver.NewExporter(stackdriver.Option{})
exporter.StartMetricsExporter()
defer exporter.StopMetricsExporter()
I was under the impression that view.RegisterExporter was the key to linking the OpenCensus views you register to the exporter(s) you choose to use. In the documentation about creating a custom exporter at https://opencensus.io/exporters/custom-exporter/go/metrics/ it says that you are supposed to use view.RegisterExporter to activate the custom exporter you write. This also reinforces the idea to me that view.RegisterExporter is important.
Why does this work without doing this step? And if this is second way is the suggested way of doing it, why was it changed?