/proc/self/cwd/source/extensions/tracers/opencensus/config.cc
Line | Count | Source (jump to first uncovered line) |
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 | 4 | 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()); |
30 | 0 | config_ = proto_config; |
31 | 0 | return driver_; |
32 | 0 | } |
33 | | |
34 | | /** |
35 | | * Static registration for the OpenCensus tracer. @see RegisterFactory. |
36 | | */ |
37 | | REGISTER_FACTORY(OpenCensusTracerFactory, Server::Configuration::TracerFactory); |
38 | | |
39 | | } // namespace OpenCensus |
40 | | } // namespace Tracers |
41 | | } // namespace Extensions |
42 | | } // namespace Envoy |