Bewerken

Delen via


DiagnosticSource.OnActivityExport(Activity, Object) Method

Definition

Transfers state from an activity to some event or operation, such as an outgoing HTTP request, that will occur outside the process.

public:
 virtual void OnActivityExport(System::Diagnostics::Activity ^ activity, System::Object ^ payload);
public virtual void OnActivityExport (System.Diagnostics.Activity activity, object? payload);
public virtual void OnActivityExport (System.Diagnostics.Activity activity, object payload);
abstract member OnActivityExport : System.Diagnostics.Activity * obj -> unit
override this.OnActivityExport : System.Diagnostics.Activity * obj -> unit
Public Overridable Sub OnActivityExport (activity As Activity, payload As Object)

Parameters

activity
Activity

The activity affected by an external event.

payload
Object

An object that represents the outgoing request.

Remarks

If an instrumentation site is at a location where activities leave the process (such as outgoing HTTP requests), that site will want to transfer state from the activity to the outgoing request.

To the extent possible, this should be done by the instrumentation site, because there is a contract between an Activity and the ougoing request logic at the instrumentation site. However, the instrumentation site can't handle policy (for example, whether activity information should be disabled or written in an older format for compatibility reasons). For this, the instrumentation site needs to call back out to the logging system and ask it to resolve policy. This is the purpose of the OnActivityExport method.

The OnActivityExport method is given the Activity as well as a payload object that represents the outgoing request. A DiagnosticSource subscriber then has the ability to update the outgoing request before it is sent.

Note that this method is rarely used at instrumentation sites (only those sites that are on an outgoing boundary of the process). Moreover, typically the default policy that the instrumentation site performs (for example, to transfer all activity state in a particular outgoing convention) is likely to be fine. This method is only for cases where that is a problem. Thus, this method should be used very rarely and is mostly here for symetry with OnActivityImport and future-proofing.

Note that payload is typed as an Object here, but any particular instrumentation site and subscriber should know the type of the payload and thus cast and decode it if necessary.

Applies to