diff --git a/changelogs/current.yaml b/changelogs/current.yaml index 79947a08c0e2..1f8446e457a3 100644 --- a/changelogs/current.yaml +++ b/changelogs/current.yaml @@ -2,6 +2,10 @@ date: Pending behavior_changes: # *Changes that are expected to cause an incompatibility if applicable; deployment changes are likely required* +- area: ext_proc + change: | + Previously, tracing spans generated by ``ext_proc`` were always sampled by default. + Now, the default sampling decision of an ``ext_proc`` span is inherited from the parent span. - area: tracing change: | Removed support for (long deprecated) opencensus tracing extension. diff --git a/source/extensions/filters/http/ext_proc/ext_proc.cc b/source/extensions/filters/http/ext_proc/ext_proc.cc index 06370ca21a4f..a24b99c310e2 100644 --- a/source/extensions/filters/http/ext_proc/ext_proc.cc +++ b/source/extensions/filters/http/ext_proc/ext_proc.cc @@ -399,7 +399,8 @@ Filter::StreamOpenState Filter::openStream() { auto options = Http::AsyncClient::StreamOptions() .setParentSpan(decoder_callbacks_->activeSpan()) .setParentContext(grpc_context) - .setBufferBodyForRetry(grpc_service_.has_retry_policy()); + .setBufferBodyForRetry(grpc_service_.has_retry_policy()) + .setSampled(absl::nullopt); ExternalProcessorClient* grpc_client = dynamic_cast(client_.get()); ExternalProcessorStreamPtr stream_object = diff --git a/test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc b/test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc index 7b77ed265849..fdc7fd69fa7f 100644 --- a/test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc +++ b/test/extensions/filters/http/ext_proc/ext_proc_integration_test.cc @@ -793,7 +793,7 @@ TEST_P(ExtProcIntegrationTest, GetAndCloseStreamWithTracing) { ext_proc_span.set_operation_name( "async envoy.service.ext_proc.v3.ExternalProcessor.Process egress"); ext_proc_span.set_context_injected(true); - ext_proc_span.set_sampled(true); + ext_proc_span.set_sampled(false); ext_proc_span.mutable_tags()->insert({"grpc.status_code", "0"}); ext_proc_span.mutable_tags()->insert({"upstream_cluster", "ext_proc_server_0"}); if (IsEnvoyGrpc()) { @@ -859,7 +859,7 @@ TEST_P(ExtProcIntegrationTest, GetAndFailStreamWithTracing) { ext_proc_span.set_operation_name( "async envoy.service.ext_proc.v3.ExternalProcessor.Process egress"); ext_proc_span.set_context_injected(true); - ext_proc_span.set_sampled(true); + ext_proc_span.set_sampled(false); ext_proc_span.mutable_tags()->insert({"grpc.status_code", "2"}); ext_proc_span.mutable_tags()->insert({"error", "true"}); ext_proc_span.mutable_tags()->insert({"upstream_cluster", "ext_proc_server_0"}); @@ -2485,7 +2485,7 @@ TEST_P(ExtProcIntegrationTest, RequestMessageTimeoutWithTracing) { ext_proc_span.set_operation_name( "async envoy.service.ext_proc.v3.ExternalProcessor.Process egress"); ext_proc_span.set_context_injected(true); - ext_proc_span.set_sampled(true); + ext_proc_span.set_sampled(false); ext_proc_span.mutable_tags()->insert({"status", "canceled"}); ext_proc_span.mutable_tags()->insert({"error", ""}); // not an error ext_proc_span.mutable_tags()->insert({"upstream_cluster", "ext_proc_server_0"}); diff --git a/test/extensions/filters/http/ext_proc/tracer_test_filter.cc b/test/extensions/filters/http/ext_proc/tracer_test_filter.cc index 645101ea1d21..bf29f3367960 100644 --- a/test/extensions/filters/http/ext_proc/tracer_test_filter.cc +++ b/test/extensions/filters/http/ext_proc/tracer_test_filter.cc @@ -20,10 +20,10 @@ const Tracing::TraceContextHandler& traceParentHeader() { struct ExpectedSpan { std::string operation_name; - bool sampled; - bool context_injected; + bool sampled{false}; + bool context_injected{false}; std::map tags; - bool tested; + bool tested{false}; }; using ExpectedSpansSharedPtr = std::shared_ptr>; @@ -116,9 +116,9 @@ class Span : public Tracing::Span { ExpectedSpansSharedPtr expected_spans_; std::map tags_; - bool context_injected_; - bool sampled_; - bool finished_; + bool context_injected_{false}; + bool sampled_{false}; + bool finished_{false}; }; class Driver : public Tracing::Driver, Logger::Loggable {