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

Use W3C trace Id format for Activities that do not have parents#952

Merged
lmolkova merged 5 commits intodevelopfrom
lmolkova/GenerateW3cTraceId
Jul 18, 2018
Merged

Use W3C trace Id format for Activities that do not have parents#952
lmolkova merged 5 commits intodevelopfrom
lmolkova/GenerateW3cTraceId

Conversation

@lmolkova
Copy link
Copy Markdown

@lmolkova lmolkova commented Jul 18, 2018

We are going to gradually enable W3C support in ApplicaitonInsights.

While the details and backward compatibility conditions are still not clear, we want to make sure that customers have enough time to transition to W3C format and this change is the first step in this transition.

This change generates Activity RootId in the format of W3C traceId when there are no parents.

I.e. if the service has received Request-Id (or legacy) header from upstream, it will use it, no matter which format it follows.

However, if there were no such header in the incoming request, the new operation id will comply with W3C spec for traceId.

This is a temporary workaround that could be removed once W3C supported in .NET (Activity).

Sampling tests shows that distribution of sampling score for the new traceId generation algorithm is uniform.

Copy link
Copy Markdown
Contributor

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple comments left.

internal static class ClientServerDependencyTracker
{
private const string DependencyActivityName = "Microsoft.AppInsights.Web.Dependency";
private const string AuxiliaryActivityName = nameof(ClientServerDependencyTracker);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AuxiliaryActivityName - Where is this used?

if (currentActivity == null)
{
activity.SetParentId(telemetry.Id);
activity.SetParentId(StringUtilities.GenerateTraceId());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to stop this in EndTracking?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, it's stopped on line 81


internal static class ActivityExtensions
{
public static Activity UpdateParent(this Activity original, string newParentId)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unittest this method

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@cijothomas cijothomas closed this Jul 18, 2018
@cijothomas cijothomas reopened this Jul 18, 2018
@lmolkova
Copy link
Copy Markdown
Author

@MS-TimothyMothra could you please have a look?

@lmolkova lmolkova merged commit eaf8be4 into develop Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants