-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Propagators Support #55419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propagators Support #55419
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,15 +9,16 @@ | |
| namespace System.Diagnostics | ||
| { | ||
| /// <summary> | ||
| /// Propagator defines the restrictions imposed by a specific transport and is bound to a data type, in order to propagate in-band context data across process boundaries. | ||
| /// An implementation of TextMapPropagator determines if and how distributed context information is encoded and decoded as it traverses the network. | ||
| /// The encoding can be transported over any network protocol that supports string key-value pairs. For example when using HTTP, each key value pair is an HTTP header. | ||
| /// TextMapPropagator inject values into and extracts values from carriers as string key/value pairs. | ||
| /// </summary> | ||
| public abstract class TextMapPropagator | ||
| { | ||
| private static TextMapPropagator s_current = CreateDefaultPropagator(); | ||
|
|
||
| /// <summary> | ||
| /// Define the callback that can be used with the propagators extract methods. This callback will be invoked for each propagation key to get. | ||
| /// The callback that is used in propagators' extract methods. The callback is invoked to lookup the value of a named field. | ||
| /// </summary> | ||
| /// <param name="carrier">Carrier is the medium used by Propagators to read values from.</param> | ||
| /// <param name="fieldName">The propagation field name.</param> | ||
|
|
@@ -26,43 +27,43 @@ public abstract class TextMapPropagator | |
| public delegate void PropagatorGetterCallback(object? carrier, string fieldName, out string? fieldValue, out IEnumerable<string>? fieldValues); | ||
|
|
||
| /// <summary> | ||
| /// Define the callback that can be used with the propagators inject methods. This callback will be invoked to set a propagation key/value pair. | ||
| /// Propagators may invoke it multiple times in order to set multiple pairs. | ||
| /// The callback that is used in propagators' inject methods. This callback is invoked to set the value of a named field. | ||
| /// Propagators may invoke it multiple times in order to set multiple fields. | ||
| /// </summary> | ||
| /// <param name="carrier">Carrier is the medium used by Propagators to write values to.</param> | ||
| /// <param name="fieldName">The propagation field name.</param> | ||
| /// <param name="fieldValue">The value corresponds to the input fieldName. </param> | ||
| public delegate void PropagatorSetterCallback(object? carrier, string fieldName, string fieldValue); | ||
|
|
||
| /// <summary> | ||
| /// The predefined propagation fields | ||
| /// The set of field names this propagator is likely to read or write. | ||
| /// </summary> | ||
| /// <returns>Returns list of fields that will be used by the TextMapPropagator.</returns> | ||
| public abstract IReadOnlyCollection<string> Fields { get; } | ||
|
|
||
| /// <summary> | ||
| /// Injects the trace values stroed in the <see cref="Activity"/> object into a carrier. For example, into the headers of an HTTP request. | ||
| /// </summary> | ||
| /// <param name="activity">The Activity object has the trace context to inject to the carrier.</param> | ||
| /// <param name="carrier">Carrier is the medium used by the propagators to write values to.</param> | ||
| /// <param name="setter">The callback will be invoked to set a propagation key/value pair to the carrier.</param> | ||
| /// <param name="activity">The Activity object has the distributed context to inject to the carrier.</param> | ||
| /// <param name="carrier">Carrier is the medium in which the distributed context will be stored.</param> | ||
| /// <param name="setter">The callback will be invoked to set a named key/value pair on the carrier.</param> | ||
| public abstract void Inject(Activity? activity, object? carrier, PropagatorSetterCallback? setter); | ||
|
|
||
| /// <summary> | ||
| /// Extracts the value from an incoming request represented by the carrier. For example, from the headers of an HTTP request. | ||
| /// Extracts trace Id and trace state from an incoming request represented by the carrier. For example, from the headers of an HTTP request. | ||
| /// </summary> | ||
| /// <param name="carrier">Carrier is the medium used by the propagators to read values from.</param> | ||
| /// <param name="carrier">Carrier is the medium from which values will be read.</param> | ||
| /// <param name="getter">The callback will be invoked to get the propagation trace Id and trace state from carrier.</param> | ||
| /// <param name="traceId">The extracted trace Id from the carrier.</param> | ||
| /// <param name="traceState">The extracted trace state from the carrier.</param> | ||
| public abstract void ExtractTraceIdAndState(object? carrier, PropagatorGetterCallback? getter, out string? traceId, out string? traceState); | ||
|
|
||
| /// <summary> | ||
| /// Extracts the baggage key-value pairs list from an incoming request represented by the carrier. For example, from the headers of an HTTP request. | ||
| /// Extracts the baggage key-value pair list from an incoming request represented by the carrier. For example, from the headers of an HTTP request. | ||
| /// </summary> | ||
| /// <param name="carrier">Carrier is the medium used by the propagators to read values from.</param> | ||
| /// <param name="carrier">Carrier is the medium from which values will be read.</param> | ||
| /// <param name="getter">The callback will be invoked to get the propagation baggage list from carrier.</param> | ||
| /// <returns>Returns the extracted key-value pair list from teh carrier.</returns> | ||
| /// <returns>Returns the extracted key-value pair list from the carrier.</returns> | ||
| public abstract IEnumerable<KeyValuePair<string, string?>>? ExtractBaggage(object? carrier, PropagatorGetterCallback? getter); | ||
|
|
||
| /// <summary> | ||
|
|
@@ -85,15 +86,21 @@ public static TextMapPropagator Current | |
| /// <summary> | ||
| /// returns the default propagator object which Current property will be initialized with. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// CreateDefaultPropagator will create a propagator instance that can inject and extract the headers with field names "tarcestate", | ||
| /// "traceparent" of the identifiers which are formatted as W3C trace parent, "Request-Id" of the identifiers which are formatted as a hierarchical identifier. | ||
| /// The returned propagator can inject the baggage key-value pair list with header name "Correlation-Context" and it can extract the baggage values mapped to header names "Correlation-Context" and "baggage". | ||
| /// </remarks> | ||
| public static TextMapPropagator CreateDefaultPropagator() => LegacyPropagator.Instance; | ||
|
|
||
| /// <summary> | ||
| /// returns the propagator which can propagate the trace context data using the root Activity and ignore any created child activities. | ||
| /// Returns a propagator which attempts to act transparently, emitting the same data on outbound network requests that was received on the in-bound request. | ||
| /// When encoding the outbound message, this propagator uses information from the request's root Activity, ignoring any intermediate Activities that may have been created while processing the request. | ||
| /// </summary> | ||
| public static TextMapPropagator CreatePassThroughPropagator() => PassThroughPropagator.Instance; | ||
|
|
||
| /// <summary> | ||
| /// returns the propagator which suppress injecting any data to teh carriers. | ||
| /// Returns a propagator which does not transmit any distributed context information in outbound network messages. | ||
| /// </summary> | ||
| public static TextMapPropagator CreateNoOutputPropagator() => NoOutputPropagator.Instance; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is "Output" the right naming to use? Would it be better to keep with the naming used elsewhere in the API, e.g. "NoInjection" or something like that?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was discussed before. Actually, it was originally proposed with the The reason was the terms Inject and Extract are coming from the specs and the APIs has names including these terms will be used in the low-level libraries (e.g. Http Client and asp.net). It is not expected many people call such APIs. While the APIs like |
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.