microsoft.opentelemetry.a365.core.spans_scopes.output_scope module

class microsoft.opentelemetry.a365.core.spans_scopes.output_scope.OutputScope(request, response, agent_details, user_details=None, span_details=None)[source]

Bases: OpenTelemetryScope

Provides OpenTelemetry tracing scope for output messages.

Output messages are set once (via the constructor or record_output_messages) rather than accumulated. For streaming scenarios, the agent developer should collect all output (e.g. via a list or string builder) and pass the final result to OutputScope.

static start(request, response, agent_details, user_details=None, span_details=None)[source]

Creates and starts a new scope for output tracing.

Parameters:
  • request (Request) – Request details for the output

  • response (Response) – The response details from the agent

  • agent_details (AgentDetails) – The details of the agent

  • user_details (UserDetails | None) – Optional human user details

  • span_details (SpanDetails | None) – Optional span configuration (parent context, timing)

Return type:

OutputScope

Returns:

A new OutputScope instance

record_output_messages(messages)[source]

Records the output messages for telemetry tracking.

Overwrites any previously set output messages. Accepts a single string, a list of strings (auto-wrapped as OTEL OutputMessage), a versioned OutputMessages wrapper, or a dict[str, object] for tool call results (per OTEL spec).

Parameters:

messages (Union[str, list[str], OutputMessages, dict[str, object]]) – String(s), OutputMessages, or dict for tool call results

Return type:

None