Skip to content

Commit

Permalink
stat_sinks: remove well_known_names
Browse files Browse the repository at this point in the history
Signed-off-by: Long Dai <[email protected]>
  • Loading branch information
daixiang0 committed Jul 12, 2021
1 parent 5ab509b commit 63f5e93
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 44 deletions.
11 changes: 0 additions & 11 deletions source/extensions/stat_sinks/BUILD
Original file line number Diff line number Diff line change
@@ -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",
],
)
1 change: 0 additions & 1 deletion source/extensions/stat_sinks/dog_statsd/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/stat_sinks/dog_statsd/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -38,7 +37,7 @@ ProtobufTypes::MessagePtr DogStatsdSinkFactory::createEmptyConfigProto() {
return std::make_unique<envoy::config::metrics::v3::DogStatsdSink>();
}

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.
Expand Down
1 change: 0 additions & 1 deletion source/extensions/stat_sinks/hystrix/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/stat_sinks/hystrix/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,7 +27,7 @@ ProtobufTypes::MessagePtr HystrixSinkFactory::createEmptyConfigProto() {
return std::make_unique<envoy::config::metrics::v3::HystrixSink>();
}

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.
Expand Down
1 change: 0 additions & 1 deletion source/extensions/stat_sinks/metrics_service/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/stat_sinks/metrics_service/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -48,7 +47,7 @@ ProtobufTypes::MessagePtr MetricsServiceSinkFactory::createEmptyConfigProto() {
std::make_unique<envoy::config::metrics::v3::MetricsServiceConfig>());
}

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.
Expand Down
1 change: 0 additions & 1 deletion source/extensions/stat_sinks/statsd/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/stat_sinks/statsd/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -45,7 +44,7 @@ ProtobufTypes::MessagePtr StatsdSinkFactory::createEmptyConfigProto() {
return std::make_unique<envoy::config::metrics::v3::StatsdSink>();
}

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.
Expand Down
1 change: 0 additions & 1 deletion source/extensions/stat_sinks/wasm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
3 changes: 1 addition & 2 deletions source/extensions/stat_sinks/wasm/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -56,7 +55,7 @@ ProtobufTypes::MessagePtr WasmSinkFactory::createEmptyConfigProto() {
return std::make_unique<envoy::extensions::stat_sinks::wasm::v3::Wasm>();
}

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.
Expand Down
9 changes: 4 additions & 5 deletions test/extensions/stats_sinks/dog_statsd/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions test/extensions/stats_sinks/hystrix/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;

Expand Down
13 changes: 6 additions & 7 deletions test/extensions/stats_sinks/statsd/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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";
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions test/extensions/stats_sinks/wasm/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -43,7 +42,7 @@ class WasmStatSinkConfigTest : public testing::TestWithParam<std::string> {

void initializeWithConfig(const envoy::extensions::stat_sinks::wasm::v3::Wasm& config) {
auto factory = Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::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_));
Expand Down
3 changes: 1 addition & 2 deletions test/server/configuration_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"}, {});

Expand Down

0 comments on commit 63f5e93

Please sign in to comment.