LCOV - code coverage report
Current view: top level - source/extensions/tracers/opencensus - config.cc (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 1 14 7.1 %
Date: 2024-01-05 06:35:25 Functions: 1 2 50.0 %

          Line data    Source code
       1             : #include "source/extensions/tracers/opencensus/config.h"
       2             : 
       3             : #include "envoy/config/trace/v3/opencensus.pb.h"
       4             : #include "envoy/config/trace/v3/opencensus.pb.validate.h"
       5             : #include "envoy/registry/registry.h"
       6             : 
       7             : #include "source/extensions/tracers/opencensus/opencensus_tracer_impl.h"
       8             : 
       9             : namespace Envoy {
      10             : namespace Extensions {
      11             : namespace Tracers {
      12             : namespace OpenCensus {
      13             : 
      14           2 : OpenCensusTracerFactory::OpenCensusTracerFactory() : FactoryBase("envoy.tracers.opencensus") {}
      15             : 
      16             : Tracing::DriverSharedPtr OpenCensusTracerFactory::createTracerDriverTyped(
      17             :     const envoy::config::trace::v3::OpenCensusConfig& proto_config,
      18           0 :     Server::Configuration::TracerFactoryContext& context) {
      19             :   // Since OpenCensus can only support a single tracing configuration per entire process,
      20             :   // we need to make sure that it is configured at most once.
      21           0 :   if (driver_) {
      22           0 :     if (Envoy::Protobuf::util::MessageDifferencer::Equals(config_, proto_config)) {
      23           0 :       return driver_;
      24           0 :     } else {
      25           0 :       throw EnvoyException("Opencensus has already been configured with a different config.");
      26           0 :     }
      27           0 :   }
      28             : 
      29           0 :   driver_ = std::make_shared<Driver>(proto_config, context.serverFactoryContext().localInfo(),
      30           0 :                                      context.serverFactoryContext().api());
      31           0 :   config_ = proto_config;
      32           0 :   return driver_;
      33           0 : }
      34             : 
      35             : /**
      36             :  * Static registration for the OpenCensus tracer. @see RegisterFactory.
      37             :  */
      38             : REGISTER_FACTORY(OpenCensusTracerFactory, Server::Configuration::TracerFactory);
      39             : 
      40             : } // namespace OpenCensus
      41             : } // namespace Tracers
      42             : } // namespace Extensions
      43             : } // namespace Envoy

Generated by: LCOV version 1.15