@@ -33,27 +33,48 @@ internal DistributedTracingData(string traceId, string parentId, bool flagRecord
33
33
internal TraceState TraceState { get ; }
34
34
35
35
/// <summary>
36
- /// Serializes this instance to a string.
37
- /// This method should be used at the caller side and the return value should be passed to the (possibly remote) callee
38
- /// side.
39
- /// <see cref="TryDeserializeFromString " /> should be used to deserialize the instance at the callee side.
36
+ /// Serializes this instance to a traceparent string.
37
+ /// This method should be used at the caller side in pairs with <see cref="SerializeTraceStateToString" />,
38
+ /// and the return value should be passed to the (possibly remote) callee side.
39
+ /// <see cref="Create " /> should be used to deserialize the instance at the callee side.
40
40
/// </summary>
41
41
/// <returns>
42
- /// String containing the instance in serialized form.
42
+ /// String containing the traceparent data in serialized form.
43
43
/// </returns>
44
44
public string SerializeToString ( ) => TraceContext . BuildTraceparent ( this ) ;
45
45
46
+ /// <summary>
47
+ /// Serializes this instance to a tracestate string.
48
+ /// This method should be used at the caller side in pairs with <see cref="SerializeToString" />,
49
+ /// and the return value should be passed to the (possibly remote) callee side.
50
+ /// <see cref="Create" /> should be used to deserialize the instance at the callee side.
51
+ /// </summary>
52
+ /// <returns>The string representation of the tracestate header, or null if there is no tracestate.</returns>
53
+ public string SerializeTraceStateToString ( ) => TraceState ? . ToTextHeader ( ) ;
54
+
46
55
/// <summary>
47
56
/// Deserializes an instance from a string.
48
57
/// This method should be used at the callee side and the deserialized instance can be passed to
49
58
/// <see cref="ITracer.StartTransaction" />.
50
59
/// </summary>
51
60
/// <param name="serialized">should be a return value from a call to <see cref="SerializeToString" />.</param>
52
- /// <param name="traceStateValue">should be a return value from a call to <see cref="DistributedTracing.TraceState.ToTextHeader"/>.</param>
53
61
/// <returns>
54
62
/// Instance deserialized from <paramref name="serialized" />.
55
63
/// </returns>
56
- public static DistributedTracingData TryDeserializeFromString ( string serialized , string traceStateValue = null ) => TraceContext . TryExtractTracingData ( serialized , traceStateValue ) ;
64
+ public static DistributedTracingData TryDeserializeFromString ( string serialized ) => TraceContext . TryExtractTracingData ( serialized ) ;
65
+
66
+ /// <summary>
67
+ /// Creates an instance from a treceparent and tracestate strings.
68
+ /// This method should be used at the callee side, and the created instance can be passed to
69
+ /// <see cref="ITracer.StartTransaction" />.
70
+ /// </summary>
71
+ /// <param name="traceParent">should be a return value from a call to <see cref="SerializeToString" />.</param>
72
+ /// <param name="traceState">should be a return value from a call to <see cref="SerializeTraceStateToString"/>.</param>
73
+ /// <returns>
74
+ /// Instance deserialized from <paramref name="traceParent" /> and <paramref name="traceState" /> .
75
+ /// </returns>
76
+ public static DistributedTracingData Create ( string traceParent , string traceState ) =>
77
+ TraceContext . TryExtractTracingData ( traceParent , traceState ) ;
57
78
58
79
public override string ToString ( ) => new ToStringBuilder ( nameof ( DistributedTracingData ) )
59
80
{
0 commit comments