From 63f5e93aebe772d2f1b2948ef22f3e7b474ee860 Mon Sep 17 00:00:00 2001 From: Long Dai Date: Thu, 3 Jun 2021 00:39:35 -0700 Subject: [PATCH 1/6] stat_sinks: remove well_known_names Signed-off-by: Long Dai --- source/extensions/stat_sinks/BUILD | 11 ----------- source/extensions/stat_sinks/dog_statsd/BUILD | 1 - source/extensions/stat_sinks/dog_statsd/config.cc | 3 +-- source/extensions/stat_sinks/hystrix/BUILD | 1 - source/extensions/stat_sinks/hystrix/config.cc | 3 +-- source/extensions/stat_sinks/metrics_service/BUILD | 1 - .../extensions/stat_sinks/metrics_service/config.cc | 3 +-- source/extensions/stat_sinks/statsd/BUILD | 1 - source/extensions/stat_sinks/statsd/config.cc | 3 +-- source/extensions/stat_sinks/wasm/BUILD | 1 - source/extensions/stat_sinks/wasm/config.cc | 3 +-- .../stats_sinks/dog_statsd/config_test.cc | 9 ++++----- test/extensions/stats_sinks/hystrix/config_test.cc | 3 +-- test/extensions/stats_sinks/statsd/config_test.cc | 13 ++++++------- test/extensions/stats_sinks/wasm/config_test.cc | 3 +-- test/server/configuration_impl_test.cc | 3 +-- 16 files changed, 18 insertions(+), 44 deletions(-) diff --git a/source/extensions/stat_sinks/BUILD b/source/extensions/stat_sinks/BUILD index 40a5e79b39d3..90e061ad8da3 100644 --- a/source/extensions/stat_sinks/BUILD +++ b/source/extensions/stat_sinks/BUILD @@ -1,19 +1,8 @@ load( "//bazel:envoy_build_system.bzl", - "envoy_cc_library", "envoy_extension_package", ) licenses(["notice"]) # Apache 2 envoy_extension_package() - -envoy_cc_library( - name = "well_known_names", - hdrs = ["well_known_names.h"], - # well known names files are public as long as they exist. - visibility = ["//visibility:public"], - deps = [ - "//source/common/singleton:const_singleton", - ], -) diff --git a/source/extensions/stat_sinks/dog_statsd/BUILD b/source/extensions/stat_sinks/dog_statsd/BUILD index ce75b191dedd..5c62fcc58f0a 100644 --- a/source/extensions/stat_sinks/dog_statsd/BUILD +++ b/source/extensions/stat_sinks/dog_statsd/BUILD @@ -19,7 +19,6 @@ envoy_cc_extension( "//envoy/registry", "//source/common/network:address_lib", "//source/common/network:resolver_lib", - "//source/extensions/stat_sinks:well_known_names", "//source/extensions/stat_sinks/common/statsd:statsd_lib", "//source/server:configuration_lib", "@envoy_api//envoy/config/metrics/v3:pkg_cc_proto", diff --git a/source/extensions/stat_sinks/dog_statsd/config.cc b/source/extensions/stat_sinks/dog_statsd/config.cc index e31ac22f68e1..28a58a212ce7 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.cc +++ b/source/extensions/stat_sinks/dog_statsd/config.cc @@ -8,7 +8,6 @@ #include "source/common/network/resolver_impl.h" #include "source/extensions/stat_sinks/common/statsd/statsd.h" -#include "source/extensions/stat_sinks/well_known_names.h" #include "absl/types/optional.h" @@ -38,7 +37,7 @@ ProtobufTypes::MessagePtr DogStatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string DogStatsdSinkFactory::name() const { return StatsSinkNames::get().DogStatsd; } +std::string DogStatsdSinkFactory::name() const { return "envoy.stat_sinks.dog_statsd"; } /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/hystrix/BUILD b/source/extensions/stat_sinks/hystrix/BUILD index 3908e49d3272..25a1ffa4a49f 100644 --- a/source/extensions/stat_sinks/hystrix/BUILD +++ b/source/extensions/stat_sinks/hystrix/BUILD @@ -20,7 +20,6 @@ envoy_cc_extension( "//envoy/registry", "//source/common/network:address_lib", "//source/common/network:resolver_lib", - "//source/extensions/stat_sinks:well_known_names", "//source/server:configuration_lib", "@envoy_api//envoy/config/metrics/v3:pkg_cc_proto", ], diff --git a/source/extensions/stat_sinks/hystrix/config.cc b/source/extensions/stat_sinks/hystrix/config.cc index b9ae021fb9af..684ce1cd873a 100644 --- a/source/extensions/stat_sinks/hystrix/config.cc +++ b/source/extensions/stat_sinks/hystrix/config.cc @@ -8,7 +8,6 @@ #include "source/common/network/resolver_impl.h" #include "source/extensions/stat_sinks/hystrix/hystrix.h" -#include "source/extensions/stat_sinks/well_known_names.h" namespace Envoy { namespace Extensions { @@ -28,7 +27,7 @@ ProtobufTypes::MessagePtr HystrixSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string HystrixSinkFactory::name() const { return StatsSinkNames::get().Hystrix; } +std::string HystrixSinkFactory::name() const { return "envoy.stat_sinks.hystrix"; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/metrics_service/BUILD b/source/extensions/stat_sinks/metrics_service/BUILD index 11ffe31b018a..97d79e032f03 100644 --- a/source/extensions/stat_sinks/metrics_service/BUILD +++ b/source/extensions/stat_sinks/metrics_service/BUILD @@ -47,7 +47,6 @@ envoy_cc_extension( "//envoy/registry", "//source/common/common:assert_lib", "//source/common/config:utility_lib", - "//source/extensions/stat_sinks:well_known_names", "//source/extensions/stat_sinks/metrics_service:metrics_proto_descriptors_lib", "//source/extensions/stat_sinks/metrics_service:metrics_service_grpc_lib", "//source/server:configuration_lib", diff --git a/source/extensions/stat_sinks/metrics_service/config.cc b/source/extensions/stat_sinks/metrics_service/config.cc index ad34c75e6305..83976a07c2e9 100644 --- a/source/extensions/stat_sinks/metrics_service/config.cc +++ b/source/extensions/stat_sinks/metrics_service/config.cc @@ -10,7 +10,6 @@ #include "source/common/network/resolver_impl.h" #include "source/extensions/stat_sinks/metrics_service/grpc_metrics_proto_descriptors.h" #include "source/extensions/stat_sinks/metrics_service/grpc_metrics_service_impl.h" -#include "source/extensions/stat_sinks/well_known_names.h" namespace Envoy { namespace Extensions { @@ -48,7 +47,7 @@ ProtobufTypes::MessagePtr MetricsServiceSinkFactory::createEmptyConfigProto() { std::make_unique()); } -std::string MetricsServiceSinkFactory::name() const { return StatsSinkNames::get().MetricsService; } +std::string MetricsServiceSinkFactory::name() const { return "envoy.stat_sinks.metrics_service"; } /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/statsd/BUILD b/source/extensions/stat_sinks/statsd/BUILD index 8ac0182eba9d..1443316f7151 100644 --- a/source/extensions/stat_sinks/statsd/BUILD +++ b/source/extensions/stat_sinks/statsd/BUILD @@ -19,7 +19,6 @@ envoy_cc_extension( "//envoy/registry", "//source/common/network:address_lib", "//source/common/network:resolver_lib", - "//source/extensions/stat_sinks:well_known_names", "//source/extensions/stat_sinks/common/statsd:statsd_lib", "//source/server:configuration_lib", "@envoy_api//envoy/config/metrics/v3:pkg_cc_proto", diff --git a/source/extensions/stat_sinks/statsd/config.cc b/source/extensions/stat_sinks/statsd/config.cc index e9656bfdb8e0..20fa5bef8fe3 100644 --- a/source/extensions/stat_sinks/statsd/config.cc +++ b/source/extensions/stat_sinks/statsd/config.cc @@ -8,7 +8,6 @@ #include "source/common/network/resolver_impl.h" #include "source/extensions/stat_sinks/common/statsd/statsd.h" -#include "source/extensions/stat_sinks/well_known_names.h" namespace Envoy { namespace Extensions { @@ -45,7 +44,7 @@ ProtobufTypes::MessagePtr StatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string StatsdSinkFactory::name() const { return StatsSinkNames::get().Statsd; } +std::string StatsdSinkFactory::name() const { return "envoy.stat_sinks.statsd"; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/wasm/BUILD b/source/extensions/stat_sinks/wasm/BUILD index 1747789d6c7a..ce5f63bfb616 100644 --- a/source/extensions/stat_sinks/wasm/BUILD +++ b/source/extensions/stat_sinks/wasm/BUILD @@ -21,7 +21,6 @@ envoy_cc_extension( "//envoy/server:factory_context_interface", "//envoy/server:instance_interface", "//source/extensions/common/wasm:wasm_lib", - "//source/extensions/stat_sinks:well_known_names", "//source/server:configuration_lib", "@envoy_api//envoy/extensions/stat_sinks/wasm/v3:pkg_cc_proto", ], diff --git a/source/extensions/stat_sinks/wasm/config.cc b/source/extensions/stat_sinks/wasm/config.cc index 8e1ffd9274d4..9d6f463b5742 100644 --- a/source/extensions/stat_sinks/wasm/config.cc +++ b/source/extensions/stat_sinks/wasm/config.cc @@ -8,7 +8,6 @@ #include "source/extensions/common/wasm/wasm.h" #include "source/extensions/stat_sinks/wasm/wasm_stat_sink_impl.h" -#include "source/extensions/stat_sinks/well_known_names.h" namespace Envoy { namespace Extensions { @@ -56,7 +55,7 @@ ProtobufTypes::MessagePtr WasmSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string WasmSinkFactory::name() const { return StatsSinkNames::get().Wasm; } +std::string WasmSinkFactory::name() const { return "envoy.stat_sinks.wasm"; } /** * Static registration for the wasm access log. @see RegisterFactory. diff --git a/test/extensions/stats_sinks/dog_statsd/config_test.cc b/test/extensions/stats_sinks/dog_statsd/config_test.cc index 6a7e285bf5f1..eb8381c14334 100644 --- a/test/extensions/stats_sinks/dog_statsd/config_test.cc +++ b/test/extensions/stats_sinks/dog_statsd/config_test.cc @@ -6,7 +6,6 @@ #include "source/common/protobuf/utility.h" #include "source/extensions/stat_sinks/common/statsd/statsd.h" #include "source/extensions/stat_sinks/dog_statsd/config.h" -#include "source/extensions/stat_sinks/well_known_names.h" #include "test/mocks/server/instance.h" #include "test/test_common/environment.h" @@ -30,7 +29,7 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, DogStatsdConfigLoopbackTest, TestUtility::ipTestParamsToString); TEST_P(DogStatsdConfigLoopbackTest, ValidUdpIp) { - const std::string name = StatsSinkNames::get().DogStatsd; + const std::string name = "envoy.stat_sinks.dog_statsd"; envoy::config::metrics::v3::DogStatsdSink sink_config; envoy::config::core::v3::Address& address = *sink_config.mutable_address(); @@ -66,7 +65,7 @@ TEST(DogStatsdConfigTest, ValidateFail) { } TEST_P(DogStatsdConfigLoopbackTest, CustomBufferSize) { - const std::string name = StatsSinkNames::get().DogStatsd; + const std::string name = "envoy.stat_sinks.dog_statsd"; envoy::config::metrics::v3::DogStatsdSink sink_config; sink_config.mutable_max_bytes_per_datagram()->set_value(128); @@ -94,7 +93,7 @@ TEST_P(DogStatsdConfigLoopbackTest, CustomBufferSize) { } TEST_P(DogStatsdConfigLoopbackTest, DefaultBufferSize) { - const std::string name = StatsSinkNames::get().DogStatsd; + const std::string name = "envoy.stat_sinks.dog_statsd"; envoy::config::metrics::v3::DogStatsdSink sink_config; envoy::config::core::v3::Address& address = *sink_config.mutable_address(); @@ -122,7 +121,7 @@ TEST_P(DogStatsdConfigLoopbackTest, DefaultBufferSize) { } TEST_P(DogStatsdConfigLoopbackTest, WithCustomPrefix) { - const std::string name = StatsSinkNames::get().DogStatsd; + const std::string name = "envoy.stat_sinks.dog_statsd"; envoy::config::metrics::v3::DogStatsdSink sink_config; envoy::config::core::v3::Address& address = *sink_config.mutable_address(); diff --git a/test/extensions/stats_sinks/hystrix/config_test.cc b/test/extensions/stats_sinks/hystrix/config_test.cc index 9a5b78b7024f..01619b17d8bf 100644 --- a/test/extensions/stats_sinks/hystrix/config_test.cc +++ b/test/extensions/stats_sinks/hystrix/config_test.cc @@ -4,7 +4,6 @@ #include "source/common/protobuf/utility.h" #include "source/extensions/stat_sinks/hystrix/config.h" #include "source/extensions/stat_sinks/hystrix/hystrix.h" -#include "source/extensions/stat_sinks/well_known_names.h" #include "test/mocks/server/instance.h" #include "test/test_common/environment.h" @@ -23,7 +22,7 @@ namespace Hystrix { namespace { TEST(StatsConfigTest, ValidHystrixSink) { - const std::string name = StatsSinkNames::get().Hystrix; + const std::string name = "envoy.stat_sinks.hystrix"; envoy::config::metrics::v3::HystrixSink sink_config; diff --git a/test/extensions/stats_sinks/statsd/config_test.cc b/test/extensions/stats_sinks/statsd/config_test.cc index cbf1c02d6030..f5ef08b27351 100644 --- a/test/extensions/stats_sinks/statsd/config_test.cc +++ b/test/extensions/stats_sinks/statsd/config_test.cc @@ -7,7 +7,6 @@ #include "source/common/protobuf/utility.h" #include "source/extensions/stat_sinks/common/statsd/statsd.h" #include "source/extensions/stat_sinks/statsd/config.h" -#include "source/extensions/stat_sinks/well_known_names.h" #include "test/mocks/server/instance.h" #include "test/test_common/environment.h" @@ -26,7 +25,7 @@ namespace Statsd { namespace { TEST(StatsConfigTest, ValidTcpStatsd) { - const std::string name = StatsSinkNames::get().Statsd; + const std::string name = "envoy.stat_sinks.statsd"; envoy::config::metrics::v3::StatsdSink sink_config; sink_config.set_tcp_cluster_name("fake_cluster"); @@ -60,7 +59,7 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, StatsConfigParameterizedTest, TestUtility::ipTestParamsToString); TEST_P(StatsConfigParameterizedTest, UdpSinkDefaultPrefix) { - const std::string name = StatsSinkNames::get().Statsd; + const std::string name = "envoy.stat_sinks.statsd"; const auto& defaultPrefix = Common::Statsd::getDefaultPrefix(); envoy::config::metrics::v3::StatsdSink sink_config; @@ -91,7 +90,7 @@ TEST_P(StatsConfigParameterizedTest, UdpSinkDefaultPrefix) { } TEST_P(StatsConfigParameterizedTest, UdpSinkCustomPrefix) { - const std::string name = StatsSinkNames::get().Statsd; + const std::string name = "envoy.stat_sinks.statsd"; const std::string customPrefix = "prefix.test"; envoy::config::metrics::v3::StatsdSink sink_config; @@ -123,7 +122,7 @@ TEST_P(StatsConfigParameterizedTest, UdpSinkCustomPrefix) { } TEST(StatsConfigTest, TcpSinkDefaultPrefix) { - const std::string name = StatsSinkNames::get().Statsd; + const std::string name = "envoy.stat_sinks.statsd"; envoy::config::metrics::v3::StatsdSink sink_config; const auto& defaultPrefix = Common::Statsd::getDefaultPrefix(); @@ -147,7 +146,7 @@ TEST(StatsConfigTest, TcpSinkDefaultPrefix) { } TEST(StatsConfigTest, TcpSinkCustomPrefix) { - const std::string name = StatsSinkNames::get().Statsd; + const std::string name = "envoy.stat_sinks.statsd"; envoy::config::metrics::v3::StatsdSink sink_config; std::string prefix = "prefixTest"; @@ -178,7 +177,7 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, StatsConfigLoopbackTest, TestUtility::ipTestParamsToString); TEST_P(StatsConfigLoopbackTest, ValidUdpIpStatsd) { - const std::string name = StatsSinkNames::get().Statsd; + const std::string name = "envoy.stat_sinks.statsd"; envoy::config::metrics::v3::StatsdSink sink_config; envoy::config::core::v3::Address& address = *sink_config.mutable_address(); diff --git a/test/extensions/stats_sinks/wasm/config_test.cc b/test/extensions/stats_sinks/wasm/config_test.cc index 0887d1b1ecb1..3121e5172152 100644 --- a/test/extensions/stats_sinks/wasm/config_test.cc +++ b/test/extensions/stats_sinks/wasm/config_test.cc @@ -5,7 +5,6 @@ #include "source/extensions/common/wasm/wasm.h" #include "source/extensions/stat_sinks/wasm/config.h" #include "source/extensions/stat_sinks/wasm/wasm_stat_sink_impl.h" -#include "source/extensions/stat_sinks/well_known_names.h" #include "test/extensions/common/wasm/wasm_runtime.h" #include "test/mocks/server/mocks.h" @@ -43,7 +42,7 @@ class WasmStatSinkConfigTest : public testing::TestWithParam { void initializeWithConfig(const envoy::extensions::stat_sinks::wasm::v3::Wasm& config) { auto factory = Registry::FactoryRegistry::getFactory( - StatsSinkNames::get().Wasm); + "envoy.stat_sinks.wasm"); ASSERT_NE(factory, nullptr); api_ = Api::createApiForTest(stats_store_); EXPECT_CALL(context_, api()).WillRepeatedly(testing::ReturnRef(*api_)); diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index d4625db96388..8dd5e3e6969b 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -12,7 +12,6 @@ #include "source/common/json/json_loader.h" #include "source/common/protobuf/utility.h" #include "source/common/upstream/cluster_manager_impl.h" -#include "source/extensions/stat_sinks/well_known_names.h" #include "source/server/configuration_impl.h" #include "test/common/upstream/utility.h" @@ -467,7 +466,7 @@ TEST_F(ConfigurationImplTest, ProtoSpecifiedStatsSink) { auto bootstrap = Upstream::parseBootstrapFromV3Json(json); auto& sink = *bootstrap.mutable_stats_sinks()->Add(); - sink.set_name(Extensions::StatSinks::StatsSinkNames::get().Statsd); + sink.set_name("envoy.stat_sinks.statsd"); addStatsdFakeClusterConfig(sink); server_.server_factory_context_->cluster_manager_.initializeClusters({"fake_cluster"}, {}); From dfb1a8dcefb85d44c01383e690d54697680e7021 Mon Sep 17 00:00:00 2001 From: Long Dai Date: Mon, 12 Jul 2021 19:33:08 -0700 Subject: [PATCH 2/6] ushare const Signed-off-by: Long Dai --- .../stat_sinks/dog_statsd/config.cc | 2 +- .../extensions/stat_sinks/dog_statsd/config.h | 3 ++ .../extensions/stat_sinks/hystrix/config.cc | 2 +- source/extensions/stat_sinks/hystrix/config.h | 3 ++ .../stat_sinks/metrics_service/config.cc | 2 +- .../stat_sinks/metrics_service/config.h | 3 ++ source/extensions/stat_sinks/statsd/config.cc | 2 +- source/extensions/stat_sinks/statsd/config.h | 3 ++ source/extensions/stat_sinks/wasm/config.cc | 2 +- source/extensions/stat_sinks/wasm/config.h | 3 ++ .../extensions/stat_sinks/well_known_names.h | 35 ------------------- .../stats_sinks/dog_statsd/config_test.cc | 20 +++-------- .../stats_sinks/hystrix/config_test.cc | 4 +-- .../metrics_service/config_test.cc | 4 +-- .../stats_sinks/statsd/config_test.cc | 4 +-- 15 files changed, 28 insertions(+), 64 deletions(-) delete mode 100644 source/extensions/stat_sinks/well_known_names.h diff --git a/source/extensions/stat_sinks/dog_statsd/config.cc b/source/extensions/stat_sinks/dog_statsd/config.cc index 28a58a212ce7..821d98db813d 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.cc +++ b/source/extensions/stat_sinks/dog_statsd/config.cc @@ -37,7 +37,7 @@ ProtobufTypes::MessagePtr DogStatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string DogStatsdSinkFactory::name() const { return "envoy.stat_sinks.dog_statsd"; } +std::string DogStatsdSinkFactory::name() const { return DogStatsd; } /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/dog_statsd/config.h b/source/extensions/stat_sinks/dog_statsd/config.h index 69806524bbe6..08669d0d5f9c 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.h +++ b/source/extensions/stat_sinks/dog_statsd/config.h @@ -9,6 +9,9 @@ namespace Extensions { namespace StatSinks { namespace DogStatsd { +// DogStatsD compatible statsd sink +const std::string DogStatsd = "envoy.stat_sinks.dog_statsd"; + /** * Config registration for the DogStatsD compatible statsd sink. @see StatsSinkFactory. */ diff --git a/source/extensions/stat_sinks/hystrix/config.cc b/source/extensions/stat_sinks/hystrix/config.cc index 684ce1cd873a..c1747a4dc876 100644 --- a/source/extensions/stat_sinks/hystrix/config.cc +++ b/source/extensions/stat_sinks/hystrix/config.cc @@ -27,7 +27,7 @@ ProtobufTypes::MessagePtr HystrixSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string HystrixSinkFactory::name() const { return "envoy.stat_sinks.hystrix"; } +std::string HystrixSinkFactory::name() const { return Hystrix; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/hystrix/config.h b/source/extensions/stat_sinks/hystrix/config.h index 1bf144323381..3bdab4615bda 100644 --- a/source/extensions/stat_sinks/hystrix/config.h +++ b/source/extensions/stat_sinks/hystrix/config.h @@ -11,6 +11,9 @@ namespace Extensions { namespace StatSinks { namespace Hystrix { +// Hystrix sink +const std::string Hystrix = "envoy.stat_sinks.hystrix"; + class HystrixSinkFactory : Logger::Loggable, public Server::Configuration::StatsSinkFactory { public: diff --git a/source/extensions/stat_sinks/metrics_service/config.cc b/source/extensions/stat_sinks/metrics_service/config.cc index 83976a07c2e9..5b906b04e106 100644 --- a/source/extensions/stat_sinks/metrics_service/config.cc +++ b/source/extensions/stat_sinks/metrics_service/config.cc @@ -47,7 +47,7 @@ ProtobufTypes::MessagePtr MetricsServiceSinkFactory::createEmptyConfigProto() { std::make_unique()); } -std::string MetricsServiceSinkFactory::name() const { return "envoy.stat_sinks.metrics_service"; } +std::string MetricsServiceSinkFactory::name() const { return MetricsService; } /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/metrics_service/config.h b/source/extensions/stat_sinks/metrics_service/config.h index aff8e19fa2fc..bad0549a3804 100644 --- a/source/extensions/stat_sinks/metrics_service/config.h +++ b/source/extensions/stat_sinks/metrics_service/config.h @@ -10,6 +10,9 @@ namespace Extensions { namespace StatSinks { namespace MetricsService { +// MetricsService sink +const std::string MetricsService = "envoy.stat_sinks.metrics_service"; + /** * Config registration for the MetricsService stats sink. @see StatsSinkFactory. */ diff --git a/source/extensions/stat_sinks/statsd/config.cc b/source/extensions/stat_sinks/statsd/config.cc index 20fa5bef8fe3..9b35b9c14c59 100644 --- a/source/extensions/stat_sinks/statsd/config.cc +++ b/source/extensions/stat_sinks/statsd/config.cc @@ -44,7 +44,7 @@ ProtobufTypes::MessagePtr StatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string StatsdSinkFactory::name() const { return "envoy.stat_sinks.statsd"; } +std::string StatsdSinkFactory::name() const { return Statsd; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/statsd/config.h b/source/extensions/stat_sinks/statsd/config.h index dbce694b7a79..61b5cb89e75f 100644 --- a/source/extensions/stat_sinks/statsd/config.h +++ b/source/extensions/stat_sinks/statsd/config.h @@ -9,6 +9,9 @@ namespace Extensions { namespace StatSinks { namespace Statsd { +// Statsd sink +const std::string Statsd = "envoy.stat_sinks.statsd"; + /** * Config registration for the tcp statsd sink. @see StatsSinkFactory. */ diff --git a/source/extensions/stat_sinks/wasm/config.cc b/source/extensions/stat_sinks/wasm/config.cc index 9d6f463b5742..297e9b796d6f 100644 --- a/source/extensions/stat_sinks/wasm/config.cc +++ b/source/extensions/stat_sinks/wasm/config.cc @@ -55,7 +55,7 @@ ProtobufTypes::MessagePtr WasmSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string WasmSinkFactory::name() const { return "envoy.stat_sinks.wasm"; } +std::string WasmSinkFactory::name() const { return Wasm; } /** * Static registration for the wasm access log. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/wasm/config.h b/source/extensions/stat_sinks/wasm/config.h index 8887e7b6ab45..0fcd9603c1e6 100644 --- a/source/extensions/stat_sinks/wasm/config.h +++ b/source/extensions/stat_sinks/wasm/config.h @@ -13,6 +13,9 @@ namespace Extensions { namespace StatSinks { namespace Wasm { +// WebAssembly sink +const std::string Wasm = "envoy.stat_sinks.wasm"; + /** * Config registration for the Wasm statsd sink. @see StatSinkFactory. */ diff --git a/source/extensions/stat_sinks/well_known_names.h b/source/extensions/stat_sinks/well_known_names.h deleted file mode 100644 index ab253da7acb8..000000000000 --- a/source/extensions/stat_sinks/well_known_names.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include - -#include "source/common/singleton/const_singleton.h" - -namespace Envoy { -namespace Extensions { -namespace StatSinks { - -/** - * Well-known stats sink names. - * NOTE: New sinks should use the well known name: envoy.stat_sinks.name. - */ -class StatsSinkNameValues { -public: - // Statsd sink - const std::string Statsd = "envoy.stat_sinks.statsd"; - // DogStatsD compatible statsd sink - const std::string DogStatsd = "envoy.stat_sinks.dog_statsd"; - // Graphite Statsd sink (with Graphite-formatted tags) - const std::string GraphiteStatsd = "envoy.stat_sinks.graphite_statsd"; - // MetricsService sink - const std::string MetricsService = "envoy.stat_sinks.metrics_service"; - // Hystrix sink - const std::string Hystrix = "envoy.stat_sinks.hystrix"; - // WebAssembly sink - const std::string Wasm = "envoy.stat_sinks.wasm"; -}; - -using StatsSinkNames = ConstSingleton; - -} // namespace StatSinks -} // namespace Extensions -} // namespace Envoy diff --git a/test/extensions/stats_sinks/dog_statsd/config_test.cc b/test/extensions/stats_sinks/dog_statsd/config_test.cc index eb8381c14334..ab5a92eedb89 100644 --- a/test/extensions/stats_sinks/dog_statsd/config_test.cc +++ b/test/extensions/stats_sinks/dog_statsd/config_test.cc @@ -29,8 +29,6 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, DogStatsdConfigLoopbackTest, TestUtility::ipTestParamsToString); TEST_P(DogStatsdConfigLoopbackTest, ValidUdpIp) { - const std::string name = "envoy.stat_sinks.dog_statsd"; - envoy::config::metrics::v3::DogStatsdSink sink_config; envoy::config::core::v3::Address& address = *sink_config.mutable_address(); envoy::config::core::v3::SocketAddress& socket_address = *address.mutable_socket_address(); @@ -41,7 +39,7 @@ TEST_P(DogStatsdConfigLoopbackTest, ValidUdpIp) { socket_address.set_port_value(8125); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(DogStatsd); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -65,8 +63,6 @@ TEST(DogStatsdConfigTest, ValidateFail) { } TEST_P(DogStatsdConfigLoopbackTest, CustomBufferSize) { - const std::string name = "envoy.stat_sinks.dog_statsd"; - envoy::config::metrics::v3::DogStatsdSink sink_config; sink_config.mutable_max_bytes_per_datagram()->set_value(128); envoy::config::core::v3::Address& address = *sink_config.mutable_address(); @@ -78,7 +74,7 @@ TEST_P(DogStatsdConfigLoopbackTest, CustomBufferSize) { socket_address.set_port_value(8125); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(DogStatsd); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -93,8 +89,6 @@ TEST_P(DogStatsdConfigLoopbackTest, CustomBufferSize) { } TEST_P(DogStatsdConfigLoopbackTest, DefaultBufferSize) { - const std::string name = "envoy.stat_sinks.dog_statsd"; - envoy::config::metrics::v3::DogStatsdSink sink_config; envoy::config::core::v3::Address& address = *sink_config.mutable_address(); envoy::config::core::v3::SocketAddress& socket_address = *address.mutable_socket_address(); @@ -105,7 +99,7 @@ TEST_P(DogStatsdConfigLoopbackTest, DefaultBufferSize) { socket_address.set_port_value(8125); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(DogStatsd); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -121,8 +115,6 @@ TEST_P(DogStatsdConfigLoopbackTest, DefaultBufferSize) { } TEST_P(DogStatsdConfigLoopbackTest, WithCustomPrefix) { - const std::string name = "envoy.stat_sinks.dog_statsd"; - envoy::config::metrics::v3::DogStatsdSink sink_config; envoy::config::core::v3::Address& address = *sink_config.mutable_address(); envoy::config::core::v3::SocketAddress& socket_address = *address.mutable_socket_address(); @@ -136,7 +128,7 @@ TEST_P(DogStatsdConfigLoopbackTest, WithCustomPrefix) { sink_config.set_prefix(customPrefix); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(DogStatsd); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -152,10 +144,8 @@ TEST_P(DogStatsdConfigLoopbackTest, WithCustomPrefix) { // Test that the deprecated extension name still functions. TEST(DogStatsdConfigTest, DEPRECATED_FEATURE_TEST(DeprecatedExtensionFilterName)) { - const std::string deprecated_name = "envoy.dog_statsd"; - ASSERT_NE(nullptr, Registry::FactoryRegistry::getFactory( - deprecated_name)); + DogStatsd)); } } // namespace diff --git a/test/extensions/stats_sinks/hystrix/config_test.cc b/test/extensions/stats_sinks/hystrix/config_test.cc index 01619b17d8bf..0f9b57354312 100644 --- a/test/extensions/stats_sinks/hystrix/config_test.cc +++ b/test/extensions/stats_sinks/hystrix/config_test.cc @@ -22,12 +22,10 @@ namespace Hystrix { namespace { TEST(StatsConfigTest, ValidHystrixSink) { - const std::string name = "envoy.stat_sinks.hystrix"; - envoy::config::metrics::v3::HystrixSink sink_config; Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(Hystrix); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); diff --git a/test/extensions/stats_sinks/metrics_service/config_test.cc b/test/extensions/stats_sinks/metrics_service/config_test.cc index a9d557639e07..1b8a4997779b 100644 --- a/test/extensions/stats_sinks/metrics_service/config_test.cc +++ b/test/extensions/stats_sinks/metrics_service/config_test.cc @@ -14,10 +14,8 @@ namespace { // Test that the deprecated extension name still functions. TEST(MetricsServiceConfigTest, DEPRECATED_FEATURE_TEST(DeprecatedExtensionFilterName)) { - const std::string deprecated_name = "envoy.metrics_service"; - ASSERT_NE(nullptr, Registry::FactoryRegistry::getFactory( - deprecated_name)); + MetricsService)); } } // namespace diff --git a/test/extensions/stats_sinks/statsd/config_test.cc b/test/extensions/stats_sinks/statsd/config_test.cc index f5ef08b27351..759aab41aaca 100644 --- a/test/extensions/stats_sinks/statsd/config_test.cc +++ b/test/extensions/stats_sinks/statsd/config_test.cc @@ -177,8 +177,6 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, StatsConfigLoopbackTest, TestUtility::ipTestParamsToString); TEST_P(StatsConfigLoopbackTest, ValidUdpIpStatsd) { - const std::string name = "envoy.stat_sinks.statsd"; - envoy::config::metrics::v3::StatsdSink sink_config; envoy::config::core::v3::Address& address = *sink_config.mutable_address(); envoy::config::core::v3::SocketAddress& socket_address = *address.mutable_socket_address(); @@ -188,7 +186,7 @@ TEST_P(StatsConfigLoopbackTest, ValidUdpIpStatsd) { socket_address.set_port_value(8125); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(Statsd); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); From 854223c79317ad4ff791bb0f76a6685c62f1be2a Mon Sep 17 00:00:00 2001 From: Long Dai Date: Mon, 12 Jul 2021 22:25:12 -0700 Subject: [PATCH 3/6] fix lost Signed-off-by: Long Dai --- .../stats_sinks/statsd/config_test.cc | 18 +++++------------- .../extensions/stats_sinks/wasm/config_test.cc | 3 +-- test/server/configuration_impl_test.cc | 3 ++- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/test/extensions/stats_sinks/statsd/config_test.cc b/test/extensions/stats_sinks/statsd/config_test.cc index 759aab41aaca..1143c5d9a19e 100644 --- a/test/extensions/stats_sinks/statsd/config_test.cc +++ b/test/extensions/stats_sinks/statsd/config_test.cc @@ -25,13 +25,11 @@ namespace Statsd { namespace { TEST(StatsConfigTest, ValidTcpStatsd) { - const std::string name = "envoy.stat_sinks.statsd"; - envoy::config::metrics::v3::StatsdSink sink_config; sink_config.set_tcp_cluster_name("fake_cluster"); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(Statsd); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -59,7 +57,6 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, StatsConfigParameterizedTest, TestUtility::ipTestParamsToString); TEST_P(StatsConfigParameterizedTest, UdpSinkDefaultPrefix) { - const std::string name = "envoy.stat_sinks.statsd"; const auto& defaultPrefix = Common::Statsd::getDefaultPrefix(); envoy::config::metrics::v3::StatsdSink sink_config; @@ -75,7 +72,7 @@ TEST_P(StatsConfigParameterizedTest, UdpSinkDefaultPrefix) { EXPECT_EQ(sink_config.prefix(), ""); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(Statsd); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); TestUtility::jsonConvert(sink_config, *message); @@ -90,7 +87,6 @@ TEST_P(StatsConfigParameterizedTest, UdpSinkDefaultPrefix) { } TEST_P(StatsConfigParameterizedTest, UdpSinkCustomPrefix) { - const std::string name = "envoy.stat_sinks.statsd"; const std::string customPrefix = "prefix.test"; envoy::config::metrics::v3::StatsdSink sink_config; @@ -107,7 +103,7 @@ TEST_P(StatsConfigParameterizedTest, UdpSinkCustomPrefix) { EXPECT_NE(sink_config.prefix(), ""); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(Statsd); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); TestUtility::jsonConvert(sink_config, *message); @@ -122,14 +118,12 @@ TEST_P(StatsConfigParameterizedTest, UdpSinkCustomPrefix) { } TEST(StatsConfigTest, TcpSinkDefaultPrefix) { - const std::string name = "envoy.stat_sinks.statsd"; - envoy::config::metrics::v3::StatsdSink sink_config; const auto& defaultPrefix = Common::Statsd::getDefaultPrefix(); sink_config.set_tcp_cluster_name("fake_cluster"); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(Statsd); ASSERT_NE(factory, nullptr); EXPECT_EQ(sink_config.prefix(), ""); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -146,8 +140,6 @@ TEST(StatsConfigTest, TcpSinkDefaultPrefix) { } TEST(StatsConfigTest, TcpSinkCustomPrefix) { - const std::string name = "envoy.stat_sinks.statsd"; - envoy::config::metrics::v3::StatsdSink sink_config; std::string prefix = "prefixTest"; sink_config.set_tcp_cluster_name("fake_cluster"); @@ -155,7 +147,7 @@ TEST(StatsConfigTest, TcpSinkCustomPrefix) { sink_config.set_prefix(prefix); EXPECT_EQ(sink_config.prefix(), prefix); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(name); + Registry::FactoryRegistry::getFactory(Statsd); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); diff --git a/test/extensions/stats_sinks/wasm/config_test.cc b/test/extensions/stats_sinks/wasm/config_test.cc index 3121e5172152..0a42ecbefe43 100644 --- a/test/extensions/stats_sinks/wasm/config_test.cc +++ b/test/extensions/stats_sinks/wasm/config_test.cc @@ -41,8 +41,7 @@ class WasmStatSinkConfigTest : public testing::TestWithParam { } void initializeWithConfig(const envoy::extensions::stat_sinks::wasm::v3::Wasm& config) { - auto factory = Registry::FactoryRegistry::getFactory( - "envoy.stat_sinks.wasm"); + auto factory = Registry::FactoryRegistry::getFactory(Wasm); ASSERT_NE(factory, nullptr); api_ = Api::createApiForTest(stats_store_); EXPECT_CALL(context_, api()).WillRepeatedly(testing::ReturnRef(*api_)); diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index 8dd5e3e6969b..1875622646ec 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -12,6 +12,7 @@ #include "source/common/json/json_loader.h" #include "source/common/protobuf/utility.h" #include "source/common/upstream/cluster_manager_impl.h" +#include "source/extensions/stat_sinks/common/statsd/statsd.h" #include "source/server/configuration_impl.h" #include "test/common/upstream/utility.h" @@ -466,7 +467,7 @@ TEST_F(ConfigurationImplTest, ProtoSpecifiedStatsSink) { auto bootstrap = Upstream::parseBootstrapFromV3Json(json); auto& sink = *bootstrap.mutable_stats_sinks()->Add(); - sink.set_name("envoy.stat_sinks.statsd"); + sink.set_name(Statsd); addStatsdFakeClusterConfig(sink); server_.server_factory_context_->cluster_manager_.initializeClusters({"fake_cluster"}, {}); From 8e57fff933a67f39c7f03168bacbaf7055981462 Mon Sep 17 00:00:00 2001 From: Long Dai Date: Mon, 12 Jul 2021 23:20:38 -0700 Subject: [PATCH 4/6] fix format Signed-off-by: Long Dai --- test/extensions/stats_sinks/wasm/config_test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/extensions/stats_sinks/wasm/config_test.cc b/test/extensions/stats_sinks/wasm/config_test.cc index 0a42ecbefe43..e7c3e8e43cfb 100644 --- a/test/extensions/stats_sinks/wasm/config_test.cc +++ b/test/extensions/stats_sinks/wasm/config_test.cc @@ -41,7 +41,8 @@ class WasmStatSinkConfigTest : public testing::TestWithParam { } void initializeWithConfig(const envoy::extensions::stat_sinks::wasm::v3::Wasm& config) { - auto factory = Registry::FactoryRegistry::getFactory(Wasm); + auto factory = + Registry::FactoryRegistry::getFactory(Wasm); ASSERT_NE(factory, nullptr); api_ = Api::createApiForTest(stats_store_); EXPECT_CALL(context_, api()).WillRepeatedly(testing::ReturnRef(*api_)); From ec6c3c7e48ddeb94586cd58c67f7d763d4198a64 Mon Sep 17 00:00:00 2001 From: Long Dai Date: Fri, 16 Jul 2021 01:11:31 -0700 Subject: [PATCH 5/6] feedback Signed-off-by: Long Dai --- source/extensions/stat_sinks/dog_statsd/config.h | 2 +- source/extensions/stat_sinks/hystrix/config.h | 2 +- source/extensions/stat_sinks/metrics_service/config.h | 2 +- source/extensions/stat_sinks/statsd/config.h | 2 +- source/extensions/stat_sinks/wasm/config.h | 2 +- test/server/configuration_impl_test.cc | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/extensions/stat_sinks/dog_statsd/config.h b/source/extensions/stat_sinks/dog_statsd/config.h index 08669d0d5f9c..e2852a2c788b 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.h +++ b/source/extensions/stat_sinks/dog_statsd/config.h @@ -10,7 +10,7 @@ namespace StatSinks { namespace DogStatsd { // DogStatsD compatible statsd sink -const std::string DogStatsd = "envoy.stat_sinks.dog_statsd"; +extern constexpr char DogStatsd[] = "envoy.stat_sinks.dog_statsd"; /** * Config registration for the DogStatsD compatible statsd sink. @see StatsSinkFactory. diff --git a/source/extensions/stat_sinks/hystrix/config.h b/source/extensions/stat_sinks/hystrix/config.h index 3bdab4615bda..a79df9717876 100644 --- a/source/extensions/stat_sinks/hystrix/config.h +++ b/source/extensions/stat_sinks/hystrix/config.h @@ -12,7 +12,7 @@ namespace StatSinks { namespace Hystrix { // Hystrix sink -const std::string Hystrix = "envoy.stat_sinks.hystrix"; +extern constexpr char Hystrix[] = "envoy.stat_sinks.hystrix"; class HystrixSinkFactory : Logger::Loggable, public Server::Configuration::StatsSinkFactory { diff --git a/source/extensions/stat_sinks/metrics_service/config.h b/source/extensions/stat_sinks/metrics_service/config.h index bad0549a3804..f3375b42f349 100644 --- a/source/extensions/stat_sinks/metrics_service/config.h +++ b/source/extensions/stat_sinks/metrics_service/config.h @@ -11,7 +11,7 @@ namespace StatSinks { namespace MetricsService { // MetricsService sink -const std::string MetricsService = "envoy.stat_sinks.metrics_service"; +extern constexpr char MetricsService[] = "envoy.stat_sinks.metrics_service"; /** * Config registration for the MetricsService stats sink. @see StatsSinkFactory. diff --git a/source/extensions/stat_sinks/statsd/config.h b/source/extensions/stat_sinks/statsd/config.h index 61b5cb89e75f..d40595a49443 100644 --- a/source/extensions/stat_sinks/statsd/config.h +++ b/source/extensions/stat_sinks/statsd/config.h @@ -10,7 +10,7 @@ namespace StatSinks { namespace Statsd { // Statsd sink -const std::string Statsd = "envoy.stat_sinks.statsd"; +extern constexpr char Statsd[] = "envoy.stat_sinks.statsd"; /** * Config registration for the tcp statsd sink. @see StatsSinkFactory. diff --git a/source/extensions/stat_sinks/wasm/config.h b/source/extensions/stat_sinks/wasm/config.h index 0fcd9603c1e6..59bb0497b14a 100644 --- a/source/extensions/stat_sinks/wasm/config.h +++ b/source/extensions/stat_sinks/wasm/config.h @@ -14,7 +14,7 @@ namespace StatSinks { namespace Wasm { // WebAssembly sink -const std::string Wasm = "envoy.stat_sinks.wasm"; +extern constexpr char Wasm[] = "envoy.stat_sinks.wasm"; /** * Config registration for the Wasm statsd sink. @see StatSinkFactory. diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index 1875622646ec..b683bb917b95 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -12,7 +12,7 @@ #include "source/common/json/json_loader.h" #include "source/common/protobuf/utility.h" #include "source/common/upstream/cluster_manager_impl.h" -#include "source/extensions/stat_sinks/common/statsd/statsd.h" +#include "source/extensions/stat_sinks/statsd/config.h" #include "source/server/configuration_impl.h" #include "test/common/upstream/utility.h" From 6c86bb715f01e46cf65245da56f0f8533a6c5b3f Mon Sep 17 00:00:00 2001 From: Long Dai Date: Mon, 19 Jul 2021 18:43:12 -0700 Subject: [PATCH 6/6] feedback Signed-off-by: Long Dai --- source/extensions/stat_sinks/dog_statsd/config.cc | 2 +- source/extensions/stat_sinks/dog_statsd/config.h | 2 +- source/extensions/stat_sinks/hystrix/config.cc | 2 +- source/extensions/stat_sinks/hystrix/config.h | 2 +- .../extensions/stat_sinks/metrics_service/config.cc | 2 +- .../extensions/stat_sinks/metrics_service/config.h | 2 +- source/extensions/stat_sinks/statsd/config.cc | 2 +- source/extensions/stat_sinks/statsd/config.h | 2 +- source/extensions/stat_sinks/wasm/config.cc | 2 +- source/extensions/stat_sinks/wasm/config.h | 2 +- .../extensions/stats_sinks/dog_statsd/config_test.cc | 10 +++++----- test/extensions/stats_sinks/hystrix/config_test.cc | 2 +- .../stats_sinks/metrics_service/config_test.cc | 2 +- test/extensions/stats_sinks/statsd/config_test.cc | 12 ++++++------ test/extensions/stats_sinks/wasm/config_test.cc | 2 +- test/server/configuration_impl_test.cc | 2 +- 16 files changed, 25 insertions(+), 25 deletions(-) diff --git a/source/extensions/stat_sinks/dog_statsd/config.cc b/source/extensions/stat_sinks/dog_statsd/config.cc index 821d98db813d..58dbc9e57c37 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.cc +++ b/source/extensions/stat_sinks/dog_statsd/config.cc @@ -37,7 +37,7 @@ ProtobufTypes::MessagePtr DogStatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string DogStatsdSinkFactory::name() const { return DogStatsd; } +std::string DogStatsdSinkFactory::name() const { return DogStatsdName; } /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/dog_statsd/config.h b/source/extensions/stat_sinks/dog_statsd/config.h index e2852a2c788b..3735f4c596ba 100644 --- a/source/extensions/stat_sinks/dog_statsd/config.h +++ b/source/extensions/stat_sinks/dog_statsd/config.h @@ -10,7 +10,7 @@ namespace StatSinks { namespace DogStatsd { // DogStatsD compatible statsd sink -extern constexpr char DogStatsd[] = "envoy.stat_sinks.dog_statsd"; +constexpr char DogStatsdName[] = "envoy.stat_sinks.dog_statsd"; /** * Config registration for the DogStatsD compatible statsd sink. @see StatsSinkFactory. diff --git a/source/extensions/stat_sinks/hystrix/config.cc b/source/extensions/stat_sinks/hystrix/config.cc index c1747a4dc876..c6a5912d4986 100644 --- a/source/extensions/stat_sinks/hystrix/config.cc +++ b/source/extensions/stat_sinks/hystrix/config.cc @@ -27,7 +27,7 @@ ProtobufTypes::MessagePtr HystrixSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string HystrixSinkFactory::name() const { return Hystrix; } +std::string HystrixSinkFactory::name() const { return HystrixName; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/hystrix/config.h b/source/extensions/stat_sinks/hystrix/config.h index a79df9717876..59a3c14364f4 100644 --- a/source/extensions/stat_sinks/hystrix/config.h +++ b/source/extensions/stat_sinks/hystrix/config.h @@ -12,7 +12,7 @@ namespace StatSinks { namespace Hystrix { // Hystrix sink -extern constexpr char Hystrix[] = "envoy.stat_sinks.hystrix"; +constexpr char HystrixName[] = "envoy.stat_sinks.hystrix"; class HystrixSinkFactory : Logger::Loggable, public Server::Configuration::StatsSinkFactory { diff --git a/source/extensions/stat_sinks/metrics_service/config.cc b/source/extensions/stat_sinks/metrics_service/config.cc index 1f9337e4ac0a..716e62fd34a7 100644 --- a/source/extensions/stat_sinks/metrics_service/config.cc +++ b/source/extensions/stat_sinks/metrics_service/config.cc @@ -47,7 +47,7 @@ ProtobufTypes::MessagePtr MetricsServiceSinkFactory::createEmptyConfigProto() { std::make_unique()); } -std::string MetricsServiceSinkFactory::name() const { return MetricsService; } +std::string MetricsServiceSinkFactory::name() const { return MetricsServiceName; } /** * Static registration for the this sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/metrics_service/config.h b/source/extensions/stat_sinks/metrics_service/config.h index f3375b42f349..72d2188ba553 100644 --- a/source/extensions/stat_sinks/metrics_service/config.h +++ b/source/extensions/stat_sinks/metrics_service/config.h @@ -11,7 +11,7 @@ namespace StatSinks { namespace MetricsService { // MetricsService sink -extern constexpr char MetricsService[] = "envoy.stat_sinks.metrics_service"; +constexpr char MetricsServiceName[] = "envoy.stat_sinks.metrics_service"; /** * Config registration for the MetricsService stats sink. @see StatsSinkFactory. diff --git a/source/extensions/stat_sinks/statsd/config.cc b/source/extensions/stat_sinks/statsd/config.cc index 9b35b9c14c59..a0efae013a10 100644 --- a/source/extensions/stat_sinks/statsd/config.cc +++ b/source/extensions/stat_sinks/statsd/config.cc @@ -44,7 +44,7 @@ ProtobufTypes::MessagePtr StatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string StatsdSinkFactory::name() const { return Statsd; } +std::string StatsdSinkFactory::name() const { return StatsdName; } /** * Static registration for the statsd sink factory. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/statsd/config.h b/source/extensions/stat_sinks/statsd/config.h index d40595a49443..eb55ab09f38b 100644 --- a/source/extensions/stat_sinks/statsd/config.h +++ b/source/extensions/stat_sinks/statsd/config.h @@ -10,7 +10,7 @@ namespace StatSinks { namespace Statsd { // Statsd sink -extern constexpr char Statsd[] = "envoy.stat_sinks.statsd"; +constexpr char StatsdName[] = "envoy.stat_sinks.statsd"; /** * Config registration for the tcp statsd sink. @see StatsSinkFactory. diff --git a/source/extensions/stat_sinks/wasm/config.cc b/source/extensions/stat_sinks/wasm/config.cc index 297e9b796d6f..1eec57ece7ef 100644 --- a/source/extensions/stat_sinks/wasm/config.cc +++ b/source/extensions/stat_sinks/wasm/config.cc @@ -55,7 +55,7 @@ ProtobufTypes::MessagePtr WasmSinkFactory::createEmptyConfigProto() { return std::make_unique(); } -std::string WasmSinkFactory::name() const { return Wasm; } +std::string WasmSinkFactory::name() const { return WasmName; } /** * Static registration for the wasm access log. @see RegisterFactory. diff --git a/source/extensions/stat_sinks/wasm/config.h b/source/extensions/stat_sinks/wasm/config.h index 59bb0497b14a..5df22470829f 100644 --- a/source/extensions/stat_sinks/wasm/config.h +++ b/source/extensions/stat_sinks/wasm/config.h @@ -14,7 +14,7 @@ namespace StatSinks { namespace Wasm { // WebAssembly sink -extern constexpr char Wasm[] = "envoy.stat_sinks.wasm"; +constexpr char WasmName[] = "envoy.stat_sinks.wasm"; /** * Config registration for the Wasm statsd sink. @see StatSinkFactory. diff --git a/test/extensions/stats_sinks/dog_statsd/config_test.cc b/test/extensions/stats_sinks/dog_statsd/config_test.cc index ab5a92eedb89..98b02ba931a9 100644 --- a/test/extensions/stats_sinks/dog_statsd/config_test.cc +++ b/test/extensions/stats_sinks/dog_statsd/config_test.cc @@ -39,7 +39,7 @@ TEST_P(DogStatsdConfigLoopbackTest, ValidUdpIp) { socket_address.set_port_value(8125); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(DogStatsd); + Registry::FactoryRegistry::getFactory(DogStatsdName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -74,7 +74,7 @@ TEST_P(DogStatsdConfigLoopbackTest, CustomBufferSize) { socket_address.set_port_value(8125); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(DogStatsd); + Registry::FactoryRegistry::getFactory(DogStatsdName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -99,7 +99,7 @@ TEST_P(DogStatsdConfigLoopbackTest, DefaultBufferSize) { socket_address.set_port_value(8125); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(DogStatsd); + Registry::FactoryRegistry::getFactory(DogStatsdName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -128,7 +128,7 @@ TEST_P(DogStatsdConfigLoopbackTest, WithCustomPrefix) { sink_config.set_prefix(customPrefix); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(DogStatsd); + Registry::FactoryRegistry::getFactory(DogStatsdName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -145,7 +145,7 @@ TEST_P(DogStatsdConfigLoopbackTest, WithCustomPrefix) { // Test that the deprecated extension name still functions. TEST(DogStatsdConfigTest, DEPRECATED_FEATURE_TEST(DeprecatedExtensionFilterName)) { ASSERT_NE(nullptr, Registry::FactoryRegistry::getFactory( - DogStatsd)); + DogStatsdName)); } } // namespace diff --git a/test/extensions/stats_sinks/hystrix/config_test.cc b/test/extensions/stats_sinks/hystrix/config_test.cc index 0f9b57354312..90d928a528e2 100644 --- a/test/extensions/stats_sinks/hystrix/config_test.cc +++ b/test/extensions/stats_sinks/hystrix/config_test.cc @@ -25,7 +25,7 @@ TEST(StatsConfigTest, ValidHystrixSink) { envoy::config::metrics::v3::HystrixSink sink_config; Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(Hystrix); + Registry::FactoryRegistry::getFactory(HystrixName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); diff --git a/test/extensions/stats_sinks/metrics_service/config_test.cc b/test/extensions/stats_sinks/metrics_service/config_test.cc index 1b8a4997779b..739e49ba5ae2 100644 --- a/test/extensions/stats_sinks/metrics_service/config_test.cc +++ b/test/extensions/stats_sinks/metrics_service/config_test.cc @@ -15,7 +15,7 @@ namespace { // Test that the deprecated extension name still functions. TEST(MetricsServiceConfigTest, DEPRECATED_FEATURE_TEST(DeprecatedExtensionFilterName)) { ASSERT_NE(nullptr, Registry::FactoryRegistry::getFactory( - MetricsService)); + MetricsServiceName)); } } // namespace diff --git a/test/extensions/stats_sinks/statsd/config_test.cc b/test/extensions/stats_sinks/statsd/config_test.cc index 1143c5d9a19e..af575796eb84 100644 --- a/test/extensions/stats_sinks/statsd/config_test.cc +++ b/test/extensions/stats_sinks/statsd/config_test.cc @@ -29,7 +29,7 @@ TEST(StatsConfigTest, ValidTcpStatsd) { sink_config.set_tcp_cluster_name("fake_cluster"); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(Statsd); + Registry::FactoryRegistry::getFactory(StatsdName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -72,7 +72,7 @@ TEST_P(StatsConfigParameterizedTest, UdpSinkDefaultPrefix) { EXPECT_EQ(sink_config.prefix(), ""); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(Statsd); + Registry::FactoryRegistry::getFactory(StatsdName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); TestUtility::jsonConvert(sink_config, *message); @@ -103,7 +103,7 @@ TEST_P(StatsConfigParameterizedTest, UdpSinkCustomPrefix) { EXPECT_NE(sink_config.prefix(), ""); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(Statsd); + Registry::FactoryRegistry::getFactory(StatsdName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); TestUtility::jsonConvert(sink_config, *message); @@ -123,7 +123,7 @@ TEST(StatsConfigTest, TcpSinkDefaultPrefix) { sink_config.set_tcp_cluster_name("fake_cluster"); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(Statsd); + Registry::FactoryRegistry::getFactory(StatsdName); ASSERT_NE(factory, nullptr); EXPECT_EQ(sink_config.prefix(), ""); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -147,7 +147,7 @@ TEST(StatsConfigTest, TcpSinkCustomPrefix) { sink_config.set_prefix(prefix); EXPECT_EQ(sink_config.prefix(), prefix); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(Statsd); + Registry::FactoryRegistry::getFactory(StatsdName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); @@ -178,7 +178,7 @@ TEST_P(StatsConfigLoopbackTest, ValidUdpIpStatsd) { socket_address.set_port_value(8125); Server::Configuration::StatsSinkFactory* factory = - Registry::FactoryRegistry::getFactory(Statsd); + Registry::FactoryRegistry::getFactory(StatsdName); ASSERT_NE(factory, nullptr); ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); diff --git a/test/extensions/stats_sinks/wasm/config_test.cc b/test/extensions/stats_sinks/wasm/config_test.cc index e7c3e8e43cfb..64a7d4333832 100644 --- a/test/extensions/stats_sinks/wasm/config_test.cc +++ b/test/extensions/stats_sinks/wasm/config_test.cc @@ -42,7 +42,7 @@ class WasmStatSinkConfigTest : public testing::TestWithParam { void initializeWithConfig(const envoy::extensions::stat_sinks::wasm::v3::Wasm& config) { auto factory = - Registry::FactoryRegistry::getFactory(Wasm); + Registry::FactoryRegistry::getFactory(WasmName); ASSERT_NE(factory, nullptr); api_ = Api::createApiForTest(stats_store_); EXPECT_CALL(context_, api()).WillRepeatedly(testing::ReturnRef(*api_)); diff --git a/test/server/configuration_impl_test.cc b/test/server/configuration_impl_test.cc index 755f36f4f30b..4e7de3b88dc1 100644 --- a/test/server/configuration_impl_test.cc +++ b/test/server/configuration_impl_test.cc @@ -467,7 +467,7 @@ TEST_F(ConfigurationImplTest, ProtoSpecifiedStatsSink) { auto bootstrap = Upstream::parseBootstrapFromV3Json(json); auto& sink = *bootstrap.mutable_stats_sinks()->Add(); - sink.set_name(Statsd); + sink.set_name(Extensions::StatSinks::Statsd::StatsdName); addStatsdFakeClusterConfig(sink); server_.server_factory_context_->cluster_manager_.initializeClusters({"fake_cluster"}, {});