@@ -199,15 +199,16 @@ Expected<ExtractedData> extract_b3(
199199
200200nlohmann::json make_config_json (
201201 StringView tracer_version_string, const Collector& collector,
202- const SpanDefaults& defaults, const TraceSampler& trace_sampler ,
203- const SpanSampler& span_sampler,
202+ const SpanDefaults& defaults, const RuntimeID& runtime_id ,
203+ const TraceSampler& trace_sampler, const SpanSampler& span_sampler,
204204 const std::vector<PropagationStyle>& injection_styles,
205205 const std::vector<PropagationStyle>& extraction_styles,
206206 const Optional<std::string>& hostname, std::size_t tags_header_max_size) {
207207 // clang-format off
208208 auto config = nlohmann::json::object ({
209209 {" version" , tracer_version_string},
210210 {" defaults" , to_json (defaults)},
211+ {" runtime_id" , runtime_id.string ()},
211212 {" collector" , collector.config_json ()},
212213 {" trace_sampler" , trace_sampler.config_json ()},
213214 {" span_sampler" , span_sampler.config_json ()},
@@ -244,8 +245,10 @@ Tracer::Tracer(const FinalizedTracerConfig& config,
244245 : logger_(config.logger),
245246 collector_ (/* see constructor body */ ),
246247 defaults_(std::make_shared<SpanDefaults>(config.defaults)),
248+ runtime_id_(config.runtime_id ? *config.runtime_id
249+ : RuntimeID::generate()),
247250 tracer_telemetry_(std::make_shared<TracerTelemetry>(
248- config.report_telemetry, clock, logger_, defaults_)),
251+ config.report_telemetry, clock, logger_, defaults_, runtime_id_ )),
249252 trace_sampler_(
250253 std::make_shared<TraceSampler>(config.trace_sampler, clock)),
251254 span_sampler_(std::make_shared<SpanSampler>(config.span_sampler, clock)),
@@ -278,8 +281,9 @@ Tracer::Tracer(const FinalizedTracerConfig& config,
278281
279282nlohmann::json Tracer::config_json () const {
280283 return make_config_json (tracer_version_string, *collector_, *defaults_,
281- *trace_sampler_, *span_sampler_, injection_styles_,
282- extraction_styles_, hostname_, tags_header_max_size_);
284+ runtime_id_, *trace_sampler_, *span_sampler_,
285+ injection_styles_, extraction_styles_, hostname_,
286+ tags_header_max_size_);
283287}
284288
285289Span Tracer::create_span () { return create_span (SpanConfig{}); }
@@ -300,8 +304,8 @@ Span Tracer::create_span(const SpanConfig& config) {
300304 tracer_telemetry_->metrics ().tracer .trace_segments_created_new .inc ();
301305 const auto segment = std::make_shared<TraceSegment>(
302306 logger_, collector_, tracer_telemetry_, trace_sampler_, span_sampler_,
303- defaults_, injection_styles_, hostname_, nullopt /* origin */ ,
304- tags_header_max_size_, std::move (trace_tags),
307+ defaults_, runtime_id_, injection_styles_, hostname_ ,
308+ nullopt /* origin */ , tags_header_max_size_, std::move (trace_tags),
305309 nullopt /* sampling_decision */ , nullopt /* additional_w3c_tracestate */ ,
306310 nullopt /* additional_datadog_w3c_tracestate*/ , std::move (span_data));
307311 Span span{span_data_ptr, segment,
@@ -464,7 +468,7 @@ Expected<Span> Tracer::extract_span(const DictReader& reader,
464468 tracer_telemetry_->metrics ().tracer .trace_segments_created_continued .inc ();
465469 const auto segment = std::make_shared<TraceSegment>(
466470 logger_, collector_, tracer_telemetry_, trace_sampler_, span_sampler_,
467- defaults_, injection_styles_, hostname_, std::move (origin),
471+ defaults_, runtime_id_, injection_styles_, hostname_, std::move (origin),
468472 tags_header_max_size_, std::move (trace_tags),
469473 std::move (sampling_decision), std::move (additional_w3c_tracestate),
470474 std::move (additional_datadog_w3c_tracestate), std::move (span_data));
0 commit comments