Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test for StartRootSpan #2878

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions test/OpenTelemetry.Tests/Trace/TracerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
// </copyright>

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using Xunit;

namespace OpenTelemetry.Trace.Tests
Expand Down Expand Up @@ -74,6 +76,35 @@ public void Tracer_StartRootSpan_BadArgs_NullSpanName()
Assert.Null(span3.Activity.DisplayName);
}

[Fact(Skip = "See https://github.com/open-telemetry/opentelemetry-dotnet/issues/2803")]
public async Task Tracer_StartRootSpan_StartsNewTrace()
{
var exportedItems = new List<Activity>();

using var tracer = Sdk.CreateTracerProviderBuilder()
.AddSource("tracername")
.AddInMemoryExporter(exportedItems)
.Build();

async Task DoSomeAsyncWork()
{
await Task.Delay(10);
var newRootSpan = TracerProvider.Default.GetTracer("tracername").StartRootSpan("RootSpan2");
using (Tracer.WithSpan(newRootSpan))
alanwest marked this conversation as resolved.
Show resolved Hide resolved
{
await Task.Delay(10);
}
}

using (tracer.GetTracer("tracername").StartActiveSpan("RootSpan1"))
{
await DoSomeAsyncWork();
}

Assert.Equal(2, exportedItems.Count);
Assert.NotEqual(exportedItems[0].TraceId, exportedItems[1].TraceId);
alanwest marked this conversation as resolved.
Show resolved Hide resolved
}

[Fact]
public void Tracer_StartSpan_BadArgs_NullSpanName()
{
Expand Down