Skip to content

Commit

Permalink
Merge branch 'main' into alanwest/exp-histogram-export
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwest authored Mar 27, 2023
2 parents 5f69b7b + 27560f6 commit 73d572b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
[Base2 Exponential Bucket Histogram Aggregation](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#base2-exponential-bucket-histogram-aggregation).
([#4337](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4337))

* Added support to set `TraceState` when converting the
System.Diagnostics.Activity object to its corresponding
OpenTelemetry.Proto.Trace.V1.Span object.
([#4331](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4331))

## 1.5.0-alpha.1

Released 2023-Mar-07
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ internal static Span ToOtlpSpan(this Activity activity, SdkLimitOptions sdkLimit
TraceId = UnsafeByteOperations.UnsafeWrap(traceIdBytes),
SpanId = UnsafeByteOperations.UnsafeWrap(spanIdBytes),
ParentSpanId = parentSpanIdString,
TraceState = activity.TraceStateString ?? string.Empty,

StartTimeUnixNano = (ulong)startTimeUnixNano,
EndTimeUnixNano = (ulong)(startTimeUnixNano + activity.Duration.ToNanoseconds()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.Equal(string.Empty, otlpSpan.TraceState);
}
}

[Fact]
public void ToOtlpSpanPeerServiceTest()
{
Expand Down

0 comments on commit 73d572b

Please sign in to comment.