Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions REPO_LAYOUT.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ currently implemented but that is the plan moving forward.)
* These are the top level extension directories and associated namespaces:
* [access_loggers/](/source/extensions/access_loggers): Access log implementations which use
the `Envoy::Extensions::AccessLoggers` namespace.
* [http_tracers/](/source/extensions/http_tracers): HTTP tracers which use the
`Envoy::Extensions::HttpTracers` namespace.
* [filters/http/](/source/extensions/filters/http): HTTP L7 filters which use the
`Envoy::Extensions::HttpFilters` namespace.
* [filters/listener/](/source/extensions/filters/listener): Listener filters which use the
Expand All @@ -83,6 +81,8 @@ currently implemented but that is the plan moving forward.)
`Envoy::Extensions::Resolvers` namespace.
* [stat_sinks/](/source/extensions/stat_sinks): Stat sink implementations which use the
`Envoy::Extensions::StatSinks` namespace.
* [tracers/](/source/extensions/tracers): Tracers which use the
`Envoy::Extensions::Tracers` namespace.
* [transport_sockets/](/source/extensions/transport_sockets): Transport socket implementations
which use the `Envoy::Extensions::TransportSockets` namespace.
* Each extension is contained wholly in its own namespace. E.g.,
Expand Down
13 changes: 8 additions & 5 deletions source/common/config/well_known_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ class HttpFilterNameValues {
typedef ConstSingleton<HttpFilterNameValues> HttpFilterNames;

/**
* Well-known HTTP tracer names.
* Well-known tracer names.
* TODO(mattklein123): Move this to extensions directory when the migration is complete.
* TODO(mattklein123): New tracers should use the well known name: envoy.tracers.name.
*/
class HttpTracerNameValues {
class TracerNameValues {
public:
// Lightstep tracer
const std::string LIGHTSTEP = "envoy.lightstep";
Expand All @@ -168,12 +170,12 @@ class HttpTracerNameValues {
const std::string DYNAMIC_OT = "envoy.dynamic.ot";
};

typedef ConstSingleton<HttpTracerNameValues> HttpTracerNames;
typedef ConstSingleton<TracerNameValues> TracerNames;

/**
* Well-known stats sink names.
* TODO(mattklein123): Move this to extensions directory when the migration is complete.
* TODO(mattklein123): New filters should use the well known name: envoy.stat_sinks.name.
* TODO(mattklein123): New sinks should use the well known name: envoy.stat_sinks.name.
*/
class StatsSinkNameValues {
public:
Expand All @@ -190,7 +192,8 @@ typedef ConstSingleton<StatsSinkNameValues> StatsSinkNames;
/**
* Well-known access log names.
* TODO(mattklein123): Move this to extensions directory when the migration is complete.
* TODO(mattklein123): New filters should use the well known name: envoy.access_loggers.name.
* TODO(mattklein123): New access loggers should use the well known name:
* envoy.access_loggers.name.
*/
class AccessLogNameValues {
public:
Expand Down
43 changes: 0 additions & 43 deletions source/common/tracing/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,46 +38,3 @@ envoy_cc_library(
"//source/common/runtime:uuid_util_lib",
],
)

envoy_cc_library(
name = "opentracing_driver_lib",
srcs = [
"opentracing_driver_impl.cc",
],
hdrs = [
"opentracing_driver_impl.h",
],
external_deps = ["opentracing"],
deps = [
":http_tracer_lib",
],
)

envoy_cc_library(
name = "dynamic_opentracing_driver_lib",
srcs = [
"dynamic_opentracing_driver_impl.cc",
],
hdrs = [
"dynamic_opentracing_driver_impl.h",
],
deps = [
":http_tracer_lib",
":opentracing_driver_lib",
],
)

envoy_cc_library(
name = "lightstep_tracer_lib",
srcs = [
"lightstep_tracer_impl.cc",
],
hdrs = [
"lightstep_tracer_impl.h",
],
external_deps = ["lightstep"],
deps = [
":http_tracer_lib",
":opentracing_driver_lib",
],
)
3 changes: 0 additions & 3 deletions source/exe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ envoy_cc_library(
srcs = ["main.cc"],
deps = [
":envoy_main_common_lib",
"//source/server/config/http:dynamic_opentracing_lib",
"//source/server/config/http:lightstep_lib",
"//source/server/config/http:zipkin_lib",
],
)

Expand Down
3 changes: 3 additions & 0 deletions source/extensions/all_extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ def envoy_all_extensions(repository = ""):
repository + "//source/extensions/stat_sinks/dog_statsd:config",
repository + "//source/extensions/stat_sinks/metrics_service:config",
repository + "//source/extensions/stat_sinks/statsd:config",
repository + "//source/extensions/tracers/dynamic_ot:config",
repository + "//source/extensions/tracers/lightstep:config",
repository + "//source/extensions/tracers/zipkin:config",
]

23 changes: 23 additions & 0 deletions source/extensions/tracers/common/ot/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
licenses(["notice"]) # Apache 2

load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_package",
)

envoy_package()

envoy_cc_library(
name = "opentracing_driver_lib",
srcs = [
"opentracing_driver_impl.cc",
],
hdrs = [
"opentracing_driver_impl.h",
],
external_deps = ["opentracing"],
deps = [
"//source/common/tracing:http_tracer_lib",
],
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "common/tracing/opentracing_driver_impl.h"
#include "extensions/tracers/common/ot/opentracing_driver_impl.h"

#include <sstream>

Expand All @@ -7,7 +7,10 @@
#include "common/common/utility.h"

namespace Envoy {
namespace Tracing {
namespace Extensions {
namespace Tracers {
namespace Common {
namespace Ot {

namespace {
class OpenTracingHTTPHeadersWriter : public opentracing::HTTPHeadersWriter {
Expand Down Expand Up @@ -117,19 +120,22 @@ void OpenTracingSpan::injectContext(Http::HeaderMap& request_headers) {
}
}

SpanPtr OpenTracingSpan::spawnChild(const Config&, const std::string& name, SystemTime start_time) {
Tracing::SpanPtr OpenTracingSpan::spawnChild(const Tracing::Config&, const std::string& name,
SystemTime start_time) {
std::unique_ptr<opentracing::Span> ot_span = span_->tracer().StartSpan(
name, {opentracing::ChildOf(&span_->context()), opentracing::StartTimestamp(start_time)});
RELEASE_ASSERT(ot_span != nullptr);
return SpanPtr{new OpenTracingSpan{driver_, std::move(ot_span)}};
return Tracing::SpanPtr{new OpenTracingSpan{driver_, std::move(ot_span)}};
}

OpenTracingDriver::OpenTracingDriver(Stats::Store& stats)
: tracer_stats_{OPENTRACING_TRACER_STATS(POOL_COUNTER_PREFIX(stats, "tracing.opentracing."))} {}

SpanPtr OpenTracingDriver::startSpan(const Config&, Http::HeaderMap& request_headers,
const std::string& operation_name, SystemTime start_time,
const Tracing::Decision tracing_decision) {
Tracing::SpanPtr OpenTracingDriver::startSpan(const Tracing::Config&,
Http::HeaderMap& request_headers,
const std::string& operation_name,
SystemTime start_time,
const Tracing::Decision tracing_decision) {
// If tracing decision is no, and sampling decision is not communicated via tags, then
// return a null span to indicate that tracing is not being performed.
if (!tracing_decision.traced && !useTagForSamplingDecision()) {
Expand Down Expand Up @@ -179,8 +185,11 @@ SpanPtr OpenTracingDriver::startSpan(const Config&, Http::HeaderMap& request_hea
}
active_span = tracer.StartSpanWithOptions(operation_name, options);
RELEASE_ASSERT(active_span != nullptr);
return SpanPtr{new OpenTracingSpan{*this, std::move(active_span)}};
return Tracing::SpanPtr{new OpenTracingSpan{*this, std::move(active_span)}};
}

} // namespace Tracing
} // namespace Ot
} // namespace Common
} // namespace Tracers
} // namespace Extensions
} // namespace Envoy
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
#include "opentracing/tracer.h"

namespace Envoy {
namespace Tracing {
namespace Extensions {
namespace Tracers {
namespace Common {
namespace Ot {

#define OPENTRACING_TRACER_STATS(COUNTER) \
COUNTER(span_context_extraction_error) \
Expand All @@ -23,7 +26,7 @@ struct OpenTracingTracerStats {

class OpenTracingDriver;

class OpenTracingSpan : public Span, Logger::Loggable<Logger::Id::tracing> {
class OpenTracingSpan : public Tracing::Span, Logger::Loggable<Logger::Id::tracing> {
public:
OpenTracingSpan(OpenTracingDriver& driver, std::unique_ptr<opentracing::Span>&& span);

Expand All @@ -32,7 +35,8 @@ class OpenTracingSpan : public Span, Logger::Loggable<Logger::Id::tracing> {
void setOperation(const std::string& operation) override;
void setTag(const std::string& name, const std::string& value) override;
void injectContext(Http::HeaderMap& request_headers) override;
SpanPtr spawnChild(const Config& config, const std::string& name, SystemTime start_time) override;
Tracing::SpanPtr spawnChild(const Tracing::Config& config, const std::string& name,
SystemTime start_time) override;

private:
OpenTracingDriver& driver_;
Expand All @@ -45,14 +49,14 @@ class OpenTracingSpan : public Span, Logger::Loggable<Logger::Id::tracing> {
* minimal amount of effort. Libraries need only provide an opentracing::Tracer implementation; the
* rest of span creation is taken care of by this class.
*/
class OpenTracingDriver : public Driver, protected Logger::Loggable<Logger::Id::tracing> {
class OpenTracingDriver : public Tracing::Driver, protected Logger::Loggable<Logger::Id::tracing> {
public:
explicit OpenTracingDriver(Stats::Store& stats);

// Tracer::TracingDriver
SpanPtr startSpan(const Config& config, Http::HeaderMap& request_headers,
const std::string& operation_name, SystemTime start_time,
const Tracing::Decision tracing_decision) override;
Tracing::SpanPtr startSpan(const Tracing::Config& config, Http::HeaderMap& request_headers,
const std::string& operation_name, SystemTime start_time,
const Tracing::Decision tracing_decision) override;

virtual opentracing::Tracer& tracer() PURE;

Expand All @@ -73,6 +77,8 @@ class OpenTracingDriver : public Driver, protected Logger::Loggable<Logger::Id::
private:
OpenTracingTracerStats tracer_stats_;
};

} // namespace Tracing
}
} // namespace Common
} // namespace Tracers
} // namespace Extensions
} // namespace Envoy
35 changes: 35 additions & 0 deletions source/extensions/tracers/dynamic_ot/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
licenses(["notice"]) # Apache 2
# Trace driver for dynamically loadable C++ OpenTracing drivers (http://opentracing.io/).

load(
"//bazel:envoy_build_system.bzl",
"envoy_cc_library",
"envoy_package",
)

envoy_package()

envoy_cc_library(
name = "dynamic_opentracing_driver_lib",
srcs = [
"dynamic_opentracing_driver_impl.cc",
],
hdrs = [
"dynamic_opentracing_driver_impl.h",
],
deps = [
"//source/common/tracing:http_tracer_lib",
"//source/extensions/tracers/common/ot:opentracing_driver_lib",
],
)

envoy_cc_library(
name = "config",
srcs = ["config.cc"],
hdrs = ["config.h"],
deps = [
":dynamic_opentracing_driver_lib",
"//source/common/config:well_known_names",
"//source/server:configuration_lib",
],
)
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
#include "server/config/http/dynamic_opentracing_http_tracer.h"

#include <string>
#include "extensions/tracers/dynamic_ot/config.h"

#include "envoy/registry/registry.h"

#include "common/common/utility.h"
#include "common/config/well_known_names.h"
#include "common/tracing/dynamic_opentracing_driver_impl.h"
#include "common/tracing/http_tracer_impl.h"

#include "extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h"

namespace Envoy {
namespace Server {
namespace Configuration {
namespace Extensions {
namespace Tracers {
namespace DynamicOt {

Tracing::HttpTracerPtr DynamicOpenTracingHttpTracerFactory::createHttpTracer(
const Json::Object& json_config, Server::Instance& server,
Upstream::ClusterManager& /*cluster_manager*/) {
Tracing::HttpTracerPtr
DynamicOpenTracingHttpTracerFactory::createHttpTracer(const Json::Object& json_config,
Server::Instance& server) {
const std::string library = json_config.getString("library");
const std::string config = json_config.getObject("config")->asJsonString();
Tracing::DriverPtr dynamic_driver{
std::make_unique<Tracing::DynamicOpenTracingDriver>(server.stats(), library, config)};
std::make_unique<DynamicOpenTracingDriver>(server.stats(), library, config)};
return std::make_unique<Tracing::HttpTracerImpl>(std::move(dynamic_driver), server.localInfo());
}

std::string DynamicOpenTracingHttpTracerFactory::name() {
return Config::HttpTracerNames::get().DYNAMIC_OT;
return Config::TracerNames::get().DYNAMIC_OT;
}

/**
* Static registration for the dynamic opentracing http tracer. @see RegisterFactory.
*/
static Registry::RegisterFactory<DynamicOpenTracingHttpTracerFactory, HttpTracerFactory> register_;
static Registry::RegisterFactory<DynamicOpenTracingHttpTracerFactory,
Server::Configuration::HttpTracerFactory>
register_;

} // namespace Configuration
} // namespace Server
} // namespace DynamicOt
} // namespace Tracers
} // namespace Extensions
} // namespace Envoy
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
#include "server/configuration_impl.h"

namespace Envoy {
namespace Server {
namespace Configuration {
namespace Extensions {
namespace Tracers {
namespace DynamicOt {

/**
* Config registration for the dynamic opentracing tracer. @see HttpTracerFactory.
*/
class DynamicOpenTracingHttpTracerFactory : public HttpTracerFactory {
class DynamicOpenTracingHttpTracerFactory : public Server::Configuration::HttpTracerFactory {
public:
// HttpTracerFactory
Tracing::HttpTracerPtr createHttpTracer(const Json::Object& json_config, Server::Instance& server,
Upstream::ClusterManager& cluster_manager) override;

Tracing::HttpTracerPtr createHttpTracer(const Json::Object& json_config,
Server::Instance& server) override;
std::string name() override;

bool requiresClusterName() const override { return false; }
};

} // namespace Configuration
} // namespace Server
} // namespace DynamicOt
} // namespace Tracers
} // namespace Extensions
} // namespace Envoy
Loading