Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/runtime/runtime.h" 4 : #include "envoy/thread_local/thread_local.h" 5 : #include "envoy/upstream/cluster_manager.h" 6 : 7 : #include "source/extensions/tracers/common/ot/opentracing_driver_impl.h" 8 : 9 : #include "opentracing/dynamic_load.h" 10 : 11 : namespace Envoy { 12 : namespace Extensions { 13 : namespace Tracers { 14 : namespace DynamicOt { 15 : 16 : /** 17 : * This driver provides support for dynamically loading tracing libraries into Envoy that provide an 18 : * implementation of the OpenTracing API (see https://github.com/opentracing/opentracing-cpp). 19 : * TODO(rnburn): Add an example showing how to use a tracer library with this driver. 20 : */ 21 : class DynamicOpenTracingDriver : public Common::Ot::OpenTracingDriver { 22 : public: 23 : DynamicOpenTracingDriver(Stats::Scope& scope, const std::string& library, 24 : const std::string& tracer_config); 25 : 26 : static std::string formatErrorMessage(std::error_code error_code, 27 : const std::string& error_message); 28 : 29 : // Tracer::OpenTracingDriver 30 0 : opentracing::Tracer& tracer() override { return *tracer_; } 31 : 32 0 : PropagationMode propagationMode() const override { 33 0 : return OpenTracingDriver::PropagationMode::TracerNative; 34 0 : } 35 : 36 : private: 37 : opentracing::DynamicTracingLibraryHandle library_handle_; 38 : std::shared_ptr<opentracing::Tracer> tracer_; 39 : }; 40 : 41 : } // namespace DynamicOt 42 : } // namespace Tracers 43 : } // namespace Extensions 44 : } // namespace Envoy