Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext_proc: change default sampling to false inheriting from parent decision #37794

Merged
merged 3 commits into from
Jan 8, 2025
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: 4 additions & 0 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion source/extensions/filters/http/ext_proc/ext_proc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExternalProcessorClient*>(client_.get());
ExternalProcessorStreamPtr stream_object =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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"});
Expand Down Expand Up @@ -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"});
Expand Down
12 changes: 6 additions & 6 deletions test/extensions/filters/http/ext_proc/tracer_test_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::string> tags;
bool tested;
bool tested{false};
};

using ExpectedSpansSharedPtr = std::shared_ptr<std::vector<ExpectedSpan>>;
Expand Down Expand Up @@ -116,9 +116,9 @@ class Span : public Tracing::Span {
ExpectedSpansSharedPtr expected_spans_;

std::map<std::string, std::string> tags_;
bool context_injected_;
bool sampled_;
bool finished_;
bool context_injected_{false};
bool sampled_{false};
bool finished_{false};
cainelli marked this conversation as resolved.
Show resolved Hide resolved
};

class Driver : public Tracing::Driver, Logger::Loggable<Logger::Id::tracing> {
Expand Down