reverse tracestate changes - base SDK has a bug

This commit is contained in:
Liudmila Molkova 2019-09-09 19:49:50 -07:00
Родитель d794387237
Коммит 3b7ee4d15d
5 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -47,5 +47,8 @@
public const char TracestateAzureSeparator = ';';
internal const string LegacyRootPropertyIdKey = "ai_legacyRootId";
// TODO[tracestate]: remove, this is done in base SDK
internal const string TracestatePropertyKey = "tracestate";
}
}

Просмотреть файл

@ -402,6 +402,12 @@ namespace Microsoft.ApplicationInsights.DependencyCollector.Implementation
}
}
// TODO[tracestate]: remove, this is done in base SDK
if (!string.IsNullOrEmpty(currentActivity.TraceStateString) && !telemetry.Properties.ContainsKey(W3CConstants.TracestatePropertyKey))
{
telemetry.Properties.Add(W3CConstants.TracestatePropertyKey, currentActivity.TraceStateString);
}
this.client.Initialize(telemetry);
// If we started auxiliary Activity before to override the Id with W3C compatible one,
@ -453,6 +459,13 @@ namespace Microsoft.ApplicationInsights.DependencyCollector.Implementation
var dependency = this.client.StartOperation<DependencyTelemetry>(resourceName);
// TODO[tracestate]: remove, this is done in base SDK
var tracestate = Activity.Current?.TraceStateString;
if (!string.IsNullOrEmpty(tracestate) && !dependency.Telemetry.Properties.ContainsKey(W3CConstants.TracestatePropertyKey))
{
dependency.Telemetry.Properties.Add(W3CConstants.TracestatePropertyKey, tracestate);
}
dependency.Telemetry.Target = DependencyTargetNameHelper.GetDependencyTargetName(requestUri);
dependency.Telemetry.Type = RemoteDependencyConstants.HTTP;
dependency.Telemetry.Data = requestUri.OriginalString;

Просмотреть файл

@ -59,6 +59,12 @@
}
telemetry.Id = W3CUtilities.FormatTelemetryId(context.Operation.Id, activity.SpanId.ToHexString());
// TODO[tracestate]: remove, this is done in base SDK
if (activity.TraceStateString != null && !telemetry.Properties.ContainsKey(W3CConstants.TracestatePropertyKey))
{
telemetry.Properties.Add(W3CConstants.TracestatePropertyKey, activity.TraceStateString);
}
}
else
{

Просмотреть файл

@ -63,6 +63,12 @@
}
telemetry.Id = W3CUtilities.FormatTelemetryId(traceId, activity.SpanId.ToHexString());
// TODO[tracestate]: remove, this is done in base SDK
if (!string.IsNullOrEmpty(activity.TraceStateString) && !telemetry.Properties.ContainsKey(W3CConstants.TracestatePropertyKey))
{
telemetry.Properties.Add(W3CConstants.TracestatePropertyKey, activity.TraceStateString);
}
}
else
{

Просмотреть файл

@ -90,6 +90,12 @@
}
}
// TODO[tracestate]: remove, this is done in base SDK
if (!string.IsNullOrEmpty(currentActivity.TraceStateString))
{
result.Properties[W3CConstants.TracestatePropertyKey] = currentActivity.TraceStateString;
}
result.Id = W3CUtilities.FormatTelemetryId(requestContext.Id, currentActivity.SpanId.ToHexString());
}
else