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

Generate W3C-compatible operation id if there is no request-id header #722

Merged
merged 1 commit into from
Jul 23, 2018

Conversation

lmolkova
Copy link
Member

See microsoft/ApplicationInsights-dotnet-server#952:

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.

This change should be merged after DependencyCollector beta4 is onboarded (and copy-paste code is removed)

/// https://github.com/w3c/distributed-tracing/blob/master/trace_context/HTTP_HEADER_FORMAT.md#trace-id
/// </summary>
/// <returns>Random 16 bytes array encoded as hex string</returns>
internal static string GenerateTraceId()
Copy link
Member Author

@lmolkova lmolkova Jul 23, 2018

Choose a reason for hiding this comment

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

I've tried to remove this guy and use one from Web SDK StringUtilities. Did not work out: https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/956, so we'll have to live with copy-paste for a while...

@lmolkova lmolkova force-pushed the lmolkova/GenerateW3cTraceId branch from 4c0bb62 to 4975794 Compare July 23, 2018 21:26
@lmolkova lmolkova changed the title [DO NOT MERGE] Generate W3C-compatible operation id if there is no request-id header Generate W3C-compatible operation id if there is no request-id header Jul 23, 2018
@lmolkova lmolkova merged commit 720b009 into develop Jul 23, 2018
@lmolkova lmolkova deleted the lmolkova/GenerateW3cTraceId branch January 3, 2019 03:07
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.

2 participants