Class AgentExtensions
Provides extension methods for the Agent class.
public static class AgentExtensions
- Inheritance
-
AgentExtensions
- Inherited Members
Methods
ExtractActivity(Agent, string, MapField<string, CloudEventAttributeValue>)
public static Activity? ExtractActivity(this Agent agent, string activityName, MapField<string, CloudEvent.Types.CloudEventAttributeValue> metadata)
Parameters
agentAgentactivityNamestringmetadataMapField<string, CloudEvent.Types.CloudEventAttributeValue>
Returns
ExtractActivity(Agent, string, IDictionary<string, string>)
Extracts an Activity from the given agent and metadata.
public static Activity? ExtractActivity(this Agent agent, string activityName, IDictionary<string, string> metadata)
Parameters
agentAgentThe agent from which to extract the activity.
activityNamestringThe name of the activity.
metadataIDictionary<string, string>The metadata containing trace information.
Returns
InvokeWithActivityAsync<TState>(Agent, Func<TState, CancellationToken, Task>, TState, Activity?, string, CancellationToken)
Invokes a function asynchronously within the context of an Activity.
public static Task InvokeWithActivityAsync<TState>(this Agent agent, Func<TState, CancellationToken, Task> func, TState state, Activity? activity, string methodName, CancellationToken cancellationToken = default)
Parameters
agentAgentThe agent invoking the function.
funcFunc<TState, CancellationToken, Task>The function to invoke.
stateTStateThe state parameter to pass to the function.
activityActivityThe activity within which to invoke the function.
methodNamestringThe name of the method being invoked.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task
A task representing the asynchronous operation.
Type Parameters
TStateThe type of the state parameter.