LCOV - code coverage report
Current view: top level - source/extensions/tracers/dynamic_ot - dynamic_opentracing_driver_impl.cc (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 23 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #include "source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h"
       2             : 
       3             : #include "source/common/common/assert.h"
       4             : 
       5             : namespace Envoy {
       6             : namespace Extensions {
       7             : namespace Tracers {
       8             : namespace DynamicOt {
       9             : 
      10             : DynamicOpenTracingDriver::DynamicOpenTracingDriver(Stats::Scope& scope, const std::string& library,
      11             :                                                    const std::string& tracer_config)
      12           0 :     : OpenTracingDriver{scope} {
      13           0 :   std::string error_message;
      14           0 :   opentracing::expected<opentracing::DynamicTracingLibraryHandle> library_handle_maybe =
      15           0 :       opentracing::DynamicallyLoadTracingLibrary(library.c_str(), error_message);
      16           0 :   if (!library_handle_maybe) {
      17           0 :     throw EnvoyException{formatErrorMessage(library_handle_maybe.error(), error_message)};
      18           0 :   }
      19           0 :   library_handle_ = std::move(*library_handle_maybe);
      20             : 
      21           0 :   opentracing::expected<std::shared_ptr<opentracing::Tracer>> tracer_maybe =
      22           0 :       library_handle_.tracer_factory().MakeTracer(tracer_config.c_str(), error_message);
      23           0 :   if (!tracer_maybe) {
      24           0 :     throw EnvoyException{formatErrorMessage(tracer_maybe.error(), error_message)};
      25           0 :   }
      26           0 :   tracer_ = std::move(*tracer_maybe);
      27           0 :   RELEASE_ASSERT(tracer_ != nullptr, "");
      28           0 : }
      29             : 
      30             : std::string DynamicOpenTracingDriver::formatErrorMessage(std::error_code error_code,
      31           0 :                                                          const std::string& error_message) {
      32           0 :   if (error_message.empty()) {
      33           0 :     return absl::StrCat("", error_code.message());
      34           0 :   } else {
      35           0 :     return fmt::format("{}: {}", error_code.message(), error_message);
      36           0 :   }
      37           0 : }
      38             : 
      39             : } // namespace DynamicOt
      40             : } // namespace Tracers
      41             : } // namespace Extensions
      42             : } // namespace Envoy

Generated by: LCOV version 1.15