LCOV - code coverage report
Current view: top level - source/extensions/stat_sinks/dog_statsd - config.cc (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 4 18 22.2 %
Date: 2024-01-05 06:35:25 Functions: 2 3 66.7 %

          Line data    Source code
       1             : #include "source/extensions/stat_sinks/dog_statsd/config.h"
       2             : 
       3             : #include <memory>
       4             : 
       5             : #include "envoy/config/metrics/v3/stats.pb.h"
       6             : #include "envoy/config/metrics/v3/stats.pb.validate.h"
       7             : #include "envoy/registry/registry.h"
       8             : 
       9             : #include "source/common/network/resolver_impl.h"
      10             : #include "source/extensions/stat_sinks/common/statsd/statsd.h"
      11             : 
      12             : #include "absl/types/optional.h"
      13             : 
      14             : namespace Envoy {
      15             : namespace Extensions {
      16             : namespace StatSinks {
      17             : namespace DogStatsd {
      18             : 
      19             : Stats::SinkPtr
      20             : DogStatsdSinkFactory::createStatsSink(const Protobuf::Message& config,
      21           0 :                                       Server::Configuration::ServerFactoryContext& server) {
      22           0 :   const auto& sink_config =
      23           0 :       MessageUtil::downcastAndValidate<const envoy::config::metrics::v3::DogStatsdSink&>(
      24           0 :           config, server.messageValidationContext().staticValidationVisitor());
      25           0 :   Network::Address::InstanceConstSharedPtr address =
      26           0 :       Network::Address::resolveProtoAddress(sink_config.address());
      27           0 :   ENVOY_LOG(debug, "dog_statsd UDP ip address: {}", address->asString());
      28           0 :   absl::optional<uint64_t> max_bytes;
      29           0 :   if (sink_config.has_max_bytes_per_datagram()) {
      30           0 :     max_bytes = sink_config.max_bytes_per_datagram().value();
      31           0 :   }
      32           0 :   return std::make_unique<Common::Statsd::UdpStatsdSink>(server.threadLocal(), std::move(address),
      33           0 :                                                          true, sink_config.prefix(), max_bytes);
      34           0 : }
      35             : 
      36           2 : ProtobufTypes::MessagePtr DogStatsdSinkFactory::createEmptyConfigProto() {
      37           2 :   return std::make_unique<envoy::config::metrics::v3::DogStatsdSink>();
      38           2 : }
      39             : 
      40          42 : std::string DogStatsdSinkFactory::name() const { return DogStatsdName; }
      41             : 
      42             : /**
      43             :  * Static registration for the this sink factory. @see RegisterFactory.
      44             :  */
      45             : LEGACY_REGISTER_FACTORY(DogStatsdSinkFactory, Server::Configuration::StatsSinkFactory,
      46             :                         "envoy.dog_statsd");
      47             : 
      48             : } // namespace DogStatsd
      49             : } // namespace StatSinks
      50             : } // namespace Extensions
      51             : } // namespace Envoy

Generated by: LCOV version 1.15