/proc/self/cwd/source/extensions/tracers/datadog/config.cc
Line | Count | Source (jump to first uncovered line) |
1 | | #include "source/extensions/tracers/datadog/config.h" |
2 | | |
3 | | #include <datadog/runtime_id.h> |
4 | | #include <datadog/tracer_config.h> |
5 | | |
6 | | #include <memory> |
7 | | |
8 | | #include "envoy/config/trace/v3/datadog.pb.h" |
9 | | #include "envoy/config/trace/v3/datadog.pb.validate.h" |
10 | | #include "envoy/registry/registry.h" |
11 | | |
12 | | #include "source/common/version/version.h" |
13 | | #include "source/extensions/tracers/datadog/tracer.h" |
14 | | |
15 | | namespace Envoy { |
16 | | namespace Extensions { |
17 | | namespace Tracers { |
18 | | namespace Datadog { |
19 | | |
20 | 4 | DatadogTracerFactory::DatadogTracerFactory() : FactoryBase("envoy.tracers.datadog") {} |
21 | | |
22 | | datadog::tracing::TracerConfig |
23 | 0 | DatadogTracerFactory::makeConfig(const envoy::config::trace::v3::DatadogConfig& proto_config) { |
24 | 0 | datadog::tracing::TracerConfig config; |
25 | 0 | config.version = "envoy " + Envoy::VersionInfo::version(); |
26 | 0 | config.name = "envoy.proxy"; |
27 | 0 | if (proto_config.service_name().empty()) { |
28 | 0 | config.service = "envoy"; |
29 | 0 | } else { |
30 | 0 | config.service = proto_config.service_name(); |
31 | 0 | } |
32 | |
|
33 | 0 | if (proto_config.has_remote_config()) { |
34 | 0 | const auto& proto_remote_config = proto_config.remote_config(); |
35 | 0 | config.agent.remote_configuration_enabled = true; |
36 | |
|
37 | 0 | if (proto_remote_config.has_polling_interval()) { |
38 | 0 | config.agent.remote_configuration_poll_interval_seconds = |
39 | 0 | proto_remote_config.polling_interval().seconds(); |
40 | 0 | } |
41 | 0 | } else { |
42 | 0 | config.agent.remote_configuration_enabled = false; |
43 | 0 | } |
44 | |
|
45 | 0 | config.integration_name = "envoy"; |
46 | 0 | config.integration_version = Envoy::VersionInfo::version(); |
47 | |
|
48 | 0 | return config; |
49 | 0 | } |
50 | | |
51 | | std::string DatadogTracerFactory::makeCollectorReferenceHost( |
52 | 0 | const envoy::config::trace::v3::DatadogConfig& proto_config) { |
53 | 0 | std::string collector_reference_host = proto_config.collector_hostname(); |
54 | 0 | if (collector_reference_host.empty()) { |
55 | 0 | collector_reference_host = proto_config.collector_cluster(); |
56 | 0 | } |
57 | 0 | return collector_reference_host; |
58 | 0 | } |
59 | | |
60 | | Tracing::DriverSharedPtr DatadogTracerFactory::createTracerDriverTyped( |
61 | | const envoy::config::trace::v3::DatadogConfig& proto_config, |
62 | 0 | Server::Configuration::TracerFactoryContext& context) { |
63 | 0 | auto& factory_context = context.serverFactoryContext(); |
64 | 0 | return std::make_shared<Tracer>( |
65 | 0 | proto_config.collector_cluster(), makeCollectorReferenceHost(proto_config), |
66 | 0 | makeConfig(proto_config), factory_context.clusterManager(), factory_context.scope(), |
67 | 0 | factory_context.threadLocal(), factory_context.timeSource()); |
68 | 0 | } |
69 | | |
70 | | /** |
71 | | * Static registration for the Datadog tracer. @see RegisterFactory. |
72 | | */ |
73 | | REGISTER_FACTORY(DatadogTracerFactory, Server::Configuration::TracerFactory); |
74 | | |
75 | | } // namespace Datadog |
76 | | } // namespace Tracers |
77 | | } // namespace Extensions |
78 | | } // namespace Envoy |