|
16 | 16 | #include "config_manager.h" |
17 | 17 | #include "datadog_agent.h" |
18 | 18 | #include "extracted_data.h" |
| 19 | +#include "extraction_util.h" |
19 | 20 | #include "hex.h" |
20 | 21 | #include "json.hpp" |
21 | 22 | #include "platform_util.h" |
@@ -142,9 +143,17 @@ Span Tracer::create_span(const SpanConfig& config) { |
142 | 143 | return span; |
143 | 144 | } |
144 | 145 |
|
145 | | -Expected<ExtractedData> Tracer::extract_headers(const DictReader& reader, std::unique_ptr<SpanData> span_data) { |
| 146 | +Expected<Span> Tracer::extract_span(const DictReader& reader) { |
| 147 | + return extract_span(reader, SpanConfig{}); |
| 148 | +} |
| 149 | + |
| 150 | +Expected<Span> Tracer::extract_span(const DictReader& reader, |
| 151 | + const SpanConfig& config) { |
146 | 152 | assert(!extraction_styles_.empty()); |
| 153 | + |
147 | 154 | AuditedReader audited_reader{reader}; |
| 155 | + |
| 156 | + auto span_data = std::make_unique<SpanData>(); |
148 | 157 | Optional<PropagationStyle> first_style_with_trace_id; |
149 | 158 | Optional<PropagationStyle> first_style_with_parent_id; |
150 | 159 | std::unordered_map<PropagationStyle, ExtractedData> extracted_contexts; |
@@ -263,26 +272,6 @@ Expected<ExtractedData> Tracer::extract_headers(const DictReader& reader, std::u |
263 | 272 | merged_context.headers_examined)); |
264 | 273 | } |
265 | 274 |
|
266 | | - return std::move(merged_context); |
267 | | -} |
268 | | - |
269 | | -Expected<Span> Tracer::extract_span(const DictReader& reader) { |
270 | | - return extract_span(reader, SpanConfig{}); |
271 | | -} |
272 | | - |
273 | | -Expected<Span> Tracer::extract_span(const DictReader& reader, |
274 | | - const SpanConfig& config) { |
275 | | - auto span_data = std::make_unique<SpanData>(); |
276 | | - auto merged_context = extract_headers(reader, std::move(span_data)); |
277 | | - if (auto* error = merged_context.if_error()) { |
278 | | - return *error; |
279 | | - } |
280 | | - return extract_span(*merged_context, config, std::move(span_data)); |
281 | | -} |
282 | | - |
283 | | -Expected<Span> Tracer::extract_span(ExtractedData& merged_context, |
284 | | - const SpanConfig& config, |
285 | | - std::unique_ptr<SpanData> span_data) { |
286 | 275 | // We're done extracting fields. Now create the span. |
287 | 276 | // This is similar to what we do in `create_span`. |
288 | 277 | span_data->apply_config(*config_manager_->span_defaults(), config, clock_); |
|
0 commit comments