From c9835660f92278e819db56dbea82ab29b8d0653f Mon Sep 17 00:00:00 2001 From: Yun-Ting Date: Fri, 24 Mar 2023 12:05:29 -0700 Subject: [PATCH] test --- .../OtlpTraceExporterTests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs index a3003baf8a7..0dda7611a59 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpTraceExporterTests.cs @@ -551,6 +551,32 @@ public void ToOtlpSpanActivityStatusTakesPrecedenceOverStatusTagsWhenActivitySta Assert.Equal(StatusDescriptionOnError, otlpSpan.Status.Message); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public void ToOtlpSpanTraceStateTest(bool traceStateWasSet) + { + using var activitySource = new ActivitySource(nameof(this.ToOtlpSpanTest)); + using var activity = activitySource.StartActivity("Name"); + string tracestate = "a=b;c=d"; + if (traceStateWasSet) + { + activity.TraceStateString = tracestate; + } + + var otlpSpan = activity.ToOtlpSpan(DefaultSdkLimitOptions); + + if (traceStateWasSet) + { + Assert.NotNull(otlpSpan.TraceState); + Assert.Equal(tracestate, otlpSpan.TraceState); + } + else + { + Assert.True(string.IsNullOrEmpty(otlpSpan.TraceState)); + } + } + [Fact] public void ToOtlpSpanPeerServiceTest() {