public static SpanContext FromString(string from) { if (from == string.Empty) { throw new Exception("Cannot convert empty string to SpanContext"); } var parts = from.Split(':'); if (parts.Length != 4) { throw new Exception("String does not match tracer state format"); } return(new SpanContext(TraceId.FromString(parts[0]), SpanId.FromString(parts[1]), SpanId.FromString(parts[2]), null, (ContextFlags)byte.Parse(parts[3]))); }
public static SpanContext ContextFromString(string value) { if (string.IsNullOrEmpty(value)) { throw new ArgumentException($"Cannot convert empty string to {nameof(SpanContext)}"); } var parts = value.Split(':'); if (parts.Length != 4) { throw new ArgumentException("String does not match tracer state format"); } return(new SpanContext( TraceId.FromString(parts[0]), SpanId.FromString(parts[1]), SpanId.FromString(parts[2]), (SpanContextFlags)byte.Parse(parts[3], NumberStyles.HexNumber))); }