OpenCensus: Fix data race (#31255)

pull/31249/head^2
Yash Tibrewal 2 years ago committed by GitHub
parent c802adfa8a
commit 0469b1ea68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/cpp/ext/filters/census/grpc_plugin.cc

@ -22,6 +22,8 @@
#include <limits.h>
#include <atomic>
#include "absl/base/attributes.h"
#include "opencensus/tags/tag_key.h"
#include "opencensus/trace/span.h"
@ -161,8 +163,8 @@ ABSL_CONST_INIT const absl::string_view kRpcServerServerLatencyMeasureName =
ABSL_CONST_INIT const absl::string_view kRpcServerStartedRpcsMeasureName =
"grpc.io/server/started_rpcs";
bool g_open_census_stats_enabled = true;
bool g_open_census_tracing_enabled = true;
std::atomic<bool> g_open_census_stats_enabled(true);
std::atomic<bool> g_open_census_tracing_enabled(true);
void EnableOpenCensusStats(bool enable) {
g_open_census_stats_enabled = enable;
@ -172,8 +174,12 @@ void EnableOpenCensusTracing(bool enable) {
g_open_census_tracing_enabled = enable;
}
bool OpenCensusStatsEnabled() { return g_open_census_stats_enabled; }
bool OpenCensusStatsEnabled() {
return g_open_census_stats_enabled.load(std::memory_order_relaxed);
}
bool OpenCensusTracingEnabled() { return g_open_census_tracing_enabled; }
bool OpenCensusTracingEnabled() {
return g_open_census_tracing_enabled.load(std::memory_order_relaxed);
}
} // namespace grpc

Loading…
Cancel
Save