Skip to content

[dotnet-sdk-10.0.100-alpha.1.25067.41] opentelemetrydotnet failed due to System.Diagnostics.StartActivity().Recorded property returns false #111693

@Junjun-zhao

Description

@Junjun-zhao

Description

When run the 3rd party unitest against with dotnet-sdk-10.0.100-alpha.1.25067.41, there are 8 cases failed with error:
System.Collections.Generic.KeyNotFoundException : The given key '4630cad0-5365-4dd5-8ccb-496ffd04d672' was not present in the dictionary. After investigation, we found it is caused by System.Diagnostics.StartActivity().Recorded return false on dotnet-sdk-10.0.100-alpha.1.25067.41.

Reproduction Steps

Minimal Repro Steps: (Attached Demo:ConsoleDemo.zip):

  1. Create .net 9.0 console project.
  2. Add the following code to Program.cs.
using System.Diagnostics;
var listener = new ActivityListener
{
    ShouldListenTo = _ => true,
    Sample = (ref ActivityCreationOptions<ActivityContext> options) => ActivitySamplingResult.AllData,
};
ActivitySource.AddActivityListener(listener);
Activity activity = new ActivitySource("").StartActivity(ActivityKind.Client,
                new ActivityContext(new ActivityTraceId(), new ActivitySpanId(), ActivityTraceFlags.Recorded));
Console.WriteLine(activity.Recorded);
  1. Build the app.
  2. Change the runtimeconfig file to let the app run against with dotnet-sdk-10.0.100-alpha.1.25067.41:
"frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "10.0.0-alpha.1.25067.10"
      }
    ]
  1. Run the app.

Expected Result:
Return true.

Actual Result:
Return false.

App Repro Steps:

  1. Change the \App\opentelemetrydotnetTest01\OpenTelemetry.Exporter.Zipkin.Tests.runtimeconfig file to let the app run against with dotnet-sdk-10.0.100-alpha.1.25067.41:
"frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "10.0.0-alpha.1.25067.10"
      }
    ]
  1. Open cmd.
  2. Cd to "\App\opentelemetrydotnetTest01".
  3. Run command "dotnet vstest OpenTelemetry.Exporter.Zipkin.Tests.dll".

Expected behavior

All cases passed.

Actual behavior

There are 8 cases failed with error:

System.Collections.Generic.KeyNotFoundException : The given key '4630cad0-5365-4dd5-8ccb-496ffd04d672' was not present in the dictionary.
  Stack Trace:
     at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNotFoundException(TKey key)
   at System.Collections.Concurrent.ConcurrentDictionary`2.get_Item(TKey key)
   at OpenTelemetry.Exporter.Zipkin.Tests.ZipkinExporterTests.IntegrationTest(Boolean useShortTraceIds, Boolean useTestResource, Boolean isRootSpan, StatusCode statusCode, String statusDescription, Boolean addErrorTag) in D:\opentelemetry-dotnet\test\OpenTelemetry.Exporter.Zipkin.Tests\ZipkinExporterTests.cs:line 409
   at InvokeStub_ZipkinExporterTests.IntegrationTest(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithManyArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Regression?

Yes

Verify Scenarios:
1). Windows 10 22H2 AMD64 + dotnet-sdk-8.0.405: Pass
2). Windows 10 22H2 AMD64 + dotnet-sdk-9.0.102: Pass
3). Windows 10 22H2 AMD64 + dotnet-sdk-10.0.100-alpha.1.25067.41: Fail

Known Workarounds

No response

Configuration

Application Name: opentelemetrydotnet
OS: Windows 10 22H2
CPU: X64
.NET Build Number: dotnet-sdk-10.0.100-alpha.1.25067.41
App & Source Location checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2350449
Github Link: https://github.com/open-telemetry/opentelemetry-dotnet

Other information

@dotnet-actwx-bot @dotnet/compat

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions