diff --git a/api/include/opentelemetry/trace/propagation/http_trace_context.h b/api/include/opentelemetry/trace/propagation/http_trace_context.h index 91905b794e..9440960be3 100644 --- a/api/include/opentelemetry/trace/propagation/http_trace_context.h +++ b/api/include/opentelemetry/trace/propagation/http_trace_context.h @@ -100,7 +100,11 @@ class HttpTraceContext : public opentelemetry::context::propagation::TextMapProp nostd::span{&trace_parent[kTraceIdSize + kSpanIdSize + 5], 2}); carrier.Set(kTraceParent, nostd::string_view(trace_parent, sizeof(trace_parent))); - carrier.Set(kTraceState, span_context.trace_state()->ToHeader()); + const auto trace_state = span_context.trace_state()->ToHeader(); + if (!trace_state.empty()) + { + carrier.Set(kTraceState, trace_state); + } } static SpanContext ExtractContextFromTraceHeaders(nostd::string_view trace_parent,