From 6bca0f04a3cf8530c457fae2fb8da5330421f08b Mon Sep 17 00:00:00 2001 From: easy Date: Thu, 15 Aug 2019 11:34:55 +1000 Subject: [PATCH] Use opencensus::tags::TagKey. opencensus::stats::TagKey is deprecated. --- .../registered_opencensus_objects.h | 31 ++++++++++--------- src/cpp/ext/filters/census/grpc_plugin.cc | 17 +++++----- src/cpp/ext/filters/census/grpc_plugin.h | 9 +++--- src/cpp/server/load_reporter/load_reporter.cc | 11 ++++--- src/cpp/server/load_reporter/load_reporter.h | 11 ++++--- 5 files changed, 42 insertions(+), 37 deletions(-) diff --git a/src/core/ext/filters/load_reporting/registered_opencensus_objects.h b/src/core/ext/filters/load_reporting/registered_opencensus_objects.h index 4eacda7c02a..ed11ff42239 100644 --- a/src/core/ext/filters/load_reporting/registered_opencensus_objects.h +++ b/src/core/ext/filters/load_reporting/registered_opencensus_objects.h @@ -22,6 +22,7 @@ #include #include "opencensus/stats/stats.h" +#include "opencensus/tags/tag_key.h" #include "src/cpp/server/load_reporter/constants.h" @@ -80,33 +81,33 @@ inline ::opencensus::stats::MeasureDouble MeasureOtherCallMetric() { // Tags. -inline ::opencensus::stats::TagKey TagKeyToken() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyToken); +inline ::opencensus::tags::TagKey TagKeyToken() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyToken); return token; } -inline ::opencensus::stats::TagKey TagKeyHost() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyHost); +inline ::opencensus::tags::TagKey TagKeyHost() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyHost); return token; } -inline ::opencensus::stats::TagKey TagKeyUserId() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyUserId); +inline ::opencensus::tags::TagKey TagKeyUserId() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyUserId); return token; } -inline ::opencensus::stats::TagKey TagKeyStatus() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyStatus); +inline ::opencensus::tags::TagKey TagKeyStatus() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyStatus); return token; } -inline ::opencensus::stats::TagKey TagKeyMetricName() { - static const ::opencensus::stats::TagKey token = - opencensus::stats::TagKey::Register(kTagKeyMetricName); +inline ::opencensus::tags::TagKey TagKeyMetricName() { + static const ::opencensus::tags::TagKey token = + opencensus::tags::TagKey::Register(kTagKeyMetricName); return token; } diff --git a/src/cpp/ext/filters/census/grpc_plugin.cc b/src/cpp/ext/filters/census/grpc_plugin.cc index c5018f0673a..63d6f1bde48 100644 --- a/src/cpp/ext/filters/census/grpc_plugin.cc +++ b/src/cpp/ext/filters/census/grpc_plugin.cc @@ -22,6 +22,7 @@ #include +#include "opencensus/tags/tag_key.h" #include "opencensus/trace/span.h" #include "src/cpp/ext/filters/census/channel_filter.h" #include "src/cpp/ext/filters/census/client_filter.h" @@ -33,27 +34,27 @@ namespace grpc { // These measure definitions should be kept in sync across opencensus // implementations--see // https://github.com/census-instrumentation/opencensus-java/blob/master/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstants.java. -::opencensus::stats::TagKey ClientMethodTagKey() { +::opencensus::tags::TagKey ClientMethodTagKey() { static const auto method_tag_key = - ::opencensus::stats::TagKey::Register("grpc_client_method"); + ::opencensus::tags::TagKey::Register("grpc_client_method"); return method_tag_key; } -::opencensus::stats::TagKey ClientStatusTagKey() { +::opencensus::tags::TagKey ClientStatusTagKey() { static const auto status_tag_key = - ::opencensus::stats::TagKey::Register("grpc_client_status"); + ::opencensus::tags::TagKey::Register("grpc_client_status"); return status_tag_key; } -::opencensus::stats::TagKey ServerMethodTagKey() { +::opencensus::tags::TagKey ServerMethodTagKey() { static const auto method_tag_key = - ::opencensus::stats::TagKey::Register("grpc_server_method"); + ::opencensus::tags::TagKey::Register("grpc_server_method"); return method_tag_key; } -::opencensus::stats::TagKey ServerStatusTagKey() { +::opencensus::tags::TagKey ServerStatusTagKey() { static const auto status_tag_key = - ::opencensus::stats::TagKey::Register("grpc_server_status"); + ::opencensus::tags::TagKey::Register("grpc_server_status"); return status_tag_key; } diff --git a/src/cpp/ext/filters/census/grpc_plugin.h b/src/cpp/ext/filters/census/grpc_plugin.h index 13176759e37..14f2481681d 100644 --- a/src/cpp/ext/filters/census/grpc_plugin.h +++ b/src/cpp/ext/filters/census/grpc_plugin.h @@ -24,6 +24,7 @@ #include "absl/strings/string_view.h" #include "include/grpcpp/opencensus.h" #include "opencensus/stats/stats.h" +#include "opencensus/tags/tag_key.h" namespace grpc_impl { class ServerContext; @@ -32,10 +33,10 @@ class ServerContext; namespace grpc { // The tag keys set when recording RPC stats. -::opencensus::stats::TagKey ClientMethodTagKey(); -::opencensus::stats::TagKey ClientStatusTagKey(); -::opencensus::stats::TagKey ServerMethodTagKey(); -::opencensus::stats::TagKey ServerStatusTagKey(); +::opencensus::tags::TagKey ClientMethodTagKey(); +::opencensus::tags::TagKey ClientStatusTagKey(); +::opencensus::tags::TagKey ServerMethodTagKey(); +::opencensus::tags::TagKey ServerStatusTagKey(); // Names of measures used by the plugin--users can create views on these // measures but should not record data for them. diff --git a/src/cpp/server/load_reporter/load_reporter.cc b/src/cpp/server/load_reporter/load_reporter.cc index 422ea62efd5..b4c5e57c354 100644 --- a/src/cpp/server/load_reporter/load_reporter.cc +++ b/src/cpp/server/load_reporter/load_reporter.cc @@ -29,6 +29,7 @@ #include "src/cpp/server/load_reporter/load_reporter.h" #include "opencensus/stats/internal/set_aggregation_window.h" +#include "opencensus/tags/tag_key.h" namespace grpc { namespace load_reporter { @@ -38,12 +39,12 @@ CpuStatsProvider::CpuStatsSample CpuStatsProviderDefaultImpl::GetCpuStats() { } CensusViewProvider::CensusViewProvider() - : tag_key_token_(::opencensus::stats::TagKey::Register(kTagKeyToken)), - tag_key_host_(::opencensus::stats::TagKey::Register(kTagKeyHost)), - tag_key_user_id_(::opencensus::stats::TagKey::Register(kTagKeyUserId)), - tag_key_status_(::opencensus::stats::TagKey::Register(kTagKeyStatus)), + : tag_key_token_(::opencensus::tags::TagKey::Register(kTagKeyToken)), + tag_key_host_(::opencensus::tags::TagKey::Register(kTagKeyHost)), + tag_key_user_id_(::opencensus::tags::TagKey::Register(kTagKeyUserId)), + tag_key_status_(::opencensus::tags::TagKey::Register(kTagKeyStatus)), tag_key_metric_name_( - ::opencensus::stats::TagKey::Register(kTagKeyMetricName)) { + ::opencensus::tags::TagKey::Register(kTagKeyMetricName)) { // One view related to starting a call. auto vd_start_count = ::opencensus::stats::ViewDescriptor() diff --git a/src/cpp/server/load_reporter/load_reporter.h b/src/cpp/server/load_reporter/load_reporter.h index 766e02a407a..44767ee841e 100644 --- a/src/cpp/server/load_reporter/load_reporter.h +++ b/src/cpp/server/load_reporter/load_reporter.h @@ -34,6 +34,7 @@ #include "src/proto/grpc/lb/v1/load_reporter.grpc.pb.h" #include "opencensus/stats/stats.h" +#include "opencensus/tags/tag_key.h" namespace grpc { namespace load_reporter { @@ -75,11 +76,11 @@ class CensusViewProvider { private: ViewDescriptorMap view_descriptor_map_; // Tag keys. - ::opencensus::stats::TagKey tag_key_token_; - ::opencensus::stats::TagKey tag_key_host_; - ::opencensus::stats::TagKey tag_key_user_id_; - ::opencensus::stats::TagKey tag_key_status_; - ::opencensus::stats::TagKey tag_key_metric_name_; + ::opencensus::tags::TagKey tag_key_token_; + ::opencensus::tags::TagKey tag_key_host_; + ::opencensus::tags::TagKey tag_key_user_id_; + ::opencensus::tags::TagKey tag_key_status_; + ::opencensus::tags::TagKey tag_key_metric_name_; }; // The default implementation fetches the real stats from Census.