#include "extensions/stat_sinks/dog_statsd/config.h" #include #include "envoy/config/metrics/v3/stats.pb.h" #include "envoy/config/metrics/v3/stats.pb.validate.h" #include "envoy/registry/registry.h" #include "common/network/resolver_impl.h" #include "extensions/stat_sinks/common/statsd/statsd.h" #include "extensions/stat_sinks/well_known_names.h" #include "absl/types/optional.h" namespace Envoy { namespace Extensions { namespace StatSinks { namespace DogStatsd { Stats::SinkPtr DogStatsdSinkFactory::createStatsSink(const Protobuf::Message& config, Server::Configuration::ServerFactoryContext& server) { const auto& sink_config = MessageUtil::downcastAndValidate( config, server.messageValidationContext().staticValidationVisitor()); Network::Address::InstanceConstSharedPtr address = Network::Address::resolveProtoAddress(sink_config.address()); ENVOY_LOG(debug, "dog_statsd UDP ip address: {}", address->asString()); absl::optional max_bytes; if (sink_config.has_max_bytes_per_datagram()) { max_bytes = sink_config.max_bytes_per_datagram().value(); } return std::make_unique(server.threadLocal(), std::move(address), true, sink_config.prefix(), max_bytes); } ProtobufTypes::MessagePtr DogStatsdSinkFactory::createEmptyConfigProto() { return std::make_unique(); } std::string DogStatsdSinkFactory::name() const { return StatsSinkNames::get().DogStatsd; } /** * Static registration for the this sink factory. @see RegisterFactory. */ REGISTER_FACTORY(DogStatsdSinkFactory, Server::Configuration::StatsSinkFactory){"envoy.dog_statsd"}; } // namespace DogStatsd } // namespace StatSinks } // namespace Extensions } // namespace Envoy