Skip to content

Commit be57fe9

Browse files
authored
chore: deprecate sampling delegation (#192)
1 parent a57c01a commit be57fe9

File tree

18 files changed

+14
-980
lines changed

18 files changed

+14
-980
lines changed

doc/sampling-delegation.md

Lines changed: 0 additions & 189 deletions
This file was deleted.

examples/http-server/proxy/proxy.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ int main() {
7474
span.set_error_message(httplib::to_string(er));
7575
std::cerr << "Error occurred while proxying request: " << req.target
7676
<< "\n";
77-
} else {
78-
tracingutil::HeaderReader reader(res.headers);
79-
auto status = span.read_sampling_delegation_response(reader);
80-
if (auto error = status.if_error()) {
81-
std::cerr << error << "\n";
82-
}
8377
}
8478

8579
span.set_tag("http.status_code", std::to_string(res.status));

examples/http-server/server/server.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ int main() {
159159
// created. We finish it by popping it off of the span stack.
160160
server.set_post_routing_handler([](const httplib::Request& request, httplib::Response& response) {
161161
auto* context = static_cast<RequestTracingContext*>(request.user_data.get());
162-
163-
tracingutil::HeaderWriter writer(response.headers);
164-
context->spans.top().trace_segment().write_sampling_delegation_response(writer);
165-
166162
context->spans.pop();
167163
return httplib::Server::HandlerResponse::Unhandled;
168164
});

include/datadog/environment.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ namespace environment {
3434
MACRO(DD_SERVICE) \
3535
MACRO(DD_SPAN_SAMPLING_RULES) \
3636
MACRO(DD_SPAN_SAMPLING_RULES_FILE) \
37-
MACRO(DD_TRACE_DELEGATE_SAMPLING) \
3837
MACRO(DD_TRACE_PROPAGATION_STYLE_EXTRACT) \
3938
MACRO(DD_TRACE_PROPAGATION_STYLE_INJECT) \
4039
MACRO(DD_TRACE_PROPAGATION_STYLE) \

include/datadog/injection_options.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,10 @@
44
// parameters to `Span::inject` that alter the behavior of trace context
55
// propagation.
66

7-
#include "optional.h"
8-
97
namespace datadog {
108
namespace tracing {
119

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

2212
} // namespace tracing
2313
} // namespace datadog

include/datadog/span.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ class Span {
6666
std::function<std::uint64_t()> generate_span_id_;
6767
Clock clock_;
6868
Optional<std::chrono::steady_clock::time_point> end_time_;
69-
mutable bool expecting_delegated_sampling_decision_;
7069

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

172-
// If this span is expecting a sampling decision that it previously delegated,
173-
// then extract a sampling decision from the specified `reader`. Return an
174-
// error if a sampling decision is present in `reader` but is invalid. Return
175-
// success otherwise. The trace segment associated with this span might adopt
176-
// the sampling decision from `reader`.
177-
Expected<void> read_sampling_delegation_response(const DictReader& reader);
178-
179171
// Return a reference to this span's trace segment. The trace segment has
180172
// member functions that affect the trace as a whole, such as
181173
// `TraceSegment::override_sampling_priority`.

include/datadog/trace_segment.h

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,6 @@ class TraceSegment {
7979

8080
std::shared_ptr<ConfigManager> config_manager_;
8181

82-
// See `doc/sampling-delegation.md` for more information about
83-
// `struct SamplingDelegation`.
84-
struct SamplingDelegation {
85-
// This segment is configured to delegate its sampling decision.
86-
bool enabled;
87-
// The trace context from which the local root span was extracted delegated
88-
// the sampling decision to this segment.
89-
bool decision_was_delegated_to_me;
90-
// This segment included a request for sampling delegation in outbound
91-
// injected trace context (see `inject`).
92-
bool sent_request_header;
93-
// This segment received a (presumably delegated) sampling decision. See
94-
// `read_sampling_delegation_response`.
95-
bool received_matching_response_header;
96-
// This segment conveyed a sampling decision back to a parent service that
97-
// had previously requested a delegated sampling decision.
98-
bool sent_response_header;
99-
} sampling_delegation_ = {};
100-
10182
public:
10283
TraceSegment(const std::shared_ptr<Logger>& logger,
10384
const std::shared_ptr<Collector>& collector,
@@ -106,8 +87,7 @@ class TraceSegment {
10687
const std::shared_ptr<SpanSampler>& span_sampler,
10788
const std::shared_ptr<const SpanDefaults>& defaults,
10889
const std::shared_ptr<ConfigManager>& config_manager,
109-
const RuntimeID& runtime_id, bool sampling_delegation_enabled,
110-
bool sampling_decision_was_delegated_to_me,
90+
const RuntimeID& runtime_id,
11191
const std::vector<PropagationStyle>& injection_styles,
11292
const Optional<std::string>& hostname,
11393
Optional<std::string> origin, std::size_t tags_header_max_size,
@@ -131,14 +111,6 @@ class TraceSegment {
131111
bool inject(DictWriter& writer, const SpanData& span,
132112
const InjectionOptions& options);
133113

134-
// Inject this segment's trace sampling decision into the specified `writer`,
135-
// if appropriate.
136-
void write_sampling_delegation_response(DictWriter& writer);
137-
138-
// Extract a trace sampling decision from the specified `reader` if it has
139-
// one, and use the resulting decision, if appropriate.
140-
Expected<void> read_sampling_delegation_response(const DictReader& reader);
141-
142114
// Take ownership of the specified `span`.
143115
void register_span(std::unique_ptr<SpanData> span);
144116
// Increment the number of finished spans. If that number is equal to the

include/datadog/tracer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class Tracer {
4949
std::vector<PropagationStyle> extraction_styles_;
5050
Optional<std::string> hostname_;
5151
std::size_t tags_header_max_size_;
52-
bool sampling_delegation_enabled_;
5352
// Store the tracer configuration in an in-memory file, allowing it to be
5453
// read to determine if the process is instrumented with a tracer and to
5554
// retrieve relevant tracing information.

include/datadog/tracer_config.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ struct TracerConfig {
8080
// `telemetry/configuration.h` By default, the telemetry module is enabled.
8181
telemetry::Configuration telemetry;
8282

83-
// `delegate_trace_sampling` indicates whether the tracer will consult a child
84-
// service for a trace sampling decision, and prefer the resulting decision
85-
// over its own, if appropriate.
86-
Optional<bool> delegate_trace_sampling;
87-
8883
// `trace_sampler` configures trace sampling. Trace sampling determines which
8984
// traces are sent to Datadog. See `trace_sampler_config.h`.
9085
TraceSamplerConfig trace_sampler;
@@ -199,7 +194,6 @@ class FinalizedTracerConfig final {
199194
Clock clock;
200195
std::string integration_name;
201196
std::string integration_version;
202-
bool delegate_trace_sampling;
203197
bool report_traces;
204198
std::unordered_map<ConfigName, ConfigMetadata> metadata;
205199
Baggage::Options baggage_opts;

src/datadog/extracted_data.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ struct ExtractedData {
2020
Optional<std::uint64_t> parent_id;
2121
Optional<std::string> origin;
2222
std::vector<std::pair<std::string, std::string>> trace_tags;
23-
bool delegate_sampling_decision = false;
2423
Optional<int> sampling_priority;
2524
// If this `ExtractedData` was created on account of `PropagationStyle::W3C`,
2625
// then `datadog_w3c_parent_id` contains the parts of the "tracestate"

0 commit comments

Comments
 (0)