Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

Dependency Parent IDs not set correctly in 2.8.0 #1277

Closed
aarondandy opened this issue Sep 26, 2019 · 10 comments
Closed

Dependency Parent IDs not set correctly in 2.8.0 #1277

aarondandy opened this issue Sep 26, 2019 · 10 comments
Assignees
Labels
Milestone

Comments

@aarondandy
Copy link

Dependency Parent IDs not set correctly in 2.8.0. Reverting from 2.8.0 back to 2.7.1 is a workaround for me.

Repro Steps

  1. Upgrade from 2.7.1 to 2.8.0 in either 2.2 project or a 3.0 project
  2. Run application, sending telemetry to AI

Actual Behavior

A request with a Request Id of |af71200102f65e46b9c58cd203474526.f0f605963ec9474d. will have a dependency (SQL for example) with a Parent Id of 00-af71200102f65e46b9c58cd203474526-f0f605963ec9474d-00

Expected Behavior

The Parent Id matches the Request Id of the parent.

Version Info

SDK Version (version of https://www.nuget.org/packages/Microsoft.ApplicationInsights.AspNetCore) : 2.8.0
.NET Core Version (TargetFramework in your .csproj file) : 3.0 or 2.2
How Application was onboarded with SDK(Installed Nugets/VisualStudio/Azure WebAppExtension) : nuget
OS : Windows
Hosting Info (IIS/Azure Web Apps/Running From Visual Studio etc) : Yes.

@cijothomas
Copy link
Contributor

Can you share a repro app for us to investigate?

@aarondandy
Copy link
Author

aarondandy commented Sep 27, 2019

Sure, here is how I put together a minimum reproduction:

  1. Create a new aspnetcore webapp of some kind (2.2 or 3.0)
  2. Add a reference to Microsoft.ApplicationInsights.AspNetCore 2.8.0
  3. Set your AI key in the APPINSIGHTS_INSTRUMENTATIONKEY environment variable
  4. Do something that would be tracked as a dependency:
using var conn = new SqlConnection(connectionString);
var junk = await conn.QueryAsync("SELECT * FROM Pewp"); // Dapper, ADO.NET, EF core, doesn't matter

It seems like this does not affect all dependency types. I notice it with SQL and ServiceBus but HTTP seems OK. With 2.8.0 the parent ID values will contain the 00- prefix and suffix while on 2.7.1 it will match the Parent's ID with whatever the other format is. I see this issue in Azure as well as within Visual Studio.

@cijothomas
Copy link
Contributor

@mqtwinter
Copy link

I just noticed this issue yesterday when looking at the github code and was left scratching my head.

What's in master right now:

telemetry.Context.Operation.ParentId = activity.ParentId;

What's in develop right now:

telemetry.Context.Operation.ParentId = activity.Id;

It looks like at some point someone found and fixed this bug.

(Sorry I'm not git/github expert, so maybe this was obvious to everyone else. I also don't know how to find exactly when/where this was fixed.)

@aarondandy
Copy link
Author

Just to be clear, this is a problem on netcore 2.2 as well which is where I first noticed it.

@cijothomas
Copy link
Contributor

@aarondandy Yes the issue is arising from using new System.Diagnostics.DiagnosticSource, and switching to new W3C Format in Activity.
(https://docs.microsoft.com/en-us/azure/azure-monitor/app/correlation#enable-w3c-distributed-tracing-support-for-aspnet-core-apps)

You can try the workaround by running the following snippet in your startup.cs configureservices.

Activity.DefaultIdFormat = ActivityIdFormat.Hierarchical;
  Activity.ForceDefaultIdFormat = true;

@cijothomas
Copy link
Contributor

Tagging as bug.
@lmolkova What are your thoughts on making a fix for this as a .1 hotfix release?

@TimothyMothra TimothyMothra transferred this issue from microsoft/ApplicationInsights-aspnetcore Sep 30, 2019
@TimothyMothra TimothyMothra added this to the 2.11.1 milestone Sep 30, 2019
@cijothomas
Copy link
Contributor

This will be fixed and released as a ".1" release.

@aarondandy
Copy link
Author

Microsoft.ApplicationInsights.AspNetCore 2.8.1 seems to fix this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants