in sdk/src/Core/Internal/Entities/TraceHeader.cs [156:196]
public static TraceHeader FromString(string rawHeader)
{
TraceHeader result = new TraceHeader();
try
{
if (string.IsNullOrEmpty(rawHeader))
{
return result;
}
Dictionary<string, string> keyValuePairs = rawHeader.Split(_validSeparators, StringSplitOptions.RemoveEmptyEntries)
.Select(value => value.Trim().Split('='))
.ToDictionary(pair => pair[0], pair => pair[1]);
if (keyValuePairs.TryGetValue(RootKey, out string tmpValue) && TraceId.IsIdValid(tmpValue))
{
result.RootTraceId = tmpValue;
}
if (keyValuePairs.TryGetValue(ParentKey, out tmpValue) && Entity.IsIdValid(tmpValue))
{
result.ParentId = tmpValue;
}
if (keyValuePairs.TryGetValue(SampledKey, out tmpValue) && char.TryParse(tmpValue, out char tmpChar))
{
if (Enum.IsDefined(typeof(SampleDecision), (int)tmpChar))
{
result.Sampled = (SampleDecision)tmpChar;
}
}
return result;
}
catch (IndexOutOfRangeException e)
{
_logger.Error(e, "Invalid trace header from string: {0}", rawHeader);
return result;
}
}