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

          Line data    Source code
       1             : #include "source/extensions/stat_sinks/graphite_statsd/config.h"
       2             : 
       3             : #include <memory>
       4             : 
       5             : #include "envoy/extensions/stat_sinks/graphite_statsd/v3/graphite_statsd.pb.h"
       6             : #include "envoy/extensions/stat_sinks/graphite_statsd/v3/graphite_statsd.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             : #include "source/extensions/stat_sinks/common/statsd/tag_formats.h"
      12             : 
      13             : namespace Envoy {
      14             : namespace Extensions {
      15             : namespace StatSinks {
      16             : namespace GraphiteStatsd {
      17             : 
      18             : Stats::SinkPtr
      19             : GraphiteStatsdSinkFactory::createStatsSink(const Protobuf::Message& config,
      20           0 :                                            Server::Configuration::ServerFactoryContext& server) {
      21             : 
      22           0 :   const auto& statsd_sink = MessageUtil::downcastAndValidate<
      23           0 :       const envoy::extensions::stat_sinks::graphite_statsd::v3::GraphiteStatsdSink&>(
      24           0 :       config, server.messageValidationContext().staticValidationVisitor());
      25           0 :   switch (statsd_sink.statsd_specifier_case()) {
      26           0 :   case envoy::extensions::stat_sinks::graphite_statsd::v3::GraphiteStatsdSink::StatsdSpecifierCase::
      27           0 :       kAddress: {
      28           0 :     Network::Address::InstanceConstSharedPtr address =
      29           0 :         Network::Address::resolveProtoAddress(statsd_sink.address());
      30           0 :     ENVOY_LOG(debug, "statsd UDP ip address: {}", address->asString());
      31           0 :     absl::optional<uint64_t> max_bytes;
      32           0 :     if (statsd_sink.has_max_bytes_per_datagram()) {
      33           0 :       max_bytes = statsd_sink.max_bytes_per_datagram().value();
      34           0 :     }
      35           0 :     return std::make_unique<Common::Statsd::UdpStatsdSink>(server.threadLocal(), std::move(address),
      36           0 :                                                            true, statsd_sink.prefix(), max_bytes,
      37           0 :                                                            Common::Statsd::getGraphiteTagFormat());
      38           0 :   }
      39           0 :   case envoy::extensions::stat_sinks::graphite_statsd::v3::GraphiteStatsdSink::StatsdSpecifierCase::
      40           0 :       STATSD_SPECIFIER_NOT_SET:
      41           0 :     break;
      42           0 :   }
      43           0 :   PANIC("unexpected statsd specifier enum");
      44           0 : }
      45             : 
      46           2 : ProtobufTypes::MessagePtr GraphiteStatsdSinkFactory::createEmptyConfigProto() {
      47           2 :   return std::make_unique<envoy::extensions::stat_sinks::graphite_statsd::v3::GraphiteStatsdSink>();
      48           2 : }
      49             : 
      50          42 : std::string GraphiteStatsdSinkFactory::name() const { return "envoy.stat_sinks.graphite_statsd"; }
      51             : 
      52             : /**
      53             :  * Static registration for the statsd sink factory. @see RegisterFactory.
      54             :  */
      55             : LEGACY_REGISTER_FACTORY(GraphiteStatsdSinkFactory, Server::Configuration::StatsSinkFactory,
      56             :                         "envoy.graphite_statsd");
      57             : 
      58             : } // namespace GraphiteStatsd
      59             : } // namespace StatSinks
      60             : } // namespace Extensions
      61             : } // namespace Envoy

Generated by: LCOV version 1.15