Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/server/tracer_config.h" 4 : 5 : namespace Envoy { 6 : namespace Extensions { 7 : namespace Tracers { 8 : namespace Common { 9 : 10 : /** 11 : * Common base class for tracer factory registrations. Removes a substantial amount of 12 : * boilerplate. 13 : */ 14 : template <class ConfigProto> class FactoryBase : public Server::Configuration::TracerFactory { 15 : public: 16 : // Server::Configuration::TracerFactory 17 : Tracing::DriverSharedPtr 18 : createTracerDriver(const Protobuf::Message& config, 19 0 : Server::Configuration::TracerFactoryContext& context) override { 20 0 : return createTracerDriverTyped(MessageUtil::downcastAndValidate<const ConfigProto&>( 21 0 : config, context.messageValidationVisitor()), 22 0 : context); 23 0 : } 24 : 25 9 : ProtobufTypes::MessagePtr createEmptyConfigProto() override { 26 9 : return std::make_unique<ConfigProto>(); 27 9 : } 28 : 29 274 : std::string name() const override { return name_; } 30 : 31 : protected: 32 14 : FactoryBase(const std::string& name) : name_(name) {} 33 : 34 : private: 35 : virtual Tracing::DriverSharedPtr 36 : createTracerDriverTyped(const ConfigProto& proto_config, 37 : Server::Configuration::TracerFactoryContext& context) PURE; 38 : 39 : const std::string name_; 40 : }; 41 : 42 : } // namespace Common 43 : } // namespace Tracers 44 : } // namespace Extensions 45 : } // namespace Envoy