Coverage Report

Created: 2023-11-12 09:30

/proc/self/cwd/source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.cc
Line
Count
Source (jump to first uncovered line)
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