Class AgentExtensions
Provides extension methods for the Agent class.
- Inheritance
-
Agent
Extensions
- 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
agent
AgentactivityName
stringmetadata
MapField <string, CloudEvent .Types.CloudEvent >Attribute Value
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
agent
AgentThe agent from which to extract the activity.
activityName
stringThe name of the activity.
metadata
IDictionary<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
agent
AgentThe agent invoking the function.
func
Func<TState, CancellationToken , Task>The function to invoke.
state
TStateThe state parameter to pass to the function.
activity
ActivityThe activity within which to invoke the function.
methodName
stringThe name of the method being invoked.
cancellationToken
CancellationToken A token to monitor for cancellation requests.
Returns
- Task
A task representing the asynchronous operation.
Type Parameters
TState
The type of the state parameter.