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
189 changes: 0 additions & 189 deletions doc/sampling-delegation.md

This file was deleted.

6 changes: 0 additions & 6 deletions examples/http-server/proxy/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ int main() {
span.set_error_message(httplib::to_string(er));
std::cerr << "Error occurred while proxying request: " << req.target
<< "\n";
} else {
tracingutil::HeaderReader reader(res.headers);
auto status = span.read_sampling_delegation_response(reader);
if (auto error = status.if_error()) {
std::cerr << error << "\n";
}
}

span.set_tag("http.status_code", std::to_string(res.status));
Expand Down
4 changes: 0 additions & 4 deletions examples/http-server/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ int main() {
// created. We finish it by popping it off of the span stack.
server.set_post_routing_handler([](const httplib::Request& request, httplib::Response& response) {
auto* context = static_cast<RequestTracingContext*>(request.user_data.get());

tracingutil::HeaderWriter writer(response.headers);
context->spans.top().trace_segment().write_sampling_delegation_response(writer);

context->spans.pop();
return httplib::Server::HandlerResponse::Unhandled;
});
Expand Down
1 change: 0 additions & 1 deletion include/datadog/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ namespace environment {
MACRO(DD_SERVICE) \
MACRO(DD_SPAN_SAMPLING_RULES) \
MACRO(DD_SPAN_SAMPLING_RULES_FILE) \
MACRO(DD_TRACE_DELEGATE_SAMPLING) \
MACRO(DD_TRACE_PROPAGATION_STYLE_EXTRACT) \
MACRO(DD_TRACE_PROPAGATION_STYLE_INJECT) \
MACRO(DD_TRACE_PROPAGATION_STYLE) \
Expand Down
12 changes: 1 addition & 11 deletions include/datadog/injection_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@
// parameters to `Span::inject` that alter the behavior of trace context
// propagation.

#include "optional.h"

namespace datadog {
namespace tracing {

struct InjectionOptions {
// If this tracer is using the "Datadog" propagation injection style, then
// include a request header that indicates that whoever extracts this trace
// context "on the other side" may make their own trace sampling decision
// and convey it back to us in a response header. If
// `delegate_sampling_decision` is null, then its value depends on the tracer
// configuration (see `TracerConfig::delegate_trace_sampling`).
Optional<bool> delegate_sampling_decision;
};
struct InjectionOptions {};

} // namespace tracing
} // namespace datadog
8 changes: 0 additions & 8 deletions include/datadog/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class Span {
std::function<std::uint64_t()> generate_span_id_;
Clock clock_;
Optional<std::chrono::steady_clock::time_point> end_time_;
mutable bool expecting_delegated_sampling_decision_;

public:
// Create a span whose properties are stored in the specified `data`, that is
Expand Down Expand Up @@ -169,13 +168,6 @@ class Span {
void inject(DictWriter& writer) const;
void inject(DictWriter& writer, const InjectionOptions& options) const;

// If this span is expecting a sampling decision that it previously delegated,
// then extract a sampling decision from the specified `reader`. Return an
// error if a sampling decision is present in `reader` but is invalid. Return
// success otherwise. The trace segment associated with this span might adopt
// the sampling decision from `reader`.
Expected<void> read_sampling_delegation_response(const DictReader& reader);

// Return a reference to this span's trace segment. The trace segment has
// member functions that affect the trace as a whole, such as
// `TraceSegment::override_sampling_priority`.
Expand Down
30 changes: 1 addition & 29 deletions include/datadog/trace_segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,6 @@ class TraceSegment {

std::shared_ptr<ConfigManager> config_manager_;

// See `doc/sampling-delegation.md` for more information about
// `struct SamplingDelegation`.
struct SamplingDelegation {
// This segment is configured to delegate its sampling decision.
bool enabled;
// The trace context from which the local root span was extracted delegated
// the sampling decision to this segment.
bool decision_was_delegated_to_me;
// This segment included a request for sampling delegation in outbound
// injected trace context (see `inject`).
bool sent_request_header;
// This segment received a (presumably delegated) sampling decision. See
// `read_sampling_delegation_response`.
bool received_matching_response_header;
// This segment conveyed a sampling decision back to a parent service that
// had previously requested a delegated sampling decision.
bool sent_response_header;
} sampling_delegation_ = {};

public:
TraceSegment(const std::shared_ptr<Logger>& logger,
const std::shared_ptr<Collector>& collector,
Expand All @@ -106,8 +87,7 @@ class TraceSegment {
const std::shared_ptr<SpanSampler>& span_sampler,
const std::shared_ptr<const SpanDefaults>& defaults,
const std::shared_ptr<ConfigManager>& config_manager,
const RuntimeID& runtime_id, bool sampling_delegation_enabled,
bool sampling_decision_was_delegated_to_me,
const RuntimeID& runtime_id,
const std::vector<PropagationStyle>& injection_styles,
const Optional<std::string>& hostname,
Optional<std::string> origin, std::size_t tags_header_max_size,
Expand All @@ -131,14 +111,6 @@ class TraceSegment {
bool inject(DictWriter& writer, const SpanData& span,
const InjectionOptions& options);

// Inject this segment's trace sampling decision into the specified `writer`,
// if appropriate.
void write_sampling_delegation_response(DictWriter& writer);

// Extract a trace sampling decision from the specified `reader` if it has
// one, and use the resulting decision, if appropriate.
Expected<void> read_sampling_delegation_response(const DictReader& reader);

// Take ownership of the specified `span`.
void register_span(std::unique_ptr<SpanData> span);
// Increment the number of finished spans. If that number is equal to the
Expand Down
1 change: 0 additions & 1 deletion include/datadog/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Tracer {
std::vector<PropagationStyle> extraction_styles_;
Optional<std::string> hostname_;
std::size_t tags_header_max_size_;
bool sampling_delegation_enabled_;
// Store the tracer configuration in an in-memory file, allowing it to be
// read to determine if the process is instrumented with a tracer and to
// retrieve relevant tracing information.
Expand Down
6 changes: 0 additions & 6 deletions include/datadog/tracer_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ struct TracerConfig {
// `telemetry/configuration.h` By default, the telemetry module is enabled.
telemetry::Configuration telemetry;

// `delegate_trace_sampling` indicates whether the tracer will consult a child
// service for a trace sampling decision, and prefer the resulting decision
// over its own, if appropriate.
Optional<bool> delegate_trace_sampling;

// `trace_sampler` configures trace sampling. Trace sampling determines which
// traces are sent to Datadog. See `trace_sampler_config.h`.
TraceSamplerConfig trace_sampler;
Expand Down Expand Up @@ -199,7 +194,6 @@ class FinalizedTracerConfig final {
Clock clock;
std::string integration_name;
std::string integration_version;
bool delegate_trace_sampling;
bool report_traces;
std::unordered_map<ConfigName, ConfigMetadata> metadata;
Baggage::Options baggage_opts;
Expand Down
1 change: 0 additions & 1 deletion src/datadog/extracted_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ struct ExtractedData {
Optional<std::uint64_t> parent_id;
Optional<std::string> origin;
std::vector<std::pair<std::string, std::string>> trace_tags;
bool delegate_sampling_decision = false;
Optional<int> sampling_priority;
// If this `ExtractedData` was created on account of `PropagationStyle::W3C`,
// then `datadog_w3c_parent_id` contains the parts of the "tracestate"
Expand Down
5 changes: 0 additions & 5 deletions src/datadog/extraction_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ Expected<ExtractedData> extract_datadog(
result.sampling_priority = *sampling_priority;
}

if (auto sampling_delegation_header =
headers.lookup("x-datadog-delegate-trace-sampling")) {
result.delegate_sampling_decision = true;
}

auto origin = headers.lookup("x-datadog-origin");
if (origin) {
result.origin = std::string(*origin);
Expand Down
17 changes: 3 additions & 14 deletions src/datadog/span.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Span::Span(SpanData* data, const std::shared_ptr<TraceSegment>& trace_segment,
: trace_segment_(trace_segment),
data_(data),
generate_span_id_(generate_span_id),
clock_(clock),
expecting_delegated_sampling_decision_(false) {
clock_(clock) {
assert(trace_segment_);
assert(data_);
assert(generate_span_id_);
Expand Down Expand Up @@ -59,21 +58,11 @@ Span Span::create_child(const SpanConfig& config) const {
Span Span::create_child() const { return create_child(SpanConfig{}); }

void Span::inject(DictWriter& writer) const {
expecting_delegated_sampling_decision_ =
trace_segment_->inject(writer, *data_);
trace_segment_->inject(writer, *data_);
}

void Span::inject(DictWriter& writer, const InjectionOptions& options) const {
expecting_delegated_sampling_decision_ =
trace_segment_->inject(writer, *data_, options);
}

Expected<void> Span::read_sampling_delegation_response(
const DictReader& reader) {
if (!expecting_delegated_sampling_decision_) return {};

expecting_delegated_sampling_decision_ = false;
return trace_segment_->read_sampling_delegation_response(reader);
trace_segment_->inject(writer, *data_, options);
}

std::uint64_t Span::id() const { return data_->span_id; }
Expand Down
Loading