diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index cd157f34d5..f0e3ac5e58 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -837,9 +837,12 @@ class Span : public trace::Span */ void SetAttribute(nostd::string_view key, const common::AttributeValue &value) noexcept override { - // TODO: not implemented - UNREFERENCED_PARAMETER(key); - UNREFERENCED_PARAMETER(value); + // don't override fields propagated from span data. + if (key == ETW_FIELD_NAME || key == ETW_FIELD_SPAN_ID || key == ETW_FIELD_TRACE_ID) + { + return; + } + attributes_[std::string{key}].FromAttributeValue(value); } /** diff --git a/exporters/etw/test/etw_tracer_test.cc b/exporters/etw/test/etw_tracer_test.cc index 400099bbe7..1c9c1f09be 100644 --- a/exporters/etw/test/etw_tracer_test.cc +++ b/exporters/etw/test/etw_tracer_test.cc @@ -69,6 +69,9 @@ TEST(ETWTracer, TracerCheck) auto innerSpan = tracer->StartSpan("MySpanL3", attribs); auto innerScope = tracer->WithActiveSpan(innerSpan); + // Add span attribute + EXPECT_NO_THROW(outerSpan->SetAttribute("AttrName1", "AttrValue1")); + // Add first event std::string eventName1 = "MyEvent1"; Properties event1 =