diff --git a/ext/include/opentelemetry/ext/zpages/tracez_processor.h b/ext/include/opentelemetry/ext/zpages/tracez_processor.h index 3291a573cc..d0c8692a8c 100644 --- a/ext/include/opentelemetry/ext/zpages/tracez_processor.h +++ b/ext/include/opentelemetry/ext/zpages/tracez_processor.h @@ -48,7 +48,8 @@ class TracezSpanProcessor : public opentelemetry::sdk::trace::SpanProcessor * running_spans. * @param span a recordable for a span that was just started */ - void OnStart(opentelemetry::sdk::trace::Recordable &span) noexcept override; + void OnStart(opentelemetry::sdk::trace::Recordable &span, + const opentelemetry::trace::SpanContext &parent_context) noexcept override; /* * OnEnd is called when a span ends; that span_data is moved from running_spans to diff --git a/ext/src/zpages/tracez_processor.cc b/ext/src/zpages/tracez_processor.cc index 779f6fd061..1f88884a5f 100644 --- a/ext/src/zpages/tracez_processor.cc +++ b/ext/src/zpages/tracez_processor.cc @@ -6,7 +6,8 @@ namespace ext namespace zpages { -void TracezSpanProcessor::OnStart(opentelemetry::sdk::trace::Recordable &span) noexcept +void TracezSpanProcessor::OnStart(opentelemetry::sdk::trace::Recordable &span, + const opentelemetry::trace::SpanContext &parent_context) noexcept { std::lock_guard lock(mtx_); spans_.running.insert(static_cast(&span)); diff --git a/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h b/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h index e266427bfb..50788b4d65 100644 --- a/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h +++ b/sdk/include/opentelemetry/sdk/trace/batch_span_processor.h @@ -66,8 +66,10 @@ class BatchSpanProcessor : public SpanProcessor * NOTE: This method is a no-op. * * @param span - The span that just started + * @param parent_context - The parent context of the span that just started */ - void OnStart(Recordable &span) noexcept override; + void OnStart(Recordable &span, + const opentelemetry::trace::SpanContext &parent_context) noexcept override; /** * Called when a span ends. diff --git a/sdk/include/opentelemetry/sdk/trace/processor.h b/sdk/include/opentelemetry/sdk/trace/processor.h index f1ef6ca6d0..e46cc6ac9c 100644 --- a/sdk/include/opentelemetry/sdk/trace/processor.h +++ b/sdk/include/opentelemetry/sdk/trace/processor.h @@ -32,8 +32,10 @@ class SpanProcessor /** * OnStart is called when a span is started. * @param span a recordable for a span that was just started + * @param parent_context The parent context of the span that just started */ - virtual void OnStart(Recordable &span) noexcept = 0; + virtual void OnStart(Recordable &span, + const opentelemetry::trace::SpanContext &parent_context) noexcept = 0; /** * OnEnd is called when a span is ended. diff --git a/sdk/include/opentelemetry/sdk/trace/simple_processor.h b/sdk/include/opentelemetry/sdk/trace/simple_processor.h index 739c541866..92612ae800 100644 --- a/sdk/include/opentelemetry/sdk/trace/simple_processor.h +++ b/sdk/include/opentelemetry/sdk/trace/simple_processor.h @@ -37,7 +37,9 @@ class SimpleSpanProcessor : public SpanProcessor return exporter_->MakeRecordable(); } - void OnStart(Recordable &span) noexcept override {} + void OnStart(Recordable &span, + const opentelemetry::trace::SpanContext &parent_context) noexcept override + {} void OnEnd(std::unique_ptr &&span) noexcept override { diff --git a/sdk/src/trace/batch_span_processor.cc b/sdk/src/trace/batch_span_processor.cc index 8e654b6824..40e82360a4 100644 --- a/sdk/src/trace/batch_span_processor.cc +++ b/sdk/src/trace/batch_span_processor.cc @@ -4,6 +4,7 @@ using opentelemetry::sdk::common::AtomicUniquePtr; using opentelemetry::sdk::common::CircularBuffer; using opentelemetry::sdk::common::CircularBufferRange; +using opentelemetry::trace::SpanContext; OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk @@ -25,7 +26,7 @@ std::unique_ptr BatchSpanProcessor::MakeRecordable() noexcept return exporter_->MakeRecordable(); } -void BatchSpanProcessor::OnStart(Recordable &) noexcept +void BatchSpanProcessor::OnStart(Recordable &, const SpanContext &) noexcept { // no-op } diff --git a/sdk/src/trace/span.cc b/sdk/src/trace/span.cc index 1edf6d14fa..bcadef775d 100644 --- a/sdk/src/trace/span.cc +++ b/sdk/src/trace/span.cc @@ -110,7 +110,7 @@ Span::Span(std::shared_ptr &&tracer, recordable_->SetStartTime(NowOr(options.start_system_time)); start_steady_time = NowOr(options.start_steady_time); // recordable_->SetResource(resource_); TODO - processor_->OnStart(*recordable_); + processor_->OnStart(*recordable_, parent_span_context); } Span::~Span() diff --git a/sdk/test/trace/simple_processor_test.cc b/sdk/test/trace/simple_processor_test.cc index cdf544e79c..0e86ac2471 100644 --- a/sdk/test/trace/simple_processor_test.cc +++ b/sdk/test/trace/simple_processor_test.cc @@ -9,6 +9,7 @@ using namespace opentelemetry::sdk::trace; using opentelemetry::exporter::memory::InMemorySpanData; using opentelemetry::exporter::memory::InMemorySpanExporter; +using opentelemetry::trace::SpanContext; TEST(SimpleProcessor, ToInMemorySpanExporter) { @@ -18,7 +19,7 @@ TEST(SimpleProcessor, ToInMemorySpanExporter) auto recordable = processor.MakeRecordable(); - processor.OnStart(*recordable); + processor.OnStart(*recordable, SpanContext::GetInvalid()); ASSERT_EQ(0, span_data->GetSpans().size());