Skip to content

Commit

Permalink
Revert "move extract headers to its own method, this is broken"
Browse files Browse the repository at this point in the history
This reverts commit 1484a48.
  • Loading branch information
mabdinur committed Jan 3, 2025
1 parent 1484a48 commit 786889f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
7 changes: 0 additions & 7 deletions include/datadog/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "id_generator.h"
#include "optional.h"
#include "span.h"
#include "extraction_util.h"
#include "tracer_config.h"
#include "tracer_signature.h"

Expand Down Expand Up @@ -62,9 +61,6 @@ class Tracer {
Span create_span();
Span create_span(const SpanConfig& config);

// ...
Expected<ExtractedData> extract_headers(const DictReader& reader, std::unique_ptr<SpanData> span_data);

// Return a span whose parent and other context is parsed from the specified
// `reader`, and whose attributes are determined by the optionally specified
// `config`. If there is no tracing information in `reader`, then return an
Expand All @@ -73,9 +69,6 @@ class Tracer {
Expected<Span> extract_span(const DictReader& reader);
Expected<Span> extract_span(const DictReader& reader,
const SpanConfig& config);
Expected<Span> extract_span(ExtractedData& merged_context,
const SpanConfig& config,
std::unique_ptr<SpanData> span_data);

// Return a span extracted from the specified `reader` (see `extract_span`).
// If there is no span to extract, then return a span that is the root of a
Expand Down
31 changes: 10 additions & 21 deletions src/datadog/tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "config_manager.h"
#include "datadog_agent.h"
#include "extracted_data.h"
#include "extraction_util.h"
#include "hex.h"
#include "json.hpp"
#include "platform_util.h"
Expand Down Expand Up @@ -142,9 +143,17 @@ Span Tracer::create_span(const SpanConfig& config) {
return span;
}

Expected<ExtractedData> Tracer::extract_headers(const DictReader& reader, std::unique_ptr<SpanData> span_data) {
Expected<Span> Tracer::extract_span(const DictReader& reader) {
return extract_span(reader, SpanConfig{});
}

Expected<Span> Tracer::extract_span(const DictReader& reader,
const SpanConfig& config) {
assert(!extraction_styles_.empty());

AuditedReader audited_reader{reader};

auto span_data = std::make_unique<SpanData>();
Optional<PropagationStyle> first_style_with_trace_id;
Optional<PropagationStyle> first_style_with_parent_id;
std::unordered_map<PropagationStyle, ExtractedData> extracted_contexts;
Expand Down Expand Up @@ -263,26 +272,6 @@ Expected<ExtractedData> Tracer::extract_headers(const DictReader& reader, std::u
merged_context.headers_examined));
}

return std::move(merged_context);
}

Expected<Span> Tracer::extract_span(const DictReader& reader) {
return extract_span(reader, SpanConfig{});
}

Expected<Span> Tracer::extract_span(const DictReader& reader,
const SpanConfig& config) {
auto span_data = std::make_unique<SpanData>();
auto merged_context = extract_headers(reader, std::move(span_data));
if (auto* error = merged_context.if_error()) {
return *error;
}
return extract_span(*merged_context, config, std::move(span_data));
}

Expected<Span> Tracer::extract_span(ExtractedData& merged_context,
const SpanConfig& config,
std::unique_ptr<SpanData> span_data) {
// We're done extracting fields. Now create the span.
// This is similar to what we do in `create_span`.
span_data->apply_config(*config_manager_->span_defaults(), config, clock_);
Expand Down

0 comments on commit 786889f

Please sign in to comment.