<PackageReference Include="System.ClientModel" Version="1.15.0" />

System.ClientModel.Primitives.DiagnosticScope

A lightweight wrapper around Activity that provides a consistent pattern for creating, starting, and completing diagnostic scopes in client libraries.
public bool IsEnabled { get; }

Gets a value indicating whether this scope is enabled and will record tracing data.

public void AddAttribute(string name, string value)

Adds a tag to the underlying activity.

public void AddAttribute<T>(string name, T value, Func<T, string> format)

Adds a typed tag to the underlying activity using a custom formatter.

public void AddIntegerAttribute(string name, int value)

Adds an integer tag to the underlying activity.

public void AddLink(string traceparent, string tracestate, IDictionary<string, object> attributes = null)

Adds a distributed tracing link to the scope. Must be called before Start.

public void AddLongAttribute(string name, long value)

Adds a long tag to the underlying activity.

public void Dispose()

Disposes the scope and stops the underlying activity.

public void Failed(Exception exception)

Marks the scope as failed with the specified exception.

public void Failed(string errorCode)

Marks the scope as failed with a low-cardinality error code.

public void SetDisplayName(string displayName)

Sets the display name of the underlying activity.

public void SetStartTime(DateTime dateTime)

Sets the start time of the underlying activity.

public void SetTraceContext(string traceparent, string tracestate = null)

Sets the W3C trace context for this scope. Must be called before Start.

public void Start()

Starts the scope by starting the underlying Activity. Must be called after adding any links, trace context, or pre-start attributes.