diff --git a/include/envoy/server/tracer_config.h b/include/envoy/server/tracer_config.h index 25f8b664d9491..4af4caf45bc9a 100644 --- a/include/envoy/server/tracer_config.h +++ b/include/envoy/server/tracer_config.h @@ -41,13 +41,13 @@ class TracerFactory : public Config::TypedFactory { ~TracerFactory() override = default; /** - * Create a particular HttpTracer implementation. If the implementation is unable to produce an - * HttpTracer with the provided parameters, it should throw an EnvoyException in the case of - * general error or a Json::Exception if the json configuration is erroneous. The returned + * Create a particular trace driver implementation. If the implementation is unable to produce + * a trace driver with the provided parameters, it should throw an EnvoyException in the case + * of general error or a Json::Exception if the json configuration is erroneous. The returned * pointer should always be valid. * * NOTE: Due to the corner case of OpenCensus, who can only support a single tracing - * configuration per entire process, the returned HttpTracer instance is not guaranteed + * configuration per entire process, the returned Driver instance is not guaranteed * to be unique. * That is why the return type has been changed to std::shared_ptr<> instead of a more * idiomatic std::unique_ptr<>. @@ -55,8 +55,8 @@ class TracerFactory : public Config::TypedFactory { * @param config supplies the proto configuration for the HttpTracer * @param context supplies the factory context */ - virtual Tracing::HttpTracerSharedPtr createHttpTracer(const Protobuf::Message& config, - TracerFactoryContext& context) PURE; + virtual Tracing::DriverSharedPtr createTracerDriver(const Protobuf::Message& config, + TracerFactoryContext& context) PURE; std::string category() const override { return "envoy.tracers"; } }; diff --git a/include/envoy/tracing/BUILD b/include/envoy/tracing/BUILD index cd539650e0ea2..9bed839d05ae9 100644 --- a/include/envoy/tracing/BUILD +++ b/include/envoy/tracing/BUILD @@ -12,7 +12,7 @@ envoy_cc_library( name = "http_tracer_interface", hdrs = ["http_tracer.h"], deps = [ - ":trace_reason_interface", + ":trace_driver_interface", "//include/envoy/access_log:access_log_interface", "//include/envoy/http:header_map_interface", ], @@ -31,3 +31,12 @@ envoy_cc_library( name = "trace_reason_interface", hdrs = ["trace_reason.h"], ) + +envoy_cc_library( + name = "trace_driver_interface", + hdrs = ["trace_driver.h"], + deps = [ + ":trace_reason_interface", + "//include/envoy/stream_info:stream_info_interface", + ], +) diff --git a/include/envoy/tracing/http_tracer.h b/include/envoy/tracing/http_tracer.h index bfc29d370291f..34409fac312e4 100644 --- a/include/envoy/tracing/http_tracer.h +++ b/include/envoy/tracing/http_tracer.h @@ -7,177 +7,12 @@ #include "envoy/access_log/access_log.h" #include "envoy/common/pure.h" #include "envoy/http/header_map.h" +#include "envoy/tracing/trace_driver.h" #include "envoy/tracing/trace_reason.h" namespace Envoy { namespace Tracing { -class Span; -using SpanPtr = std::unique_ptr; - -constexpr uint32_t DefaultMaxPathTagLength = 256; - -enum class OperationName { Ingress, Egress }; - -/** - * The context for the custom tag to obtain the tag value. - */ -struct CustomTagContext { - const Http::RequestHeaderMap* request_headers; - const StreamInfo::StreamInfo& stream_info; -}; - -/** - * Tracing custom tag, with tag name and how it would be applied to the span. - */ -class CustomTag { -public: - virtual ~CustomTag() = default; - - /** - * @return the tag name view. - */ - virtual absl::string_view tag() const PURE; - - /** - * The way how to apply the custom tag to the span, - * generally obtain the tag value from the context and attached it to the span. - * @param span the active span. - * @param ctx the custom tag context. - */ - virtual void apply(Span& span, const CustomTagContext& ctx) const PURE; -}; - -using CustomTagConstSharedPtr = std::shared_ptr; -using CustomTagMap = absl::flat_hash_map; - -/** - * Tracing configuration, it carries additional data needed to populate the span. - */ -class Config { -public: - virtual ~Config() = default; - - /** - * @return operation name for tracing, e.g., ingress. - */ - virtual OperationName operationName() const PURE; - - /** - * @return custom tags to be attached to the active span. - */ - virtual const CustomTagMap* customTags() const PURE; - - /** - * @return true if spans should be annotated with more detailed information. - */ - virtual bool verbose() const PURE; - - /** - * @return the maximum length allowed for paths in the extracted HttpUrl tag. - */ - virtual uint32_t maxPathTagLength() const PURE; -}; - -/** - * Basic abstraction for span. - */ -class Span { -public: - virtual ~Span() = default; - - /** - * Set the operation name. - * @param operation the operation name - */ - virtual void setOperation(absl::string_view operation) PURE; - - /** - * Attach metadata to a Span, to be handled in an implementation-dependent fashion. - * @param name the name of the tag - * @param value the value to associate with the tag - */ - virtual void setTag(absl::string_view name, absl::string_view value) PURE; - - /** - * Record an event associated with a span, to be handled in an implementation-dependent fashion. - * @param timestamp the time of the event. - * @param event the name of the event. - */ - virtual void log(SystemTime timestamp, const std::string& event) PURE; - - /** - * Capture the final duration for this Span and carry out any work necessary to complete it. - * Once this method is called, the Span may be safely discarded. - */ - virtual void finishSpan() PURE; - - /** - * Mutate the provided headers with the context necessary to propagate this - * (implementation-specific) trace. - * @param request_headers the headers to which propagation context will be added - */ - virtual void injectContext(Http::RequestHeaderMap& request_headers) PURE; - - /** - * Create and start a child Span, with this Span as its parent in the trace. - * @param config the tracing configuration - * @param name operation name captured by the spawned child - * @param start_time initial start time for the operation captured by the child - */ - virtual SpanPtr spawnChild(const Config& config, const std::string& name, - SystemTime start_time) PURE; - - /** - * This method overrides any previous sampling decision associated with the trace instance. - * If the sampled parameter is false, this span and any subsequent child spans - * are not reported to the tracing system. - * @param sampled whether the span and any subsequent child spans should be sampled - */ - virtual void setSampled(bool sampled) PURE; - - /** - * Retrieve a key's value from the span's baggage. - * This baggage data could've been set by this span or any parent spans. - * @param key baggage key - * @return the baggage's value for the given input key - */ - virtual std::string getBaggage(absl::string_view key) PURE; - - /** - * Set a key/value pair in the current span's baggage. - * All subsequent child spans will have access to this baggage. - * @param key baggage key - * @param key baggage value - */ - virtual void setBaggage(absl::string_view key, absl::string_view value) PURE; - - /** - * Retrieve the trace ID associated with this span. - * The trace id may be generated for this span, propagated by parent spans, or - * not created yet. - * @return trace ID as a hex string - */ - virtual std::string getTraceIdAsHex() const PURE; -}; - -/** - * Tracing driver is responsible for span creation. - */ -class Driver { -public: - virtual ~Driver() = default; - - /** - * Start driver specific span. - */ - virtual SpanPtr startSpan(const Config& config, Http::RequestHeaderMap& request_headers, - const std::string& operation_name, SystemTime start_time, - const Tracing::Decision tracing_decision) PURE; -}; - -using DriverPtr = std::unique_ptr; - /** * HttpTracer is responsible for handling traces and delegate actions to the * corresponding drivers. diff --git a/include/envoy/tracing/trace_driver.h b/include/envoy/tracing/trace_driver.h new file mode 100644 index 0000000000000..7adb2222cacd4 --- /dev/null +++ b/include/envoy/tracing/trace_driver.h @@ -0,0 +1,183 @@ +#pragma once + +#include +#include +#include + +#include "envoy/common/pure.h" +#include "envoy/stream_info/stream_info.h" +#include "envoy/tracing/trace_reason.h" + +namespace Envoy { +namespace Tracing { + +class Span; +using SpanPtr = std::unique_ptr; + +constexpr uint32_t DefaultMaxPathTagLength = 256; + +enum class OperationName { Ingress, Egress }; + +/** + * The context for the custom tag to obtain the tag value. + */ +struct CustomTagContext { + const Http::RequestHeaderMap* request_headers; + const StreamInfo::StreamInfo& stream_info; +}; + +/** + * Tracing custom tag, with tag name and how it would be applied to the span. + */ +class CustomTag { +public: + virtual ~CustomTag() = default; + + /** + * @return the tag name view. + */ + virtual absl::string_view tag() const PURE; + + /** + * The way how to apply the custom tag to the span, + * generally obtain the tag value from the context and attached it to the span. + * @param span the active span. + * @param ctx the custom tag context. + */ + virtual void apply(Span& span, const CustomTagContext& ctx) const PURE; +}; + +using CustomTagConstSharedPtr = std::shared_ptr; +using CustomTagMap = absl::flat_hash_map; + +/** + * Tracing configuration, it carries additional data needed to populate the span. + */ +class Config { +public: + virtual ~Config() = default; + + /** + * @return operation name for tracing, e.g., ingress. + */ + virtual OperationName operationName() const PURE; + + /** + * @return custom tags to be attached to the active span. + */ + virtual const CustomTagMap* customTags() const PURE; + + /** + * @return true if spans should be annotated with more detailed information. + */ + virtual bool verbose() const PURE; + + /** + * @return the maximum length allowed for paths in the extracted HttpUrl tag. This is only used + * for HTTP protocol tracing. + */ + virtual uint32_t maxPathTagLength() const PURE; +}; + +/** + * Basic abstraction for span. + */ +class Span { +public: + virtual ~Span() = default; + + /** + * Set the operation name. + * @param operation the operation name + */ + virtual void setOperation(absl::string_view operation) PURE; + + /** + * Attach metadata to a Span, to be handled in an implementation-dependent fashion. + * @param name the name of the tag + * @param value the value to associate with the tag + */ + virtual void setTag(absl::string_view name, absl::string_view value) PURE; + + /** + * Record an event associated with a span, to be handled in an implementation-dependent fashion. + * @param timestamp the time of the event. + * @param event the name of the event. + */ + virtual void log(SystemTime timestamp, const std::string& event) PURE; + + /** + * Capture the final duration for this Span and carry out any work necessary to complete it. + * Once this method is called, the Span may be safely discarded. + */ + virtual void finishSpan() PURE; + + /** + * Mutate the provided headers with the context necessary to propagate this + * (implementation-specific) trace. + * @param request_headers the headers to which propagation context will be added + */ + virtual void injectContext(Http::RequestHeaderMap& request_headers) PURE; + + /** + * Create and start a child Span, with this Span as its parent in the trace. + * @param config the tracing configuration + * @param name operation name captured by the spawned child + * @param start_time initial start time for the operation captured by the child + */ + virtual SpanPtr spawnChild(const Config& config, const std::string& name, + SystemTime start_time) PURE; + + /** + * This method overrides any previous sampling decision associated with the trace instance. + * If the sampled parameter is false, this span and any subsequent child spans + * are not reported to the tracing system. + * @param sampled whether the span and any subsequent child spans should be sampled + */ + virtual void setSampled(bool sampled) PURE; + + /** + * Retrieve a key's value from the span's baggage. + * This baggage data could've been set by this span or any parent spans. + * @param key baggage key + * @return the baggage's value for the given input key + */ + virtual std::string getBaggage(absl::string_view key) PURE; + + /** + * Set a key/value pair in the current span's baggage. + * All subsequent child spans will have access to this baggage. + * @param key baggage key + * @param key baggage value + */ + virtual void setBaggage(absl::string_view key, absl::string_view value) PURE; + + /** + * Retrieve the trace ID associated with this span. + * The trace id may be generated for this span, propagated by parent spans, or + * not created yet. + * @return trace ID as a hex string + */ + virtual std::string getTraceIdAsHex() const PURE; +}; + +/** + * Tracing driver is responsible for span creation. + */ +class Driver { +public: + virtual ~Driver() = default; + + /** + * Start driver specific span. + */ + virtual SpanPtr startSpan(const Config& config, Http::RequestHeaderMap& request_headers, + const std::string& operation_name, SystemTime start_time, + const Tracing::Decision tracing_decision) PURE; +}; + +using DriverPtr = std::unique_ptr; +using DriverSharedPtr = std::shared_ptr; + +} // namespace Tracing +} // namespace Envoy diff --git a/source/common/tracing/BUILD b/source/common/tracing/BUILD index ef703c964a904..8dce4bdd7b64f 100644 --- a/source/common/tracing/BUILD +++ b/source/common/tracing/BUILD @@ -8,6 +8,27 @@ licenses(["notice"]) # Apache 2 envoy_package() +envoy_cc_library( + name = "null_span_lib", + hdrs = [ + "null_span_impl.h", + ], + deps = [ + "//include/envoy/tracing:trace_driver_interface", + "//source/common/common:empty_string", + ], +) + +envoy_cc_library( + name = "common_values_lib", + hdrs = [ + "common_values.h", + ], + deps = [ + "//source/common/singleton:const_singleton", + ], +) + envoy_cc_library( name = "http_tracer_lib", srcs = [ @@ -17,6 +38,8 @@ envoy_cc_library( "http_tracer_impl.h", ], deps = [ + ":common_values_lib", + ":null_span_lib", "//include/envoy/http:request_id_extension_interface", "//include/envoy/local_info:local_info_interface", "//include/envoy/runtime:runtime_interface", @@ -45,9 +68,9 @@ envoy_cc_library( ) envoy_cc_library( - name = "http_tracer_config_lib", + name = "tracer_config_lib", hdrs = [ - "http_tracer_config_impl.h", + "tracer_config_impl.h", ], deps = [ "//include/envoy/server:tracer_config_interface", diff --git a/source/common/tracing/common_values.h b/source/common/tracing/common_values.h new file mode 100644 index 0000000000000..41cb3947772f4 --- /dev/null +++ b/source/common/tracing/common_values.h @@ -0,0 +1,84 @@ +#pragma once + +#include + +#include "common/singleton/const_singleton.h" + +namespace Envoy { +namespace Tracing { + +/** + * Tracing tag names. + */ +class TracingTagValues { +public: + // OpenTracing standard tag names. + const std::string Component = "component"; + const std::string DbInstance = "db.instance"; + const std::string DbStatement = "db.statement"; + const std::string DbUser = "db.user"; + const std::string DbType = "db.type"; + const std::string Error = "error"; + const std::string HttpMethod = "http.method"; + const std::string HttpStatusCode = "http.status_code"; + const std::string HttpUrl = "http.url"; + const std::string MessageBusDestination = "message_bus.destination"; + const std::string PeerAddress = "peer.address"; + const std::string PeerHostname = "peer.hostname"; + const std::string PeerIpv4 = "peer.ipv4"; + const std::string PeerIpv6 = "peer.ipv6"; + const std::string PeerPort = "peer.port"; + const std::string PeerService = "peer.service"; + const std::string SpanKind = "span.kind"; + + // Non-standard tag names. + const std::string DownstreamCluster = "downstream_cluster"; + const std::string ErrorReason = "error.reason"; + const std::string GrpcAuthority = "grpc.authority"; + const std::string GrpcContentType = "grpc.content_type"; + const std::string GrpcMessage = "grpc.message"; + const std::string GrpcPath = "grpc.path"; + const std::string GrpcStatusCode = "grpc.status_code"; + const std::string GrpcTimeout = "grpc.timeout"; + const std::string GuidXClientTraceId = "guid:x-client-trace-id"; + const std::string GuidXRequestId = "guid:x-request-id"; + const std::string HttpProtocol = "http.protocol"; + const std::string NodeId = "node_id"; + const std::string RequestSize = "request_size"; + const std::string ResponseFlags = "response_flags"; + const std::string ResponseSize = "response_size"; + const std::string RetryCount = "retry.count"; + const std::string Status = "status"; + const std::string UpstreamAddress = "upstream_address"; + const std::string UpstreamCluster = "upstream_cluster"; + const std::string UpstreamClusterName = "upstream_cluster.name"; + const std::string UserAgent = "user_agent"; + const std::string Zone = "zone"; + + // Tag values. + const std::string Canceled = "canceled"; + const std::string Proxy = "proxy"; + const std::string True = "true"; +}; + +using Tags = ConstSingleton; + +class TracingLogValues { +public: + // OpenTracing standard key names. + const std::string EventKey = "event"; + + // Event names + const std::string LastDownstreamRxByteReceived = "last_downstream_rx_byte_received"; + const std::string FirstUpstreamTxByteSent = "first_upstream_tx_byte_sent"; + const std::string LastUpstreamTxByteSent = "last_upstream_tx_byte_sent"; + const std::string FirstUpstreamRxByteReceived = "first_upstream_rx_byte_received"; + const std::string LastUpstreamRxByteReceived = "last_upstream_rx_byte_received"; + const std::string FirstDownstreamTxByteSent = "first_downstream_tx_byte_sent"; + const std::string LastDownstreamTxByteSent = "last_downstream_tx_byte_sent"; +}; + +using Logs = ConstSingleton; + +} // namespace Tracing +} // namespace Envoy diff --git a/source/common/tracing/http_tracer_impl.cc b/source/common/tracing/http_tracer_impl.cc index 32c3a5224aa50..df9d29b4a72a1 100644 --- a/source/common/tracing/http_tracer_impl.cc +++ b/source/common/tracing/http_tracer_impl.cc @@ -272,7 +272,7 @@ HttpTracerUtility::createCustomTag(const envoy::type::tracing::v3::CustomTag& ta } } -HttpTracerImpl::HttpTracerImpl(DriverPtr&& driver, const LocalInfo::LocalInfo& local_info) +HttpTracerImpl::HttpTracerImpl(DriverSharedPtr driver, const LocalInfo::LocalInfo& local_info) : driver_(std::move(driver)), local_info_(local_info) {} SpanPtr HttpTracerImpl::startSpan(const Config& config, Http::RequestHeaderMap& request_headers, diff --git a/source/common/tracing/http_tracer_impl.h b/source/common/tracing/http_tracer_impl.h index 58950449adc2d..4c3b733ab0904 100644 --- a/source/common/tracing/http_tracer_impl.h +++ b/source/common/tracing/http_tracer_impl.h @@ -13,87 +13,15 @@ #include "envoy/type/tracing/v3/custom_tag.pb.h" #include "envoy/upstream/cluster_manager.h" -#include "common/common/empty_string.h" #include "common/config/metadata.h" #include "common/http/header_map_impl.h" #include "common/json/json_loader.h" +#include "common/tracing/common_values.h" +#include "common/tracing/null_span_impl.h" namespace Envoy { namespace Tracing { -/** - * Tracing tag names. - */ -class TracingTagValues { -public: - // OpenTracing standard tag names. - const std::string Component = "component"; - const std::string DbInstance = "db.instance"; - const std::string DbStatement = "db.statement"; - const std::string DbUser = "db.user"; - const std::string DbType = "db.type"; - const std::string Error = "error"; - const std::string HttpMethod = "http.method"; - const std::string HttpStatusCode = "http.status_code"; - const std::string HttpUrl = "http.url"; - const std::string MessageBusDestination = "message_bus.destination"; - const std::string PeerAddress = "peer.address"; - const std::string PeerHostname = "peer.hostname"; - const std::string PeerIpv4 = "peer.ipv4"; - const std::string PeerIpv6 = "peer.ipv6"; - const std::string PeerPort = "peer.port"; - const std::string PeerService = "peer.service"; - const std::string SpanKind = "span.kind"; - - // Non-standard tag names. - const std::string DownstreamCluster = "downstream_cluster"; - const std::string ErrorReason = "error.reason"; - const std::string GrpcAuthority = "grpc.authority"; - const std::string GrpcContentType = "grpc.content_type"; - const std::string GrpcMessage = "grpc.message"; - const std::string GrpcPath = "grpc.path"; - const std::string GrpcStatusCode = "grpc.status_code"; - const std::string GrpcTimeout = "grpc.timeout"; - const std::string GuidXClientTraceId = "guid:x-client-trace-id"; - const std::string GuidXRequestId = "guid:x-request-id"; - const std::string HttpProtocol = "http.protocol"; - const std::string NodeId = "node_id"; - const std::string RequestSize = "request_size"; - const std::string ResponseFlags = "response_flags"; - const std::string ResponseSize = "response_size"; - const std::string RetryCount = "retry.count"; - const std::string Status = "status"; - const std::string UpstreamAddress = "upstream_address"; - const std::string UpstreamCluster = "upstream_cluster"; - const std::string UpstreamClusterName = "upstream_cluster.name"; - const std::string UserAgent = "user_agent"; - const std::string Zone = "zone"; - - // Tag values. - const std::string Canceled = "canceled"; - const std::string Proxy = "proxy"; - const std::string True = "true"; -}; - -using Tags = ConstSingleton; - -class TracingLogValues { -public: - // OpenTracing standard key names. - const std::string EventKey = "event"; - - // Event names - const std::string LastDownstreamRxByteReceived = "last_downstream_rx_byte_received"; - const std::string FirstUpstreamTxByteSent = "first_upstream_tx_byte_sent"; - const std::string LastUpstreamTxByteSent = "last_upstream_tx_byte_sent"; - const std::string FirstUpstreamRxByteReceived = "first_upstream_rx_byte_received"; - const std::string LastUpstreamRxByteReceived = "last_upstream_rx_byte_received"; - const std::string FirstDownstreamTxByteSent = "first_downstream_tx_byte_sent"; - const std::string LastDownstreamTxByteSent = "last_downstream_tx_byte_sent"; -}; - -using Logs = ConstSingleton; - class HttpTracerUtility { public: /** @@ -157,28 +85,6 @@ class EgressConfigImpl : public Config { using EgressConfig = ConstSingleton; -class NullSpan : public Span { -public: - static NullSpan& instance() { - static NullSpan* instance = new NullSpan(); - return *instance; - } - - // Tracing::Span - void setOperation(absl::string_view) override {} - void setTag(absl::string_view, absl::string_view) override {} - void log(SystemTime, const std::string&) override {} - void finishSpan() override {} - void injectContext(Http::RequestHeaderMap&) override {} - void setBaggage(absl::string_view, absl::string_view) override {} - std::string getBaggage(absl::string_view) override { return EMPTY_STRING; } - std::string getTraceIdAsHex() const override { return EMPTY_STRING; } - SpanPtr spawnChild(const Config&, const std::string&, SystemTime) override { - return SpanPtr{new NullSpan()}; - } - void setSampled(bool) override {} -}; - class HttpNullTracer : public HttpTracer { public: // Tracing::HttpTracer @@ -190,15 +96,17 @@ class HttpNullTracer : public HttpTracer { class HttpTracerImpl : public HttpTracer { public: - HttpTracerImpl(DriverPtr&& driver, const LocalInfo::LocalInfo& local_info); + HttpTracerImpl(DriverSharedPtr driver, const LocalInfo::LocalInfo& local_info); // Tracing::HttpTracer SpanPtr startSpan(const Config& config, Http::RequestHeaderMap& request_headers, const StreamInfo::StreamInfo& stream_info, const Tracing::Decision tracing_decision) override; + DriverSharedPtr driverForTest() const { return driver_; } + private: - DriverPtr driver_; + DriverSharedPtr driver_; const LocalInfo::LocalInfo& local_info_; }; diff --git a/source/common/tracing/http_tracer_manager_impl.cc b/source/common/tracing/http_tracer_manager_impl.cc index 125e2a4e4e8bf..e25f5d99ba2d9 100644 --- a/source/common/tracing/http_tracer_manager_impl.cc +++ b/source/common/tracing/http_tracer_manager_impl.cc @@ -46,7 +46,9 @@ HttpTracerManagerImpl::getOrCreateHttpTracer(const envoy::config::trace::v3::Tra ProtobufTypes::MessagePtr message = Envoy::Config::Utility::translateToFactoryConfig( *config, factory_context_->messageValidationVisitor(), factory); - HttpTracerSharedPtr http_tracer = factory.createHttpTracer(*message, *factory_context_); + HttpTracerSharedPtr http_tracer = std::make_shared( + factory.createTracerDriver(*message, *factory_context_), + factory_context_->serverFactoryContext().localInfo()); http_tracers_.emplace(cache_key, http_tracer); // cache a weak reference return http_tracer; } diff --git a/source/common/tracing/null_span_impl.h b/source/common/tracing/null_span_impl.h new file mode 100644 index 0000000000000..18677818dfcaa --- /dev/null +++ b/source/common/tracing/null_span_impl.h @@ -0,0 +1,36 @@ +#pragma once + +#include "envoy/tracing/trace_driver.h" + +#include "common/common/empty_string.h" + +namespace Envoy { +namespace Tracing { + +/** + * Null implementation of Span. + */ +class NullSpan : public Span { +public: + static NullSpan& instance() { + static NullSpan* instance = new NullSpan(); + return *instance; + } + + // Tracing::Span + void setOperation(absl::string_view) override {} + void setTag(absl::string_view, absl::string_view) override {} + void log(SystemTime, const std::string&) override {} + void finishSpan() override {} + void injectContext(Http::RequestHeaderMap&) override {} + void setBaggage(absl::string_view, absl::string_view) override {} + std::string getBaggage(absl::string_view) override { return EMPTY_STRING; } + std::string getTraceIdAsHex() const override { return EMPTY_STRING; } + SpanPtr spawnChild(const Config&, const std::string&, SystemTime) override { + return SpanPtr{new NullSpan()}; + } + void setSampled(bool) override {} +}; + +} // namespace Tracing +} // namespace Envoy diff --git a/source/common/tracing/http_tracer_config_impl.h b/source/common/tracing/tracer_config_impl.h similarity index 100% rename from source/common/tracing/http_tracer_config_impl.h rename to source/common/tracing/tracer_config_impl.h diff --git a/source/extensions/filters/network/http_connection_manager/BUILD b/source/extensions/filters/network/http_connection_manager/BUILD index fd9234f3ea93a..60c8ce180e04e 100644 --- a/source/extensions/filters/network/http_connection_manager/BUILD +++ b/source/extensions/filters/network/http_connection_manager/BUILD @@ -52,9 +52,9 @@ envoy_cc_extension( "//source/common/router:rds_lib", "//source/common/router:scoped_rds_lib", "//source/common/runtime:runtime_lib", - "//source/common/tracing:http_tracer_config_lib", "//source/common/tracing:http_tracer_lib", "//source/common/tracing:http_tracer_manager_lib", + "//source/common/tracing:tracer_config_lib", "//source/extensions/filters/http/common:pass_through_filter_lib", "//source/extensions/filters/network:well_known_names", "//source/extensions/filters/network/common:factory_base_lib", diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index 0cf301d93ead1..cd0fd9c9fbecf 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -33,8 +33,8 @@ #include "common/router/rds_impl.h" #include "common/router/scoped_rds.h" #include "common/runtime/runtime_impl.h" -#include "common/tracing/http_tracer_config_impl.h" #include "common/tracing/http_tracer_manager_impl.h" +#include "common/tracing/tracer_config_impl.h" #ifdef ENVOY_ENABLE_QUIC #include "common/quic/codec_impl.h" diff --git a/source/extensions/tracers/common/factory_base.h b/source/extensions/tracers/common/factory_base.h index 03e45d7615595..b31d22c3c28cc 100644 --- a/source/extensions/tracers/common/factory_base.h +++ b/source/extensions/tracers/common/factory_base.h @@ -14,12 +14,12 @@ namespace Common { template class FactoryBase : public Server::Configuration::TracerFactory { public: // Server::Configuration::TracerFactory - Tracing::HttpTracerSharedPtr - createHttpTracer(const Protobuf::Message& config, - Server::Configuration::TracerFactoryContext& context) override { - return createHttpTracerTyped(MessageUtil::downcastAndValidate( - config, context.messageValidationVisitor()), - context); + Tracing::DriverSharedPtr + createTracerDriver(const Protobuf::Message& config, + Server::Configuration::TracerFactoryContext& context) override { + return createTracerDriverTyped(MessageUtil::downcastAndValidate( + config, context.messageValidationVisitor()), + context); } ProtobufTypes::MessagePtr createEmptyConfigProto() override { @@ -32,9 +32,9 @@ template class FactoryBase : public Server::Configuration::T FactoryBase(const std::string& name) : name_(name) {} private: - virtual Tracing::HttpTracerSharedPtr - createHttpTracerTyped(const ConfigProto& proto_config, - Server::Configuration::TracerFactoryContext& context) PURE; + virtual Tracing::DriverSharedPtr + createTracerDriverTyped(const ConfigProto& proto_config, + Server::Configuration::TracerFactoryContext& context) PURE; const std::string name_; }; diff --git a/source/extensions/tracers/common/ot/BUILD b/source/extensions/tracers/common/ot/BUILD index beced5b3f219e..c8b386d0c3c87 100644 --- a/source/extensions/tracers/common/ot/BUILD +++ b/source/extensions/tracers/common/ot/BUILD @@ -18,6 +18,15 @@ envoy_cc_library( ], external_deps = ["opentracing"], deps = [ - "//source/common/tracing:http_tracer_lib", + "//include/envoy/runtime:runtime_interface", + "//include/envoy/thread_local:thread_local_interface", + "//include/envoy/tracing:trace_driver_interface", + "//include/envoy/upstream:cluster_manager_interface", + "//source/common/common:base64_lib", + "//source/common/common:empty_string", + "//source/common/http:header_map_lib", + "//source/common/json:json_loader_lib", + "//source/common/tracing:common_values_lib", + "//source/common/tracing:null_span_lib", ], ) diff --git a/source/extensions/tracers/common/ot/opentracing_driver_impl.cc b/source/extensions/tracers/common/ot/opentracing_driver_impl.cc index 18bf1e828dcc1..92a6b07d634f6 100644 --- a/source/extensions/tracers/common/ot/opentracing_driver_impl.cc +++ b/source/extensions/tracers/common/ot/opentracing_driver_impl.cc @@ -7,7 +7,9 @@ #include "common/common/assert.h" #include "common/common/base64.h" #include "common/common/utility.h" -#include "common/tracing/http_tracer_impl.h" +#include "common/http/header_map_impl.h" +#include "common/tracing/common_values.h" +#include "common/tracing/null_span_impl.h" namespace Envoy { namespace Extensions { diff --git a/source/extensions/tracers/common/ot/opentracing_driver_impl.h b/source/extensions/tracers/common/ot/opentracing_driver_impl.h index ef10c15926677..d214d967a287e 100644 --- a/source/extensions/tracers/common/ot/opentracing_driver_impl.h +++ b/source/extensions/tracers/common/ot/opentracing_driver_impl.h @@ -3,7 +3,7 @@ #include #include "envoy/stats/scope.h" -#include "envoy/tracing/http_tracer.h" +#include "envoy/tracing/trace_driver.h" #include "common/common/empty_string.h" #include "common/common/logger.h" diff --git a/source/extensions/tracers/datadog/BUILD b/source/extensions/tracers/datadog/BUILD index d294f3e56a41e..164a1d73c1f94 100644 --- a/source/extensions/tracers/datadog/BUILD +++ b/source/extensions/tracers/datadog/BUILD @@ -23,7 +23,6 @@ envoy_cc_library( deps = [ "//source/common/config:utility_lib", "//source/common/http:async_client_utility_lib", - "//source/common/tracing:http_tracer_lib", "//source/common/upstream:cluster_update_tracker_lib", "//source/common/version:version_lib", "//source/extensions/tracers/common/ot:opentracing_driver_lib", diff --git a/source/extensions/tracers/datadog/config.cc b/source/extensions/tracers/datadog/config.cc index 1113708d5fde2..cdfcafdddf38f 100644 --- a/source/extensions/tracers/datadog/config.cc +++ b/source/extensions/tracers/datadog/config.cc @@ -5,7 +5,6 @@ #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" @@ -18,15 +17,13 @@ namespace Datadog { DatadogTracerFactory::DatadogTracerFactory() : FactoryBase("envoy.tracers.datadog") {} -Tracing::HttpTracerSharedPtr DatadogTracerFactory::createHttpTracerTyped( +Tracing::DriverSharedPtr DatadogTracerFactory::createTracerDriverTyped( const envoy::config::trace::v3::DatadogConfig& proto_config, Server::Configuration::TracerFactoryContext& context) { - Tracing::DriverPtr datadog_driver = std::make_unique( - proto_config, context.serverFactoryContext().clusterManager(), - context.serverFactoryContext().scope(), context.serverFactoryContext().threadLocal(), - context.serverFactoryContext().runtime()); - return std::make_shared(std::move(datadog_driver), - context.serverFactoryContext().localInfo()); + return std::make_shared(proto_config, context.serverFactoryContext().clusterManager(), + context.serverFactoryContext().scope(), + context.serverFactoryContext().threadLocal(), + context.serverFactoryContext().runtime()); } /** diff --git a/source/extensions/tracers/datadog/config.h b/source/extensions/tracers/datadog/config.h index 324c82e85f9b1..1808fddff0033 100644 --- a/source/extensions/tracers/datadog/config.h +++ b/source/extensions/tracers/datadog/config.h @@ -21,9 +21,9 @@ class DatadogTracerFactory : public Common::FactoryBase( - context.serverFactoryContext().scope(), library, config); - return std::make_shared(std::move(dynamic_driver), - context.serverFactoryContext().localInfo()); + return std::make_shared(context.serverFactoryContext().scope(), library, + config); } /** diff --git a/source/extensions/tracers/dynamic_ot/config.h b/source/extensions/tracers/dynamic_ot/config.h index 05fd2873132b8..4b9a761a262ea 100644 --- a/source/extensions/tracers/dynamic_ot/config.h +++ b/source/extensions/tracers/dynamic_ot/config.h @@ -20,9 +20,9 @@ class DynamicOpenTracingTracerFactory private: // FactoryBase - Tracing::HttpTracerSharedPtr - createHttpTracerTyped(const envoy::config::trace::v3::DynamicOtConfig& configuration, - Server::Configuration::TracerFactoryContext& context) override; + Tracing::DriverSharedPtr + createTracerDriverTyped(const envoy::config::trace::v3::DynamicOtConfig& configuration, + Server::Configuration::TracerFactoryContext& context) override; }; } // namespace DynamicOt diff --git a/source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h b/source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h index a872088b8e111..668e3f99ad739 100644 --- a/source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h +++ b/source/extensions/tracers/dynamic_ot/dynamic_opentracing_driver_impl.h @@ -2,7 +2,6 @@ #include "envoy/runtime/runtime.h" #include "envoy/thread_local/thread_local.h" -#include "envoy/tracing/http_tracer.h" #include "envoy/upstream/cluster_manager.h" #include "extensions/tracers/common/ot/opentracing_driver_impl.h" diff --git a/source/extensions/tracers/lightstep/config.cc b/source/extensions/tracers/lightstep/config.cc index 04a5de828390d..49aa98ccaf4a5 100644 --- a/source/extensions/tracers/lightstep/config.cc +++ b/source/extensions/tracers/lightstep/config.cc @@ -6,7 +6,6 @@ #include "common/common/utility.h" #include "common/config/datasource.h" -#include "common/tracing/http_tracer_impl.h" #include "extensions/tracers/lightstep/lightstep_tracer_impl.h" @@ -19,7 +18,7 @@ namespace Lightstep { LightstepTracerFactory::LightstepTracerFactory() : FactoryBase("envoy.tracers.lightstep") {} -Tracing::HttpTracerSharedPtr LightstepTracerFactory::createHttpTracerTyped( +Tracing::DriverSharedPtr LightstepTracerFactory::createTracerDriverTyped( const envoy::config::trace::v3::LightstepConfig& proto_config, Server::Configuration::TracerFactoryContext& context) { auto opts = std::make_unique(); @@ -34,14 +33,12 @@ Tracing::HttpTracerSharedPtr LightstepTracerFactory::createHttpTracerTyped( } opts->component_name = context.serverFactoryContext().localInfo().clusterName(); - Tracing::DriverPtr lightstep_driver = std::make_unique( + return std::make_shared( proto_config, context.serverFactoryContext().clusterManager(), context.serverFactoryContext().scope(), context.serverFactoryContext().threadLocal(), context.serverFactoryContext().runtime(), std::move(opts), Common::Ot::OpenTracingDriver::PropagationMode::TracerNative, context.serverFactoryContext().grpcContext()); - return std::make_shared(std::move(lightstep_driver), - context.serverFactoryContext().localInfo()); } /** diff --git a/source/extensions/tracers/lightstep/config.h b/source/extensions/tracers/lightstep/config.h index f14a45470ecf1..33cec8da3d605 100644 --- a/source/extensions/tracers/lightstep/config.h +++ b/source/extensions/tracers/lightstep/config.h @@ -20,9 +20,9 @@ class LightstepTracerFactory private: // FactoryBase - Tracing::HttpTracerSharedPtr - createHttpTracerTyped(const envoy::config::trace::v3::LightstepConfig& proto_config, - Server::Configuration::TracerFactoryContext& context) override; + Tracing::DriverSharedPtr + createTracerDriverTyped(const envoy::config::trace::v3::LightstepConfig& proto_config, + Server::Configuration::TracerFactoryContext& context) override; }; } // namespace Lightstep diff --git a/source/extensions/tracers/lightstep/lightstep_tracer_impl.h b/source/extensions/tracers/lightstep/lightstep_tracer_impl.h index e99d92b5346e9..10820e4a3601e 100644 --- a/source/extensions/tracers/lightstep/lightstep_tracer_impl.h +++ b/source/extensions/tracers/lightstep/lightstep_tracer_impl.h @@ -7,7 +7,6 @@ #include "envoy/config/trace/v3/lightstep.pb.h" #include "envoy/runtime/runtime.h" #include "envoy/thread_local/thread_local.h" -#include "envoy/tracing/http_tracer.h" #include "envoy/upstream/cluster_manager.h" #include "common/buffer/buffer_impl.h" diff --git a/source/extensions/tracers/opencensus/config.cc b/source/extensions/tracers/opencensus/config.cc index 24a439a98a650..ae6756e9bbfff 100644 --- a/source/extensions/tracers/opencensus/config.cc +++ b/source/extensions/tracers/opencensus/config.cc @@ -4,8 +4,6 @@ #include "envoy/config/trace/v3/opencensus.pb.validate.h" #include "envoy/registry/registry.h" -#include "common/tracing/http_tracer_impl.h" - #include "extensions/tracers/opencensus/opencensus_tracer_impl.h" namespace Envoy { @@ -15,25 +13,23 @@ namespace OpenCensus { OpenCensusTracerFactory::OpenCensusTracerFactory() : FactoryBase("envoy.tracers.opencensus") {} -Tracing::HttpTracerSharedPtr OpenCensusTracerFactory::createHttpTracerTyped( +Tracing::DriverSharedPtr OpenCensusTracerFactory::createTracerDriverTyped( const envoy::config::trace::v3::OpenCensusConfig& proto_config, Server::Configuration::TracerFactoryContext& context) { // Since OpenCensus can only support a single tracing configuration per entire process, // we need to make sure that it is configured at most once. - if (tracer_) { + if (driver_) { if (Envoy::Protobuf::util::MessageDifferencer::Equals(config_, proto_config)) { - return tracer_; + return driver_; } else { throw EnvoyException("Opencensus has already been configured with a different config."); } } - Tracing::DriverPtr driver = - std::make_unique(proto_config, context.serverFactoryContext().localInfo(), - context.serverFactoryContext().api()); - tracer_ = std::make_shared(std::move(driver), - context.serverFactoryContext().localInfo()); + + driver_ = std::make_shared(proto_config, context.serverFactoryContext().localInfo(), + context.serverFactoryContext().api()); config_ = proto_config; - return tracer_; + return driver_; } /** diff --git a/source/extensions/tracers/opencensus/config.h b/source/extensions/tracers/opencensus/config.h index a5270a45cb865..5b853f9b9e1dd 100644 --- a/source/extensions/tracers/opencensus/config.h +++ b/source/extensions/tracers/opencensus/config.h @@ -22,13 +22,13 @@ class OpenCensusTracerFactory private: // FactoryBase - Tracing::HttpTracerSharedPtr - createHttpTracerTyped(const envoy::config::trace::v3::OpenCensusConfig& proto_config, - Server::Configuration::TracerFactoryContext& context) override; + Tracing::DriverSharedPtr + createTracerDriverTyped(const envoy::config::trace::v3::OpenCensusConfig& proto_config, + Server::Configuration::TracerFactoryContext& context) override; // Since OpenCensus can only support a single tracing configuration per entire process, // we need to make sure that it is configured at most once. - Tracing::HttpTracerSharedPtr tracer_; + Tracing::DriverSharedPtr driver_; envoy::config::trace::v3::OpenCensusConfig config_; }; diff --git a/source/extensions/tracers/opencensus/opencensus_tracer_impl.h b/source/extensions/tracers/opencensus/opencensus_tracer_impl.h index 2c06d0c49a5db..3d4cbf7cdae91 100644 --- a/source/extensions/tracers/opencensus/opencensus_tracer_impl.h +++ b/source/extensions/tracers/opencensus/opencensus_tracer_impl.h @@ -3,7 +3,7 @@ #include "envoy/api/api.h" #include "envoy/config/trace/v3/opencensus.pb.h" #include "envoy/local_info/local_info.h" -#include "envoy/tracing/http_tracer.h" +#include "envoy/tracing/trace_driver.h" #include "common/common/logger.h" diff --git a/source/extensions/tracers/skywalking/config.cc b/source/extensions/tracers/skywalking/config.cc index 4f9e15b12f2dc..12e1b43c01579 100644 --- a/source/extensions/tracers/skywalking/config.cc +++ b/source/extensions/tracers/skywalking/config.cc @@ -5,7 +5,6 @@ #include "envoy/registry/registry.h" #include "common/common/utility.h" -#include "common/tracing/http_tracer_impl.h" #include "extensions/tracers/skywalking/skywalking_tracer_impl.h" @@ -16,13 +15,10 @@ namespace SkyWalking { SkyWalkingTracerFactory::SkyWalkingTracerFactory() : FactoryBase("envoy.tracers.skywalking") {} -Tracing::HttpTracerSharedPtr SkyWalkingTracerFactory::createHttpTracerTyped( +Tracing::DriverSharedPtr SkyWalkingTracerFactory::createTracerDriverTyped( const envoy::config::trace::v3::SkyWalkingConfig& proto_config, Server::Configuration::TracerFactoryContext& context) { - Tracing::DriverPtr skywalking_driver = - std::make_unique(proto_config, context); - return std::make_shared(std::move(skywalking_driver), - context.serverFactoryContext().localInfo()); + return std::make_shared(proto_config, context); } /** diff --git a/source/extensions/tracers/skywalking/config.h b/source/extensions/tracers/skywalking/config.h index abeffe373e5d7..0fc1ad8dc9671 100644 --- a/source/extensions/tracers/skywalking/config.h +++ b/source/extensions/tracers/skywalking/config.h @@ -20,9 +20,9 @@ class SkyWalkingTracerFactory private: // FactoryBase - Tracing::HttpTracerSharedPtr - createHttpTracerTyped(const envoy::config::trace::v3::SkyWalkingConfig& proto_config, - Server::Configuration::TracerFactoryContext& context) override; + Tracing::DriverSharedPtr + createTracerDriverTyped(const envoy::config::trace::v3::SkyWalkingConfig& proto_config, + Server::Configuration::TracerFactoryContext& context) override; }; } // namespace SkyWalking diff --git a/source/extensions/tracers/skywalking/skywalking_tracer_impl.h b/source/extensions/tracers/skywalking/skywalking_tracer_impl.h index 0b64b37efe16c..a2443f10d2ba8 100644 --- a/source/extensions/tracers/skywalking/skywalking_tracer_impl.h +++ b/source/extensions/tracers/skywalking/skywalking_tracer_impl.h @@ -3,9 +3,7 @@ #include "envoy/config/trace/v3/skywalking.pb.h" #include "envoy/server/tracer_config.h" #include "envoy/thread_local/thread_local.h" -#include "envoy/tracing/http_tracer.h" - -#include "common/tracing/http_tracer_impl.h" +#include "envoy/tracing/trace_driver.h" #include "source/tracing_context_impl.h" diff --git a/source/extensions/tracers/skywalking/tracer.h b/source/extensions/tracers/skywalking/tracer.h index 3852d1718b90a..52e2a24fb18d1 100644 --- a/source/extensions/tracers/skywalking/tracer.h +++ b/source/extensions/tracers/skywalking/tracer.h @@ -2,7 +2,10 @@ #include -#include "common/tracing/http_tracer_impl.h" +#include "envoy/tracing/trace_driver.h" + +#include "common/tracing/common_values.h" +#include "common/tracing/null_span_impl.h" #include "extensions/tracers/skywalking/trace_segment_reporter.h" diff --git a/source/extensions/tracers/xray/BUILD b/source/extensions/tracers/xray/BUILD index d8779c3bf2f2c..797e8a84e407d 100644 --- a/source/extensions/tracers/xray/BUILD +++ b/source/extensions/tracers/xray/BUILD @@ -41,7 +41,7 @@ envoy_cc_library( ":daemon_cc_proto", "//include/envoy/common:time_interface", "//include/envoy/server:tracer_config_interface", - "//include/envoy/tracing:http_tracer_interface", + "//include/envoy/tracing:trace_driver_interface", "//source/common/common:hex_lib", "//source/common/common:macros", "//source/common/common:random_generator_lib", @@ -49,7 +49,8 @@ envoy_cc_library( "//source/common/json:json_loader_lib", "//source/common/protobuf:utility_lib", "//source/common/runtime:runtime_lib", - "//source/common/tracing:http_tracer_lib", + "//source/common/tracing:common_values_lib", + "//source/common/tracing:null_span_lib", ], ) diff --git a/source/extensions/tracers/xray/config.cc b/source/extensions/tracers/xray/config.cc index 96c2c5a10dbd9..ff9bd156ea7f3 100644 --- a/source/extensions/tracers/xray/config.cc +++ b/source/extensions/tracers/xray/config.cc @@ -9,7 +9,6 @@ #include "common/common/utility.h" #include "common/config/datasource.h" -#include "common/tracing/http_tracer_impl.h" #include "extensions/tracers/xray/xray_tracer_impl.h" @@ -20,9 +19,9 @@ namespace XRay { XRayTracerFactory::XRayTracerFactory() : FactoryBase("envoy.tracers.xray") {} -Tracing::HttpTracerSharedPtr -XRayTracerFactory::createHttpTracerTyped(const envoy::config::trace::v3::XRayConfig& proto_config, - Server::Configuration::TracerFactoryContext& context) { +Tracing::DriverSharedPtr +XRayTracerFactory::createTracerDriverTyped(const envoy::config::trace::v3::XRayConfig& proto_config, + Server::Configuration::TracerFactoryContext& context) { std::string sampling_rules_json; try { sampling_rules_json = Config::DataSource::read(proto_config.sampling_rule_manifest(), true, @@ -51,10 +50,7 @@ XRayTracerFactory::createHttpTracerTyped(const envoy::config::trace::v3::XRayCon XRayConfiguration xconfig{endpoint, proto_config.segment_name(), sampling_rules_json, origin, std::move(aws)}; - auto xray_driver = std::make_unique(xconfig, context); - - return std::make_shared(std::move(xray_driver), - context.serverFactoryContext().localInfo()); + return std::make_shared(xconfig, context); } /** diff --git a/source/extensions/tracers/xray/config.h b/source/extensions/tracers/xray/config.h index 69e1201de2f94..00c5b3d5fa8ef 100644 --- a/source/extensions/tracers/xray/config.h +++ b/source/extensions/tracers/xray/config.h @@ -20,9 +20,9 @@ class XRayTracerFactory : public Common::FactoryBase( + return std::make_shared( proto_config, context.serverFactoryContext().clusterManager(), context.serverFactoryContext().scope(), context.serverFactoryContext().threadLocal(), context.serverFactoryContext().runtime(), context.serverFactoryContext().localInfo(), context.serverFactoryContext().api().randomGenerator(), context.serverFactoryContext().timeSource()); - - return std::make_shared(std::move(zipkin_driver), - context.serverFactoryContext().localInfo()); } /** diff --git a/source/extensions/tracers/zipkin/config.h b/source/extensions/tracers/zipkin/config.h index b91ef7cb7f350..8c879e64f5243 100644 --- a/source/extensions/tracers/zipkin/config.h +++ b/source/extensions/tracers/zipkin/config.h @@ -19,9 +19,9 @@ class ZipkinTracerFactory : public Common::FactoryBase(); DriverPtr driver_ptr(driver_); tracer_ = std::make_shared(std::move(driver_ptr), local_info_); } Http::TestRequestHeaderMapImpl request_headers_{ {":path", "/"}, {":method", "GET"}, {"x-request-id", "foo"}, {":authority", "test"}}; - Http::TestResponseHeaderMapImpl response_headers; - Http::TestResponseTrailerMapImpl response_trailers; - StreamInfo::MockStreamInfo stream_info_; + Http::TestResponseHeaderMapImpl response_headers_{{":status", "200"}, + {"content-type", "application/grpc"}, + {"grpc-status", "7"}, + {"grpc-message", "permission denied"}}; + Http::TestResponseTrailerMapImpl response_trailers_; + NiceMock stream_info_; NiceMock local_info_; - MockConfig config_; - MockDriver* driver_; + NiceMock config_; + NiceMock* driver_; HttpTracerSharedPtr tracer_; }; @@ -764,6 +777,58 @@ TEST_F(HttpTracerImplTest, BasicFunctionalityNodeSet) { tracer_->startSpan(config_, request_headers_, stream_info_, {Reason::Sampling, true}); } +TEST_F(HttpTracerImplTest, ChildUpstreamSpanTest) { + EXPECT_CALL(stream_info_, startTime()); + EXPECT_CALL(local_info_, nodeName()); + EXPECT_CALL(config_, operationName()).Times(2).WillRepeatedly(Return(OperationName::Egress)); + + NiceMock* span = new NiceMock(); + const std::string operation_name = "egress test"; + EXPECT_CALL(*driver_, startSpan_(_, _, operation_name, stream_info_.start_time_, _)) + .WillOnce(Return(span)); + EXPECT_CALL(*span, setTag(_, _)).Times(testing::AnyNumber()); + EXPECT_CALL(*span, setTag(Eq(Tracing::Tags::get().NodeId), Eq("node_name"))); + + auto parent_span = + tracer_->startSpan(config_, request_headers_, stream_info_, {Reason::Sampling, true}); + + NiceMock* second_span = new NiceMock(); + + EXPECT_CALL(*span, spawnChild_(_, _, _)).WillOnce(Return(second_span)); + auto child_span = + parent_span->spawnChild(config_, "fake child of egress test", stream_info_.start_time_); + + const std::string expected_ip = "10.0.0.100"; + const auto remote_address = Network::Address::InstanceConstSharedPtr{ + new Network::Address::Ipv4Instance(expected_ip, 0, nullptr)}; + + absl::optional protocol = Http::Protocol::Http2; + absl::optional response_code(200); + const std::string cluster_name = "fake cluster"; + const std::string ob_cluster_name = "ob fake cluster"; + EXPECT_CALL(stream_info_, responseCode()).WillRepeatedly(ReturnPointee(&response_code)); + EXPECT_CALL(stream_info_, protocol()).WillRepeatedly(ReturnPointee(&protocol)); + EXPECT_CALL(*(stream_info_.host_), address()).WillOnce(Return(remote_address)); + EXPECT_CALL(stream_info_.host_->cluster_, name()).WillOnce(ReturnRef(cluster_name)); + EXPECT_CALL(stream_info_.host_->cluster_, observabilityName()) + .WillOnce(ReturnRef(ob_cluster_name)); + + EXPECT_CALL(*second_span, setTag(_, _)).Times(testing::AnyNumber()); + EXPECT_CALL(*second_span, setTag(Eq(Tracing::Tags::get().HttpProtocol), Eq("HTTP/2"))); + EXPECT_CALL(*second_span, + setTag(Eq(Tracing::Tags::get().UpstreamAddress), Eq(expected_ip + ":0"))); + EXPECT_CALL(*second_span, setTag(Eq(Tracing::Tags::get().UpstreamCluster), Eq("fake cluster"))); + EXPECT_CALL(*second_span, + setTag(Eq(Tracing::Tags::get().UpstreamClusterName), Eq("ob fake cluster"))); + EXPECT_CALL(*second_span, setTag(Eq(Tracing::Tags::get().HttpStatusCode), Eq("200"))); + EXPECT_CALL(*second_span, setTag(Eq(Tracing::Tags::get().GrpcStatusCode), Eq("7"))); + EXPECT_CALL(*second_span, setTag(Eq(Tracing::Tags::get().GrpcMessage), Eq("permission denied"))); + EXPECT_CALL(*second_span, setTag(Eq(Tracing::Tags::get().Error), Eq(Tracing::Tags::get().True))); + + HttpTracerUtility::finalizeUpstreamSpan(*child_span, &response_headers_, &response_trailers_, + stream_info_, config_); +} + } // namespace } // namespace Tracing } // namespace Envoy diff --git a/test/common/tracing/http_tracer_manager_impl_test.cc b/test/common/tracing/http_tracer_manager_impl_test.cc index 67f802af9edc6..2b49433879b45 100644 --- a/test/common/tracing/http_tracer_manager_impl_test.cc +++ b/test/common/tracing/http_tracer_manager_impl_test.cc @@ -1,6 +1,6 @@ -#include "common/tracing/http_tracer_config_impl.h" #include "common/tracing/http_tracer_impl.h" #include "common/tracing/http_tracer_manager_impl.h" +#include "common/tracing/tracer_config_impl.h" #include "test/mocks/server/instance.h" #include "test/mocks/server/tracer_factory.h" @@ -20,9 +20,9 @@ namespace Envoy { namespace Tracing { namespace { -class SampleTracer : public HttpTracer { +class SampleDriver : public Driver { public: - SpanPtr startSpan(const Config&, Http::RequestHeaderMap&, const StreamInfo::StreamInfo&, + SpanPtr startSpan(const Config&, Http::RequestHeaderMap&, const std::string&, SystemTime, const Tracing::Decision) override { return nullptr; } @@ -30,10 +30,10 @@ class SampleTracer : public HttpTracer { class SampleTracerFactory : public Server::Configuration::TracerFactory { public: - Tracing::HttpTracerSharedPtr - createHttpTracer(const Protobuf::Message&, - Server::Configuration::TracerFactoryContext&) override { - return std::make_shared(); + Tracing::DriverSharedPtr + createTracerDriver(const Protobuf::Message&, + Server::Configuration::TracerFactoryContext&) override { + return std::make_shared(); } std::string name() const override { return "envoy.tracers.sample"; } @@ -69,8 +69,11 @@ TEST_F(HttpTracerManagerImplTest, ShouldUseProperTracerFactory) { auto http_tracer = http_tracer_manager_.getOrCreateHttpTracer(&tracing_config); + EXPECT_THAT(http_tracer.get(), WhenDynamicCastTo(NotNull())); + auto http_tracer_impl = dynamic_cast(http_tracer.get()); + // Should use proper TracerFactory. - EXPECT_THAT(http_tracer.get(), WhenDynamicCastTo(NotNull())); + EXPECT_THAT(http_tracer_impl->driverForTest().get(), WhenDynamicCastTo(NotNull())); } TEST_F(HttpTracerManagerImplTest, ShouldCacheAndReuseTracers) { @@ -162,23 +165,25 @@ class HttpTracerManagerImplCacheTest : public testing::Test { }; TEST_F(HttpTracerManagerImplCacheTest, ShouldCacheHttpTracersUsingWeakReferences) { - HttpTracer* expected_tracer = new NiceMock(); + Driver* expected_driver = new NiceMock(); // Expect HttpTracerManager to create a new HttpTracer. - EXPECT_CALL(tracer_factory_, createHttpTracer(_, _)) + EXPECT_CALL(tracer_factory_, createTracerDriver(_, _)) .WillOnce(InvokeWithoutArgs( - [expected_tracer] { return std::shared_ptr(expected_tracer); })); + [expected_driver] { return std::shared_ptr(expected_driver); })); auto actual_tracer_one = http_tracer_manager_.getOrCreateHttpTracer(&tracing_config_one_); - EXPECT_EQ(actual_tracer_one.get(), expected_tracer); + EXPECT_EQ(dynamic_cast(actual_tracer_one.get())->driverForTest().get(), + expected_driver); // Expect a new HttpTracer to be added to the cache. EXPECT_THAT(http_tracer_manager_.peekCachedTracersForTest(), SizeIs(1)); // Expect HttpTracerManager to re-use cached value. auto actual_tracer_two = http_tracer_manager_.getOrCreateHttpTracer(&tracing_config_one_); - EXPECT_EQ(actual_tracer_two.get(), expected_tracer); + EXPECT_EQ(dynamic_cast(actual_tracer_one.get())->driverForTest().get(), + expected_driver); // Expect no changes to the cache. EXPECT_THAT(http_tracer_manager_.peekCachedTracersForTest(), SizeIs(1)); @@ -194,25 +199,26 @@ TEST_F(HttpTracerManagerImplCacheTest, ShouldCacheHttpTracersUsingWeakReferences // Expect no more strong references to be left. EXPECT_EQ(weak_pointer.lock(), nullptr); - HttpTracer* expected_another_tracer = new NiceMock(); + Driver* expected_other_driver = new NiceMock(); // Expect HttpTracerManager to create a new HttpTracer once again. - EXPECT_CALL(tracer_factory_, createHttpTracer(_, _)) - .WillOnce(InvokeWithoutArgs([expected_another_tracer] { - return std::shared_ptr(expected_another_tracer); - })); + EXPECT_CALL(tracer_factory_, createTracerDriver(_, _)) + .WillOnce(InvokeWithoutArgs( + [expected_other_driver] { return std::shared_ptr(expected_other_driver); })); // Use a different config to guarantee that a new cache entry will be added anyway. auto actual_tracer_three = http_tracer_manager_.getOrCreateHttpTracer(&tracing_config_two_); - EXPECT_EQ(actual_tracer_three.get(), expected_another_tracer); + EXPECT_EQ(dynamic_cast(actual_tracer_three.get())->driverForTest().get(), + expected_other_driver); // Expect expired cache entries to be removed and a new HttpTracer to be added to the cache. EXPECT_THAT(http_tracer_manager_.peekCachedTracersForTest(), SizeIs(1)); // Expect HttpTracerManager to keep the right value in the cache. auto actual_tracer_four = http_tracer_manager_.getOrCreateHttpTracer(&tracing_config_two_); - EXPECT_EQ(actual_tracer_four.get(), expected_another_tracer); + EXPECT_EQ(dynamic_cast(actual_tracer_four.get())->driverForTest().get(), + expected_other_driver); // Expect no changes to the cache. EXPECT_THAT(http_tracer_manager_.peekCachedTracersForTest(), SizeIs(1)); } diff --git a/test/extensions/tracers/datadog/config_test.cc b/test/extensions/tracers/datadog/config_test.cc index 6171c0691e767..b591004204317 100644 --- a/test/extensions/tracers/datadog/config_test.cc +++ b/test/extensions/tracers/datadog/config_test.cc @@ -38,7 +38,7 @@ TEST(DatadogTracerConfigTest, DatadogHttpTracer) { DatadogTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr datadog_tracer = factory.createHttpTracer(*message, context); + auto datadog_tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, datadog_tracer); } diff --git a/test/extensions/tracers/dynamic_ot/config_test.cc b/test/extensions/tracers/dynamic_ot/config_test.cc index 951a71ba416e2..3ccabd8b3a3b7 100644 --- a/test/extensions/tracers/dynamic_ot/config_test.cc +++ b/test/extensions/tracers/dynamic_ot/config_test.cc @@ -49,7 +49,7 @@ TEST(DynamicOtTracerConfigTest, DynamicOpentracingHttpTracer) { DynamicOpenTracingTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - const Tracing::HttpTracerSharedPtr tracer = factory.createHttpTracer(*message, context); + auto tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, tracer); } diff --git a/test/extensions/tracers/lightstep/config_test.cc b/test/extensions/tracers/lightstep/config_test.cc index 60725e610fd26..a490959a6b050 100644 --- a/test/extensions/tracers/lightstep/config_test.cc +++ b/test/extensions/tracers/lightstep/config_test.cc @@ -41,7 +41,7 @@ TEST(LightstepTracerConfigTest, DEPRECATED_FEATURE_TEST(LightstepHttpTracer)) { LightstepTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr lightstep_tracer = factory.createHttpTracer(*message, context); + auto lightstep_tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, lightstep_tracer); } @@ -67,7 +67,7 @@ TEST(LightstepTracerConfigTest, LightstepHttpTracerAccessToken) { LightstepTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr lightstep_tracer = factory.createHttpTracer(*message, context); + auto lightstep_tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, lightstep_tracer); } diff --git a/test/extensions/tracers/opencensus/config_test.cc b/test/extensions/tracers/opencensus/config_test.cc index 0de2ac976df5c..ecb6b5d99c1c4 100644 --- a/test/extensions/tracers/opencensus/config_test.cc +++ b/test/extensions/tracers/opencensus/config_test.cc @@ -37,7 +37,7 @@ TEST(OpenCensusTracerConfigTest, InvalidStackdriverConfiguration) { auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - EXPECT_THROW_WITH_MESSAGE((factory.createHttpTracer(*message, context)), EnvoyException, + EXPECT_THROW_WITH_MESSAGE((factory.createTracerDriver(*message, context)), EnvoyException, "Opencensus stackdriver tracer only support GoogleGrpc."); } @@ -60,7 +60,7 @@ TEST(OpenCensusTracerConfigTest, InvalidOcagentConfiguration) { auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - EXPECT_THROW_WITH_MESSAGE((factory.createHttpTracer(*message, context)), EnvoyException, + EXPECT_THROW_WITH_MESSAGE((factory.createTracerDriver(*message, context)), EnvoyException, "Opencensus ocagent tracer only supports GoogleGrpc."); } @@ -77,7 +77,7 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracer) { OpenCensusTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr tracer = factory.createHttpTracer(*message, context); + auto tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, tracer); } @@ -113,7 +113,7 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracerWithTypedConfig) { OpenCensusTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr tracer = factory.createHttpTracer(*message, context); + auto tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, tracer); // Reset TraceParams back to default. @@ -147,7 +147,7 @@ TEST(OpenCensusTracerConfigTest, OpenCensusTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr tracer = factory.createHttpTracer(*message, context); + auto tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, tracer); // Reset TraceParams back to default. @@ -188,7 +188,7 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracerGrpc) { auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); #ifdef ENVOY_GOOGLE_GRPC - Tracing::HttpTracerSharedPtr tracer = factory.createHttpTracer(*message, context); + auto tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, tracer); // Reset TraceParams back to default. @@ -196,7 +196,7 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracerGrpc) { {32, 32, 128, 32, ::opencensus::trace::ProbabilitySampler(1e-4)}); #else EXPECT_THROW_WITH_MESSAGE( - (factory.createHttpTracer(*message, context)), EnvoyException, + (factory.createTracerDriver(*message, context)), EnvoyException, "Opencensus tracer: cannot handle ocagent google grpc service, google grpc is not built in."); #endif } @@ -219,12 +219,12 @@ TEST(OpenCensusTracerConfigTest, ShouldCreateAtMostOneOpenCensusTracer) { auto message_one = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr tracer_one = factory.createHttpTracer(*message_one, context); + auto tracer_one = factory.createTracerDriver(*message_one, context); EXPECT_NE(nullptr, tracer_one); auto message_two = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr tracer_two = factory.createHttpTracer(*message_two, context); + auto tracer_two = factory.createTracerDriver(*message_two, context); // Verify that no new tracer has been created. EXPECT_EQ(tracer_two, tracer_one); } @@ -242,13 +242,13 @@ TEST(OpenCensusTracerConfigTest, ShouldCacheFirstCreatedTracerUsingStrongReferen auto message_one = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - std::weak_ptr tracer_one = factory.createHttpTracer(*message_one, context); + std::weak_ptr tracer_one = factory.createTracerDriver(*message_one, context); // Verify that tracer factory keeps a strong reference. EXPECT_NE(nullptr, tracer_one.lock()); auto message_two = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr tracer_two = factory.createHttpTracer(*message_two, context); + auto tracer_two = factory.createTracerDriver(*message_two, context); EXPECT_NE(nullptr, tracer_two); // Verify that no new tracer has been created. EXPECT_EQ(tracer_two, tracer_one.lock()); @@ -273,7 +273,7 @@ TEST(OpenCensusTracerConfigTest, ShouldNotCacheInvalidConfiguration) { auto message_one = Config::Utility::translateToFactoryConfig( configuration_one.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - EXPECT_THROW_WITH_MESSAGE((factory.createHttpTracer(*message_one, context)), EnvoyException, + EXPECT_THROW_WITH_MESSAGE((factory.createTracerDriver(*message_one, context)), EnvoyException, "Opencensus ocagent tracer only supports GoogleGrpc."); const std::string yaml_two = R"EOF( @@ -293,12 +293,12 @@ TEST(OpenCensusTracerConfigTest, ShouldNotCacheInvalidConfiguration) { auto message_two = Config::Utility::translateToFactoryConfig( configuration_two.http(), ProtobufMessage::getStrictValidationVisitor(), factory); #ifdef ENVOY_GOOGLE_GRPC - Tracing::HttpTracerSharedPtr tracer_two = factory.createHttpTracer(*message_two, context); + auto tracer_two = factory.createTracerDriver(*message_two, context); // Verify that a new tracer has been created despite an earlier failed attempt. EXPECT_NE(nullptr, tracer_two); #else EXPECT_THROW_WITH_MESSAGE( - (factory.createHttpTracer(*message_two, context)), EnvoyException, + (factory.createTracerDriver(*message_two, context)), EnvoyException, "Opencensus tracer: cannot handle ocagent google grpc service, google grpc is not built in."); #endif } @@ -321,7 +321,7 @@ TEST(OpenCensusTracerConfigTest, ShouldRejectSubsequentCreateAttemptsWithDiffere auto message_one = Config::Utility::translateToFactoryConfig( configuration_one.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr tracer_one = factory.createHttpTracer(*message_one, context); + auto tracer_one = factory.createTracerDriver(*message_one, context); EXPECT_NE(nullptr, tracer_one); const std::string yaml_two = R"EOF( @@ -339,7 +339,7 @@ TEST(OpenCensusTracerConfigTest, ShouldRejectSubsequentCreateAttemptsWithDiffere auto message_two = Config::Utility::translateToFactoryConfig( configuration_two.http(), ProtobufMessage::getStrictValidationVisitor(), factory); // Verify that OpenCensus is only configured once in a lifetime. - EXPECT_THROW_WITH_MESSAGE((factory.createHttpTracer(*message_two, context)), EnvoyException, + EXPECT_THROW_WITH_MESSAGE((factory.createTracerDriver(*message_two, context)), EnvoyException, "Opencensus has already been configured with a different config."); } @@ -367,10 +367,10 @@ TEST(OpenCensusTracerConfigTest, OpenCensusHttpTracerStackdriverGrpc) { auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); #ifdef ENVOY_GOOGLE_GRPC - Tracing::HttpTracerSharedPtr tracer = factory.createHttpTracer(*message, context); + auto tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, tracer); #else - EXPECT_THROW_WITH_MESSAGE((factory.createHttpTracer(*message, context)), EnvoyException, + EXPECT_THROW_WITH_MESSAGE((factory.createTracerDriver(*message, context)), EnvoyException, "Opencensus tracer: cannot handle stackdriver google grpc service, " "google grpc is not built in."); #endif diff --git a/test/extensions/tracers/skywalking/config_test.cc b/test/extensions/tracers/skywalking/config_test.cc index 1f1082298f1fa..f865525e09a3b 100644 --- a/test/extensions/tracers/skywalking/config_test.cc +++ b/test/extensions/tracers/skywalking/config_test.cc @@ -45,7 +45,7 @@ TEST(SkyWalkingTracerConfigTest, SkyWalkingHttpTracer) { SkyWalkingTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr skywalking_tracer = factory.createHttpTracer(*message, context); + auto skywalking_tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, skywalking_tracer); } @@ -79,7 +79,7 @@ TEST(SkyWalkingTracerConfigTest, SkyWalkingHttpTracerWithClientConfig) { SkyWalkingTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr skywalking_tracer = factory.createHttpTracer(*message, context); + auto skywalking_tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, skywalking_tracer); } diff --git a/test/extensions/tracers/xray/config_test.cc b/test/extensions/tracers/xray/config_test.cc index 7008ef0a0c54e..26b613eaec3a9 100644 --- a/test/extensions/tracers/xray/config_test.cc +++ b/test/extensions/tracers/xray/config_test.cc @@ -43,7 +43,7 @@ TEST(XRayTracerConfigTest, XRayHttpTracerWithTypedConfig) { XRayTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr xray_tracer = factory.createHttpTracer(*message, context); + auto xray_tracer = factory.createTracerDriver(*message, context); ASSERT_NE(nullptr, xray_tracer); } @@ -78,7 +78,7 @@ TEST(XRayTracerConfigTest, XRayHttpTracerWithInvalidFileName) { auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr xray_tracer = factory.createHttpTracer(*message, context); + auto xray_tracer = factory.createTracerDriver(*message, context); ASSERT_NE(nullptr, xray_tracer); } @@ -104,7 +104,7 @@ TEST(XRayTracerConfigTest, ProtocolNotUDPThrows) { auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - ASSERT_THROW(factory.createHttpTracer(*message, context), EnvoyException); + ASSERT_THROW(factory.createTracerDriver(*message, context), EnvoyException); } TEST(XRayTracerConfigTest, UsingNamedPortThrows) { @@ -129,7 +129,7 @@ TEST(XRayTracerConfigTest, UsingNamedPortThrows) { auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - ASSERT_THROW(factory.createHttpTracer(*message, context), EnvoyException); + ASSERT_THROW(factory.createTracerDriver(*message, context), EnvoyException); } TEST(XRayTracerConfigTest, XRayHttpTracerWithSegmentFieldsTypedConfig) { @@ -162,7 +162,7 @@ TEST(XRayTracerConfigTest, XRayHttpTracerWithSegmentFieldsTypedConfig) { XRayTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr xray_tracer = factory.createHttpTracer(*message, context); + auto xray_tracer = factory.createTracerDriver(*message, context); ASSERT_NE(nullptr, xray_tracer); } diff --git a/test/extensions/tracers/zipkin/config_test.cc b/test/extensions/tracers/zipkin/config_test.cc index b0219b927665d..945a0e172d446 100644 --- a/test/extensions/tracers/zipkin/config_test.cc +++ b/test/extensions/tracers/zipkin/config_test.cc @@ -39,7 +39,7 @@ TEST(ZipkinTracerConfigTest, ZipkinHttpTracer) { ZipkinTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr zipkin_tracer = factory.createHttpTracer(*message, context); + auto zipkin_tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, zipkin_tracer); } @@ -63,7 +63,7 @@ TEST(ZipkinTracerConfigTest, ZipkinHttpTracerWithTypedConfig) { ZipkinTracerFactory factory; auto message = Config::Utility::translateToFactoryConfig( configuration.http(), ProtobufMessage::getStrictValidationVisitor(), factory); - Tracing::HttpTracerSharedPtr zipkin_tracer = factory.createHttpTracer(*message, context); + auto zipkin_tracer = factory.createTracerDriver(*message, context); EXPECT_NE(nullptr, zipkin_tracer); } diff --git a/test/mocks/server/tracer_factory.h b/test/mocks/server/tracer_factory.h index e342116ee2d5a..c9d4fa73e41b8 100644 --- a/test/mocks/server/tracer_factory.h +++ b/test/mocks/server/tracer_factory.h @@ -16,7 +16,7 @@ class MockTracerFactory : public TracerFactory { std::string name() const override { return name_; } MOCK_METHOD(ProtobufTypes::MessagePtr, createEmptyConfigProto, ()); - MOCK_METHOD(Tracing::HttpTracerSharedPtr, createHttpTracer, + MOCK_METHOD(Tracing::DriverSharedPtr, createTracerDriver, (const Protobuf::Message& config, TracerFactoryContext& context)); private: