-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracing: add datadog extension (#4699)
Signed-off-by: Caleb Gilmour <caleb.gilmour@datadoghq.com>
- Loading branch information
1 parent
55e21f3
commit 46c0693
Showing
22 changed files
with
729 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
# Trace driver for Datadog (https://datadoghq.com/) | ||
|
||
load( | ||
"//bazel:envoy_build_system.bzl", | ||
"envoy_cc_library", | ||
"envoy_package", | ||
) | ||
|
||
envoy_package() | ||
|
||
envoy_cc_library( | ||
name = "datadog_tracer_lib", | ||
srcs = [ | ||
"datadog_tracer_impl.cc", | ||
], | ||
hdrs = [ | ||
"datadog_tracer_impl.h", | ||
], | ||
external_deps = ["dd_opentracing_cpp"], | ||
deps = [ | ||
"//source/common/tracing:http_tracer_lib", | ||
"//source/extensions/tracers:well_known_names", | ||
"//source/extensions/tracers/common/ot:opentracing_driver_lib", | ||
"//source/server:configuration_lib", | ||
], | ||
) | ||
|
||
envoy_cc_library( | ||
name = "config", | ||
srcs = ["config.cc"], | ||
hdrs = ["config.h"], | ||
deps = [ | ||
":datadog_tracer_lib", | ||
"//source/extensions/tracers:well_known_names", | ||
"//source/server:configuration_lib", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "extensions/tracers/datadog/config.h" | ||
|
||
#include "envoy/registry/registry.h" | ||
|
||
#include "common/common/utility.h" | ||
#include "common/tracing/http_tracer_impl.h" | ||
|
||
#include "extensions/tracers/datadog/datadog_tracer_impl.h" | ||
#include "extensions/tracers/well_known_names.h" | ||
|
||
#include "datadog/opentracing.h" | ||
|
||
namespace Envoy { | ||
namespace Extensions { | ||
namespace Tracers { | ||
namespace Datadog { | ||
|
||
Tracing::HttpTracerPtr | ||
DatadogTracerFactory::createHttpTracer(const envoy::config::trace::v2::Tracing& configuration, | ||
Server::Instance& server) { | ||
|
||
ProtobufTypes::MessagePtr config_ptr = createEmptyConfigProto(); | ||
|
||
if (configuration.http().has_config()) { | ||
MessageUtil::jsonConvert(configuration.http().config(), *config_ptr); | ||
} | ||
|
||
const auto& datadog_config = | ||
dynamic_cast<const envoy::config::trace::v2::DatadogConfig&>(*config_ptr); | ||
|
||
Tracing::DriverPtr datadog_driver{ | ||
std::make_unique<Driver>(datadog_config, server.clusterManager(), server.stats(), | ||
server.threadLocal(), server.runtime())}; | ||
return std::make_unique<Tracing::HttpTracerImpl>(std::move(datadog_driver), server.localInfo()); | ||
} | ||
|
||
std::string DatadogTracerFactory::name() { return TracerNames::get().Datadog; } | ||
|
||
/** | ||
* Static registration for the Datadog tracer. @see RegisterFactory. | ||
*/ | ||
static Registry::RegisterFactory<DatadogTracerFactory, Server::Configuration::TracerFactory> | ||
register_; | ||
|
||
} // namespace Datadog | ||
} // namespace Tracers | ||
} // namespace Extensions | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "envoy/server/instance.h" | ||
|
||
#include "server/configuration_impl.h" | ||
|
||
namespace Envoy { | ||
namespace Extensions { | ||
namespace Tracers { | ||
namespace Datadog { | ||
|
||
/** | ||
* Config registration for the Datadog tracer. @see TracerFactory. | ||
*/ | ||
class DatadogTracerFactory : public Server::Configuration::TracerFactory { | ||
public: | ||
// TracerFactory | ||
Tracing::HttpTracerPtr createHttpTracer(const envoy::config::trace::v2::Tracing& configuration, | ||
Server::Instance& server) override; | ||
|
||
ProtobufTypes::MessagePtr createEmptyConfigProto() override { | ||
return std::make_unique<envoy::config::trace::v2::DatadogConfig>(); | ||
} | ||
|
||
std::string name() override; | ||
}; | ||
|
||
} // namespace Datadog | ||
} // namespace Tracers | ||
} // namespace Extensions | ||
} // namespace Envoy |
Oops, something went wrong.