-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made stats sinks a statically registered component (#1506)
This is part of a larger effort to make various implementations more flexible by allowing proprietary components to be statically registered with Envoy needing only to be linked to the binary at build time and configured at runtime #967 . The user-visible configuration changes do involve a few deprecations: statsd_udp_ip_address and statsd_tcp_cluster_name will be deprecated, and their equivalents will be moved to a new stats_sinks array where the configurations for any statically registered sink will exist. As a part of this change, all integration tests were moved to the new configuration format, but a new configuration test was added to ensure that the deprecated format continues to work until it is removed in 1.5.0.
- Loading branch information
Showing
84 changed files
with
433 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
load( | ||
"//bazel:envoy_build_system.bzl", | ||
"envoy_cc_library", | ||
"envoy_package", | ||
) | ||
|
||
envoy_package() | ||
|
||
envoy_cc_library( | ||
name = "statsd_lib", | ||
srcs = ["statsd.cc"], | ||
hdrs = ["statsd.h"], | ||
external_deps = [ | ||
"envoy_bootstrap", | ||
], | ||
deps = [ | ||
"//include/envoy/registry", | ||
"//source/common/network:address_lib", | ||
"//source/common/stats:statsd_lib", | ||
"//source/server:configuration_lib", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "server/config/stats/statsd.h" | ||
|
||
#include <string> | ||
|
||
#include "envoy/registry/registry.h" | ||
|
||
#include "common/stats/statsd.h" | ||
|
||
#include "api/bootstrap.pb.h" | ||
|
||
namespace Envoy { | ||
namespace Server { | ||
namespace Configuration { | ||
|
||
Stats::SinkPtr StatsdSinkFactory::createStatsSink(const Protobuf::Message& config, | ||
Server::Instance& server) { | ||
|
||
const auto& statsd_sink = dynamic_cast<const envoy::api::v2::StatsdSink&>(config); | ||
switch (statsd_sink.statsd_specifier_case()) { | ||
case envoy::api::v2::StatsdSink::kAddress: { | ||
Network::Address::InstanceConstSharedPtr address = | ||
Network::Utility::fromProtoAddress(statsd_sink.address()); | ||
ENVOY_LOG(info, "statsd UDP ip address: {}", address->asString()); | ||
return Stats::SinkPtr( | ||
new Stats::Statsd::UdpStatsdSink(server.threadLocal(), std::move(address))); | ||
break; | ||
} | ||
case envoy::api::v2::StatsdSink::kTcpClusterName: | ||
ENVOY_LOG(info, "statsd TCP cluster: {}", statsd_sink.tcp_cluster_name()); | ||
return Stats::SinkPtr(new Stats::Statsd::TcpStatsdSink( | ||
server.localInfo(), statsd_sink.tcp_cluster_name(), server.threadLocal(), | ||
server.clusterManager(), server.stats())); | ||
break; | ||
default: | ||
throw EnvoyException( | ||
fmt::format("No tcp_cluster_name or address provided for {} Stats::Sink config", name())); | ||
} | ||
} | ||
|
||
ProtobufTypes::MessagePtr StatsdSinkFactory::createEmptyConfigProto() { | ||
return std::unique_ptr<envoy::api::v2::StatsdSink>(new envoy::api::v2::StatsdSink()); | ||
} | ||
|
||
std::string StatsdSinkFactory::name() { return "envoy.statsd"; } | ||
|
||
/** | ||
* Static registration for the statsd sink factory. @see RegisterFactory. | ||
*/ | ||
static Registry::RegisterFactory<StatsdSinkFactory, StatsSinkFactory> register_; | ||
|
||
} // namespace Configuration | ||
} // namespace Server | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "envoy/server/instance.h" | ||
|
||
#include "server/configuration_impl.h" | ||
|
||
namespace Envoy { | ||
namespace Server { | ||
namespace Configuration { | ||
|
||
/** | ||
* Config registration for the tcp statsd sink. @see StatsSinkFactory. | ||
*/ | ||
class StatsdSinkFactory : Logger::Loggable<Logger::Id::config>, public StatsSinkFactory { | ||
public: | ||
// StatsSinkFactory | ||
Stats::SinkPtr createStatsSink(const Protobuf::Message& config, Instance& server) override; | ||
|
||
ProtobufTypes::MessagePtr createEmptyConfigProto() override; | ||
|
||
std::string name() override; | ||
}; | ||
|
||
} // namespace Configuration | ||
} // namespace Server | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.