Struct ProtoTraceScope
A lightweight fluent descriptor for a traced operation. Create one with Operation(IProtoTraceWriter, string, string, string), refine it with During(ProtoTracePhase), Parent(string?) and With(string, string?), then either run traced work through RunAsync(Func<ValueTask>) or open a handle with Begin().
public readonly struct ProtoTraceScope
- Inherited Members
- Extension Methods
Methods
Begin()
Opens the operation so the caller manages its outcome. The returned handle is tied to the ambient trace and must be completed within the current operation scope.
public ProtoTraceOperation Begin()
Returns
During(ProtoTracePhase)
Sets the lifecycle phase requested for the operation.
public ProtoTraceScope During(ProtoTracePhase phase)
Parameters
phaseProtoTracePhase
Returns
For(string, string)
Ties the operation to an entity (a client, context, resource, server or capability), so the viewer can place it on that entity's timeline.
public ProtoTraceScope For(string entityKind, string entityId)
Parameters
Returns
Parent(string?)
Sets an explicit parent operation id instead of the ambient parent.
public ProtoTraceScope Parent(string? parentId)
Parameters
parentIdstring
Returns
RunAsync(Func<ProtoTraceOperation, ValueTask>)
Runs action as a traced operation, passing the live operation handle.
public ValueTask RunAsync(Func<ProtoTraceOperation, ValueTask> action)
Parameters
actionFunc<ProtoTraceOperation, ValueTask>
Returns
RunAsync(Func<ValueTask>)
Runs action as a traced operation, deriving its outcome.
public ValueTask RunAsync(Func<ValueTask> action)
Parameters
Returns
RunAsync<TResult>(Func<ProtoTraceOperation, ValueTask<TResult>>)
Runs action as a traced operation, passing the live handle and returning its result.
public ValueTask<TResult> RunAsync<TResult>(Func<ProtoTraceOperation, ValueTask<TResult>> action)
Parameters
actionFunc<ProtoTraceOperation, ValueTask<TResult>>
Returns
- ValueTask<TResult>
Type Parameters
TResult
RunAsync<TResult>(Func<ValueTask<TResult>>)
Runs action as a traced operation, returning its result on success.
public ValueTask<TResult> RunAsync<TResult>(Func<ValueTask<TResult>> action)
Parameters
Returns
- ValueTask<TResult>
Type Parameters
TResult
With(IReadOnlyDictionary<string, string?>?)
Adds a set of attributes to the operation. A null or empty set is ignored.
public ProtoTraceScope With(IReadOnlyDictionary<string, string?>? attributes)
Parameters
attributesIReadOnlyDictionary<string, string>
Returns
With(string, string?)
Adds a single attribute to the operation.
public ProtoTraceScope With(string name, string? value)