[Stats] fix stats shutdown crash if opencensus exporter not initialized (#9727)

This commit is contained in:
Lingxuan Zuo
2020-07-28 11:21:10 +08:00
committed by GitHub
parent 914cc96c91
commit 1049c9e53b
+4
View File
@@ -103,6 +103,10 @@ static inline void Init(const TagsType &global_tags, const int metrics_agent_por
static inline void Shutdown() {
// TODO(sang): Harvest thread is not currently cleaned up.
absl::MutexLock lock(&stats_mutex);
if (!StatsConfig::instance().IsInitialized()) {
// Return if stats had never been initialized.
return;
}
metrics_io_service_pool->Stop();
opencensus::stats::StatsExporter::Shutdown();
metrics_io_service_pool = nullptr;