stopOpenCensus flushes the exporter's and cleans up globals across all packages if exporter was created.
()
| 160 | // stopOpenCensus flushes the exporter's and cleans up globals across all |
| 161 | // packages if exporter was created. |
| 162 | func stopOpenCensus() { |
| 163 | if exporter != nil { |
| 164 | internal.ClearGlobalDialOptions() |
| 165 | internal.ClearGlobalServerOptions() |
| 166 | // This Unregister call guarantees the data recorded gets sent to |
| 167 | // exporter, synchronising the view package and exporter. Doesn't matter |
| 168 | // if views not registered, will be a noop if not registered. |
| 169 | view.Unregister(defaultViews...) |
| 170 | // Call these unconditionally, doesn't matter if not registered, will be |
| 171 | // a noop if not registered. |
| 172 | trace.UnregisterExporter(exporter) |
| 173 | view.UnregisterExporter(exporter) |
| 174 | |
| 175 | // This Flush call makes sure recorded telemetry get sent to backend. |
| 176 | exporter.Flush() |
| 177 | exporter.Close() |
| 178 | } |
| 179 | } |