Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat_sinks: remove well_known_names #16794

Merged
merged 11 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 DogStatsd; }

/**
* Static registration for the this sink factory. @see RegisterFactory.
Expand Down
3 changes: 3 additions & 0 deletions source/extensions/stat_sinks/dog_statsd/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace Extensions {
namespace StatSinks {
namespace DogStatsd {

// DogStatsD compatible statsd sink
const std::string DogStatsd = "envoy.stat_sinks.dog_statsd";
daixiang0 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Config registration for the DogStatsD compatible statsd sink. @see StatsSinkFactory.
*/
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 Hystrix; }

/**
* Static registration for the statsd sink factory. @see RegisterFactory.
Expand Down
3 changes: 3 additions & 0 deletions source/extensions/stat_sinks/hystrix/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace Extensions {
namespace StatSinks {
namespace Hystrix {

// Hystrix sink
const std::string Hystrix = "envoy.stat_sinks.hystrix";

class HystrixSinkFactory : Logger::Loggable<Logger::Id::config>,
public Server::Configuration::StatsSinkFactory {
public:
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 MetricsService; }

/**
* Static registration for the this sink factory. @see RegisterFactory.
Expand Down
3 changes: 3 additions & 0 deletions source/extensions/stat_sinks/metrics_service/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
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 Statsd; }

/**
* Static registration for the statsd sink factory. @see RegisterFactory.
Expand Down
3 changes: 3 additions & 0 deletions source/extensions/stat_sinks/statsd/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
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 Wasm; }

/**
* Static registration for the wasm access log. @see RegisterFactory.
Expand Down
3 changes: 3 additions & 0 deletions source/extensions/stat_sinks/wasm/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
35 changes: 0 additions & 35 deletions source/extensions/stat_sinks/well_known_names.h

This file was deleted.

21 changes: 5 additions & 16 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,8 +29,6 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, DogStatsdConfigLoopbackTest,
TestUtility::ipTestParamsToString);

TEST_P(DogStatsdConfigLoopbackTest, ValidUdpIp) {
const std::string name = StatsSinkNames::get().DogStatsd;

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();
Expand All @@ -42,7 +39,7 @@ TEST_P(DogStatsdConfigLoopbackTest, ValidUdpIp) {
socket_address.set_port_value(8125);

Server::Configuration::StatsSinkFactory* factory =
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(name);
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(DogStatsd);
ASSERT_NE(factory, nullptr);

ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto();
Expand All @@ -66,8 +63,6 @@ TEST(DogStatsdConfigTest, ValidateFail) {
}

TEST_P(DogStatsdConfigLoopbackTest, CustomBufferSize) {
const std::string name = StatsSinkNames::get().DogStatsd;

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();
Expand All @@ -79,7 +74,7 @@ TEST_P(DogStatsdConfigLoopbackTest, CustomBufferSize) {
socket_address.set_port_value(8125);

Server::Configuration::StatsSinkFactory* factory =
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(name);
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(DogStatsd);
ASSERT_NE(factory, nullptr);

ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto();
Expand All @@ -94,8 +89,6 @@ TEST_P(DogStatsdConfigLoopbackTest, CustomBufferSize) {
}

TEST_P(DogStatsdConfigLoopbackTest, DefaultBufferSize) {
const std::string name = StatsSinkNames::get().DogStatsd;

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();
Expand All @@ -106,7 +99,7 @@ TEST_P(DogStatsdConfigLoopbackTest, DefaultBufferSize) {
socket_address.set_port_value(8125);

Server::Configuration::StatsSinkFactory* factory =
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(name);
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(DogStatsd);
ASSERT_NE(factory, nullptr);

ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto();
Expand All @@ -122,8 +115,6 @@ TEST_P(DogStatsdConfigLoopbackTest, DefaultBufferSize) {
}

TEST_P(DogStatsdConfigLoopbackTest, WithCustomPrefix) {
const std::string name = StatsSinkNames::get().DogStatsd;

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();
Expand All @@ -137,7 +128,7 @@ TEST_P(DogStatsdConfigLoopbackTest, WithCustomPrefix) {
sink_config.set_prefix(customPrefix);

Server::Configuration::StatsSinkFactory* factory =
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(name);
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(DogStatsd);
ASSERT_NE(factory, nullptr);

ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto();
Expand All @@ -153,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<Server::Configuration::StatsSinkFactory>::getFactory(
deprecated_name));
DogStatsd));
}

} // namespace
Expand Down
5 changes: 1 addition & 4 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,12 +22,10 @@ namespace Hystrix {
namespace {

TEST(StatsConfigTest, ValidHystrixSink) {
const std::string name = StatsSinkNames::get().Hystrix;

envoy::config::metrics::v3::HystrixSink sink_config;

Server::Configuration::StatsSinkFactory* factory =
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(name);
Registry::FactoryRegistry<Server::Configuration::StatsSinkFactory>::getFactory(Hystrix);
ASSERT_NE(factory, nullptr);

ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto();
Expand Down
4 changes: 1 addition & 3 deletions test/extensions/stats_sinks/metrics_service/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Server::Configuration::StatsSinkFactory>::getFactory(
deprecated_name));
MetricsService));
}

} // namespace
Expand Down
Loading