Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/common/pure.h" 4 : #include "envoy/config/typed_config.h" 5 : #include "envoy/server/filter_config.h" 6 : #include "envoy/tracing/tracer.h" 7 : 8 : #include "source/common/protobuf/protobuf.h" 9 : 10 : namespace Envoy { 11 : namespace Server { 12 : namespace Configuration { 13 : 14 : /** 15 : * Context passed to HTTP tracers to access server resources. 16 : */ 17 : class TracerFactoryContext { 18 : public: 19 96 : virtual ~TracerFactoryContext() = default; 20 : 21 : /** 22 : * @return ServerFactoryContext which lifetime is no shorter than the server. 23 : */ 24 : virtual ServerFactoryContext& serverFactoryContext() PURE; 25 : 26 : /** 27 : * @return ProtobufMessage::ValidationVisitor& validation visitor for tracer configuration 28 : * messages. 29 : */ 30 : virtual ProtobufMessage::ValidationVisitor& messageValidationVisitor() PURE; 31 : }; 32 : 33 : using TracerFactoryContextPtr = std::unique_ptr<TracerFactoryContext>; 34 : 35 : /** 36 : * Implemented by each Tracer and registered via Registry::registerFactory() or the convenience 37 : * class RegisterFactory. 38 : */ 39 : class TracerFactory : public Config::TypedFactory { 40 : public: 41 0 : ~TracerFactory() override = default; 42 : 43 : /** 44 : * Create a particular trace driver implementation. If the implementation is unable to produce 45 : * a trace driver with the provided parameters, it should throw an EnvoyException in the case 46 : * of general error or a Json::Exception if the json configuration is erroneous. The returned 47 : * pointer should always be valid. 48 : * 49 : * NOTE: Due to the corner case of OpenCensus, who can only support a single tracing 50 : * configuration per entire process, the returned Driver instance is not guaranteed 51 : * to be unique. 52 : * That is why the return type has been changed to std::shared_ptr<> instead of a more 53 : * idiomatic std::unique_ptr<>. 54 : * 55 : * @param config supplies the proto configuration for the Tracer 56 : * @param context supplies the factory context 57 : */ 58 : virtual Tracing::DriverSharedPtr createTracerDriver(const Protobuf::Message& config, 59 : TracerFactoryContext& context) PURE; 60 : 61 16 : std::string category() const override { return "envoy.tracers"; } 62 : }; 63 : 64 : } // namespace Configuration 65 : } // namespace Server 66 : } // namespace Envoy