This is a bug in versions 2.8.0+ (checked 2.8.0 and 2.8.1). It does not happen in 2.7.2 (also checked 2.5.1).
Repro Steps
Create a console application with code like this:
public class Sql
{
public static void Run()
{
var connString = @"Data Source=(LocalDb)\MSSQLLocalDB; Initial Catalog=master; Integrated Security=SSPI";
for (var i = 0; i < 5; ++i)
{
ExecSql(i, connString);
}
}
static void ExecSql(int i, string connectionString)
{
using (var conn = new SqlConnection(connectionString))
{
conn.Open();
conn.GetSchema("Tables");
}
Console.WriteLine($"Activity id after sql {i}: {Activity.Current?.Id}");
}
}
Full repro solution attached.
ConsoleApp1.zip
Actual Behavior
When using 2.8.0 the app prints:
Activity id after sql 0: |47da6e291f386f42b6fb519694553b3c.dc340c80_
Activity id after sql 1: |47da6e291f386f42b6fb519694553b3c.dc340c80_1.
Activity id after sql 2: |47da6e291f386f42b6fb519694553b3c.dc340c80_1.1.
Activity id after sql 3: |47da6e291f386f42b6fb519694553b3c.dc340c80_1.1.1.
Activity id after sql 4: |47da6e291f386f42b6fb519694553b3c.dc340c80_1.1.1.1.
Note that activity remains present after running a sql dependency and, due to this, the next operation (here another sql dependency) becomes its child. It continues for subsequent operations.
Expected Behavior
When using 2.7.2 the app prints:
Activity id after sql 0:
Activity id after sql 1:
Activity id after sql 2:
Activity id after sql 3:
Activity id after sql 4:
This is the expected output, i.e. there's no activity left over after running a sql dependency.
Version Info
SDK Version : 2.8.0, also 2.8.1
.NET Version : net framework 4.6.1, also 4.7.1
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : Visual Studio
OS : Windows 10
Hosting Info (IIS/Azure WebApps/ etc) : console app / Windows service
This is a bug in versions 2.8.0+ (checked 2.8.0 and 2.8.1). It does not happen in 2.7.2 (also checked 2.5.1).
Repro Steps
Create a console application with code like this:
Full repro solution attached.
ConsoleApp1.zip
Actual Behavior
When using 2.8.0 the app prints:
Note that activity remains present after running a sql dependency and, due to this, the next operation (here another sql dependency) becomes its child. It continues for subsequent operations.
Expected Behavior
When using 2.7.2 the app prints:
This is the expected output, i.e. there's no activity left over after running a sql dependency.
Version Info
SDK Version : 2.8.0, also 2.8.1
.NET Version : net framework 4.6.1, also 4.7.1
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : Visual Studio
OS : Windows 10
Hosting Info (IIS/Azure WebApps/ etc) : console app / Windows service