Compartilhar via


OutputScope Class

Definition

Provides OpenTelemetry tracing scope for AI agent output operations.

public sealed class OutputScope : Microsoft.Agents.A365.Observability.Runtime.Tracing.Scopes.OpenTelemetryScope
type OutputScope = class
    inherit OpenTelemetryScope
Public NotInheritable Class OutputScope
Inherits OpenTelemetryScope
Inheritance

Remarks

Output messages are set once (via the constructor or RecordOutputMessages(IEnumerable<String>)) rather than accumulated. For streaming scenarios, the agent developer should collect all output and pass the final result to OutputScope.

Fields

Name Description
OperationName

The operation name for output tracing.

Properties

Name Description
Id

Gets the span ID for the current activity.

(Inherited from OpenTelemetryScope)
TraceId

Gets the trace ID for the current activity.

(Inherited from OpenTelemetryScope)

Methods

Name Description
AddBaggage(String, String)

Adds baggage to the current activity for distributed tracing context propagation.

(Inherited from OpenTelemetryScope)
Dispose()

Disposes the scope and finalizes telemetry data collection.

(Inherited from OpenTelemetryScope)
GetActivityContext()

Gets the ActivityContext for this scope's span.

(Inherited from OpenTelemetryScope)
InjectTraceContext()

Injects this span's trace context into W3C HTTP headers.

(Inherited from OpenTelemetryScope)
RecordAttributes(IEnumerable<KeyValuePair<String,Object>>)

Records multiple attribute key/value pairs for telemetry tracking.

(Inherited from OpenTelemetryScope)
RecordCancellation()

Record the task cancellation event.

(Inherited from OpenTelemetryScope)
RecordError(Exception)

Log the error.

(Inherited from OpenTelemetryScope)
RecordOutputMessages(IDictionary<String,Object>)

Records a tool call result dictionary for telemetry tracking. Per OTEL spec, tool call results are expected to be objects and are serialized to JSON. Overwrites any previously set output messages.

RecordOutputMessages(IEnumerable<String>)

Records the output messages for telemetry tracking. Overwrites any previously set output messages. Plain strings are auto-wrapped as OTEL OutputMessage with role "assistant".

RecordOutputMessages(OutputMessages)

Records structured output messages for telemetry tracking. Overwrites any previously set output messages.

SetEndTime(DateTimeOffset)

Sets a custom end time for the scope. This allows for manual control of the scope duration.

(Inherited from OpenTelemetryScope)
SetStartTime(DateTimeOffset)

Sets a custom start time for the scope. This allows for manual control of the scope start time. Can be used in addition to or instead of setting start time via constructor.

(Inherited from OpenTelemetryScope)
SetTagMaybe(String, Object)

Set the tag on the activity if the tag is present.

(Inherited from OpenTelemetryScope)
Start(Request, Response, AgentDetails, UserDetails, SpanDetails)

Creates and starts a new scope for output tracing.

Applies to