Struct ProtoTraceScope

Namespace
ProtoTest.Core
Assembly
ProtoTest.Core.dll

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

ProtoTraceOperation

During(ProtoTracePhase)

Sets the lifecycle phase requested for the operation.

public ProtoTraceScope During(ProtoTracePhase phase)

Parameters

phase ProtoTracePhase

Returns

ProtoTraceScope

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

entityKind string
entityId string

Returns

ProtoTraceScope

Parent(string?)

Sets an explicit parent operation id instead of the ambient parent.

public ProtoTraceScope Parent(string? parentId)

Parameters

parentId string

Returns

ProtoTraceScope

RunAsync(Func<ProtoTraceOperation, ValueTask>)

Runs action as a traced operation, passing the live operation handle.

public ValueTask RunAsync(Func<ProtoTraceOperation, ValueTask> action)

Parameters

action Func<ProtoTraceOperation, ValueTask>

Returns

ValueTask

RunAsync(Func<ValueTask>)

Runs action as a traced operation, deriving its outcome.

public ValueTask RunAsync(Func<ValueTask> action)

Parameters

action Func<ValueTask>

Returns

ValueTask

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

action Func<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

action Func<ValueTask<TResult>>

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

attributes IReadOnlyDictionary<string, string>

Returns

ProtoTraceScope

With(string, string?)

Adds a single attribute to the operation.

public ProtoTraceScope With(string name, string? value)

Parameters

name string
value string

Returns

ProtoTraceScope