|
|
@ -120,27 +120,30 @@ void GlobalStatsPluginRegistry::StatsPluginGroup::AddServerCallTracers( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NoDestruct<Mutex> GlobalStatsPluginRegistry::mutex_; |
|
|
|
std::atomic<GlobalStatsPluginRegistry::GlobalStatsPluginNode*> |
|
|
|
NoDestruct<std::vector<std::shared_ptr<StatsPlugin>>> |
|
|
|
|
|
|
|
GlobalStatsPluginRegistry::plugins_; |
|
|
|
GlobalStatsPluginRegistry::plugins_; |
|
|
|
|
|
|
|
|
|
|
|
void GlobalStatsPluginRegistry::RegisterStatsPlugin( |
|
|
|
void GlobalStatsPluginRegistry::RegisterStatsPlugin( |
|
|
|
std::shared_ptr<StatsPlugin> plugin) { |
|
|
|
std::shared_ptr<StatsPlugin> plugin) { |
|
|
|
MutexLock lock(&*mutex_); |
|
|
|
GlobalStatsPluginNode* node = new GlobalStatsPluginNode(); |
|
|
|
plugins_->push_back(std::move(plugin)); |
|
|
|
node->plugin = std::move(plugin); |
|
|
|
|
|
|
|
node->next = plugins_.load(std::memory_order_relaxed); |
|
|
|
|
|
|
|
while (!plugins_.compare_exchange_weak( |
|
|
|
|
|
|
|
node->next, node, std::memory_order_acq_rel, std::memory_order_relaxed)) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GlobalStatsPluginRegistry::StatsPluginGroup |
|
|
|
GlobalStatsPluginRegistry::StatsPluginGroup |
|
|
|
GlobalStatsPluginRegistry::GetStatsPluginsForChannel( |
|
|
|
GlobalStatsPluginRegistry::GetStatsPluginsForChannel( |
|
|
|
const experimental::StatsPluginChannelScope& scope) { |
|
|
|
const experimental::StatsPluginChannelScope& scope) { |
|
|
|
MutexLock lock(&*mutex_); |
|
|
|
|
|
|
|
StatsPluginGroup group; |
|
|
|
StatsPluginGroup group; |
|
|
|
for (const auto& plugin : *plugins_) { |
|
|
|
for (GlobalStatsPluginNode* node = plugins_.load(std::memory_order_acquire); |
|
|
|
|
|
|
|
node != nullptr; node = node->next) { |
|
|
|
bool is_enabled = false; |
|
|
|
bool is_enabled = false; |
|
|
|
std::shared_ptr<StatsPlugin::ScopeConfig> config; |
|
|
|
std::shared_ptr<StatsPlugin::ScopeConfig> config; |
|
|
|
std::tie(is_enabled, config) = plugin->IsEnabledForChannel(scope); |
|
|
|
std::tie(is_enabled, config) = node->plugin->IsEnabledForChannel(scope); |
|
|
|
if (is_enabled) { |
|
|
|
if (is_enabled) { |
|
|
|
group.AddStatsPlugin(plugin, std::move(config)); |
|
|
|
group.AddStatsPlugin(node->plugin, std::move(config)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return group; |
|
|
|
return group; |
|
|
@ -148,14 +151,14 @@ GlobalStatsPluginRegistry::GetStatsPluginsForChannel( |
|
|
|
|
|
|
|
|
|
|
|
GlobalStatsPluginRegistry::StatsPluginGroup |
|
|
|
GlobalStatsPluginRegistry::StatsPluginGroup |
|
|
|
GlobalStatsPluginRegistry::GetStatsPluginsForServer(const ChannelArgs& args) { |
|
|
|
GlobalStatsPluginRegistry::GetStatsPluginsForServer(const ChannelArgs& args) { |
|
|
|
MutexLock lock(&*mutex_); |
|
|
|
|
|
|
|
StatsPluginGroup group; |
|
|
|
StatsPluginGroup group; |
|
|
|
for (const auto& plugin : *plugins_) { |
|
|
|
for (GlobalStatsPluginNode* node = plugins_.load(std::memory_order_acquire); |
|
|
|
|
|
|
|
node != nullptr; node = node->next) { |
|
|
|
bool is_enabled = false; |
|
|
|
bool is_enabled = false; |
|
|
|
std::shared_ptr<StatsPlugin::ScopeConfig> config; |
|
|
|
std::shared_ptr<StatsPlugin::ScopeConfig> config; |
|
|
|
std::tie(is_enabled, config) = plugin->IsEnabledForServer(args); |
|
|
|
std::tie(is_enabled, config) = node->plugin->IsEnabledForServer(args); |
|
|
|
if (is_enabled) { |
|
|
|
if (is_enabled) { |
|
|
|
group.AddStatsPlugin(plugin, std::move(config)); |
|
|
|
group.AddStatsPlugin(node->plugin, std::move(config)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return group; |
|
|
|
return group; |
|
|
|