microsoft.opentelemetry.a365.core package
- class microsoft.opentelemetry.a365.core.OpenTelemetryScope(operation_name, activity_name, agent_details=None, span_details=None)[source]
Bases:
objectBase class for OpenTelemetry tracing scopes in the SDK.
- record_attributes(attributes)[source]
Record multiple attribute key/value pairs for telemetry tracking.
This method allows setting multiple custom attributes on the span at once.
- set_end_time(end_time)[source]
Set a custom end time for the scope.
When set, dispose() will pass this value to span.end() instead of using the current wall-clock time. This is useful when the actual end time of the operation is known before the scope is disposed.
- get_context()[source]
Get the OpenTelemetry context for this scope’s span.
This method returns a Context object containing this scope’s span, which can be used to propagate trace context to child operations or downstream services.
- class microsoft.opentelemetry.a365.core.ExecuteToolScope(request, details, agent_details, user_details=None, span_details=None)[source]
Bases:
OpenTelemetryScopeProvides OpenTelemetry tracing scope for AI tool execution operations.
- static start(request, details, agent_details, user_details=None, span_details=None)[source]
Creates and starts a new scope for tool execution tracing.
- Parameters:
request (
Request) – Request details for the tool executiondetails (
ToolCallDetails) – The details of the tool callagent_details (
AgentDetails) – The details of the agent making the calluser_details (
UserDetails|None) – Optional human user detailsspan_details (
SpanDetails|None) – Optional span configuration (parent context, timing, kind)
- Return type:
- Returns:
A new ExecuteToolScope instance
- class microsoft.opentelemetry.a365.core.InvokeAgentScope(request, scope_details, agent_details, caller_details=None, span_details=None)[source]
Bases:
OpenTelemetryScopeProvides OpenTelemetry tracing scope for AI agent invocation operations.
- static start(request, scope_details, agent_details, caller_details=None, span_details=None)[source]
Create and start a new scope for agent invocation tracing.
- Parameters:
request (
Request) – Request details for the invocationscope_details (
InvokeAgentScopeDetails) – Scope-level configuration (endpoint)agent_details (
AgentDetails) – The details of the agent being invokedcaller_details (
CallerDetails|None) – Optional composite caller details (human user and/or calling agent for A2A scenarios)span_details (
SpanDetails|None) – Optional span configuration (parent context, timing, kind)
- Return type:
- Returns:
A new InvokeAgentScope instance
- record_input_messages(messages)[source]
Record the input messages for telemetry tracking.
Accepts plain strings (auto-wrapped as OTEL ChatMessage with role
user) or a versionedInputMessageswrapper.- Parameters:
messages (
Union[str,list[str],InputMessages]) – List of input message strings or an InputMessages wrapper- Return type:
- record_output_messages(messages)[source]
Record the output messages for telemetry tracking.
Accepts plain strings (auto-wrapped as OTEL OutputMessage with role
assistant) or a versionedOutputMessageswrapper.- Parameters:
messages (
Union[str,list[str],OutputMessages]) – List of output message strings or an OutputMessages wrapper- Return type:
- class microsoft.opentelemetry.a365.core.InferenceScope(request, details, agent_details, user_details=None, span_details=None)[source]
Bases:
OpenTelemetryScopeProvides OpenTelemetry tracing scope for generative AI inference operations.
- static start(request, details, agent_details, user_details=None, span_details=None)[source]
Creates and starts a new scope for inference tracing.
- Parameters:
request (
Request) – Request details for the inferencedetails (
InferenceCallDetails) – The details of the inference callagent_details (
AgentDetails) – The details of the agent making the calluser_details (
UserDetails|None) – Optional human user detailsspan_details (
SpanDetails|None) – Optional span configuration (parent context, timing)
- Return type:
- Returns:
A new InferenceScope instance
- record_input_messages(messages)[source]
Records the input messages for telemetry tracking.
Accepts plain strings (auto-wrapped as OTEL ChatMessage with role
user) or a versionedInputMessageswrapper.- Parameters:
messages (
Union[str,list[str],InputMessages]) – List of input message strings or an InputMessages wrapper- Return type:
- record_output_messages(messages)[source]
Records the output messages for telemetry tracking.
Accepts plain strings (auto-wrapped as OTEL OutputMessage with role
assistant) or a versionedOutputMessageswrapper.- Parameters:
messages (
Union[str,list[str],OutputMessages]) – List of output message strings or an OutputMessages wrapper- Return type:
- record_input_tokens(input_tokens)[source]
Records the number of input tokens for telemetry tracking.
- record_output_tokens(output_tokens)[source]
Records the number of output tokens for telemetry tracking.
- class microsoft.opentelemetry.a365.core.OutputScope(request, response, agent_details, user_details=None, span_details=None)[source]
Bases:
OpenTelemetryScopeProvides 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 toOutputScope.- 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 outputresponse (
Response) – The response details from the agentagent_details (
AgentDetails) – The details of the agentuser_details (
UserDetails|None) – Optional human user detailsspan_details (
SpanDetails|None) – Optional span configuration (parent context, timing)
- Return type:
- 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
OutputMessageswrapper, or adict[str, object]for tool call results (per OTEL spec).
- class microsoft.opentelemetry.a365.core.BaggageBuilder[source]
Bases:
objectPer request baggage builder.
This class provides a fluent API for setting baggage values that will be propagated in the OpenTelemetry context.
Example
builder = (BaggageBuilder() .tenant_id("tenant-123") .agent_id("agent-456")) with builder.build(): # Baggage is set in this context pass # Baggage is restored after exiting the context
- operation_source(value)[source]
Set the operation source baggage value.
This captures the name of the service using the SDK.
- tenant_id(value)[source]
Set the tenant ID baggage value.
- Parameters:
- Return type:
- Returns:
Self for method chaining
- agent_id(value)[source]
Set the agent ID baggage value.
- Parameters:
- Return type:
- Returns:
Self for method chaining
- agentic_user_id(value)[source]
Set the agentic user ID baggage value.
- Parameters:
- Return type:
- Returns:
Self for method chaining
- agentic_user_email(value)[source]
Set the agentic user email baggage value.
- Parameters:
- Return type:
- Returns:
Self for method chaining
- agent_blueprint_id(value)[source]
Set the agent blueprint ID baggage value.
- Parameters:
- Return type:
- Returns:
Self for method chaining
- user_id(value)[source]
Set the user ID baggage value.
- Parameters:
- Return type:
- Returns:
Self for method chaining
- invoke_agent_server(address, port=None)[source]
Set the invoke agent server address and port baggage values.
- Parameters:
- Return type:
- Returns:
Self for method chaining
- channel_name(value)[source]
Sets the channel name baggage value (e.g., ‘Teams’, ‘msteams’).
- Return type:
- class microsoft.opentelemetry.a365.core.InvokeAgentScopeDetails(endpoint=None)[source]
Bases:
objectScope-level configuration for agent invocation tracing.
- endpoint: ServiceEndpoint | None = None
- class microsoft.opentelemetry.a365.core.AgentDetails(agent_id, agent_name=None, agent_description=None, agentic_user_id=None, agentic_user_email=None, agent_blueprint_id=None, agent_platform_id=None, tenant_id=None, icon_uri=None, provider_name=None, agent_version=None)[source]
Bases:
objectDetails about an AI agent in the system.
- class microsoft.opentelemetry.a365.core.CallerDetails(user_details=None, caller_agent_details=None)[source]
Bases:
objectComposite caller details for agent-to-agent (A2A) scenarios.
Groups the human caller identity and the calling agent identity together.
- user_details: UserDetails | None = None
Details about the human user in the call chain.
- caller_agent_details: AgentDetails | None = None
Details about the calling agent in A2A scenarios.
- class microsoft.opentelemetry.a365.core.UserDetails(user_id=None, user_email=None, user_name=None, user_client_ip=None)[source]
Bases:
objectDetails about the human user that invoked an agent.
- class microsoft.opentelemetry.a365.core.ToolCallDetails(tool_name, arguments=None, tool_call_id=None, description=None, tool_type=None, endpoint=None)[source]
Bases:
objectDetails of a tool call made by an agent in the system.
- endpoint: ServiceEndpoint | None = None
- class microsoft.opentelemetry.a365.core.Channel(name=None, link=None)[source]
Bases:
objectChannel information for agent execution context.
- class microsoft.opentelemetry.a365.core.Request(content=None, session_id=None, channel=None, conversation_id=None)[source]
Bases:
objectRequest details for agent execution.
- class microsoft.opentelemetry.a365.core.Response(messages)[source]
Bases:
objectResponse details from agent execution.
Accepts plain strings (backward compat), structured
OutputMessages, or adictfor tool call results (per OTEL spec).
- class microsoft.opentelemetry.a365.core.SpanDetails(span_kind=None, parent_context=None, start_time=None, end_time=None, span_links=None)[source]
Bases:
objectGroups span configuration for scope construction.
- class microsoft.opentelemetry.a365.core.InferenceCallDetails(operationName, model, providerName, inputTokens=None, outputTokens=None, finishReasons=None, thoughtProcess=None, endpoint=None)[source]
Bases:
objectDetails of an inference call for generative AI operations.
- operationName: InferenceOperationType
- endpoint: ServiceEndpoint | None = None
- class microsoft.opentelemetry.a365.core.ServiceEndpoint(hostname, port=None)[source]
Bases:
objectRepresents a service endpoint with hostname and optional port.
- class microsoft.opentelemetry.a365.core.InferenceOperationType(value)[source]
Bases:
EnumSupported inference operation types for generative AI.
- CHAT = 'Chat'
- TEXT_COMPLETION = 'TextCompletion'
- GENERATE_CONTENT = 'GenerateContent'
- class microsoft.opentelemetry.a365.core.ToolType(value)[source]
Bases:
EnumEnumeration for different tool types for execute tool contexts.
- FUNCTION = 'function'
- EXTENSION = 'extension'
- DATASTORE = 'datastore'
- class microsoft.opentelemetry.a365.core.MessageRole(value)[source]
Bases:
EnumRole of a message participant per OTEL gen-ai semantic conventions.
- SYSTEM = 'system'
- USER = 'user'
- ASSISTANT = 'assistant'
- TOOL = 'tool'
- class microsoft.opentelemetry.a365.core.FinishReason(value)[source]
Bases:
EnumReason a model stopped generating per OTEL gen-ai semantic conventions.
- STOP = 'stop'
- LENGTH = 'length'
- CONTENT_FILTER = 'content_filter'
- TOOL_CALL = 'tool_call'
- ERROR = 'error'
- class microsoft.opentelemetry.a365.core.Modality(value)[source]
Bases:
EnumMedia modality for blob, file, and URI parts.
- IMAGE = 'image'
- VIDEO = 'video'
- AUDIO = 'audio'
- class microsoft.opentelemetry.a365.core.TextPart(content)[source]
Bases:
objectPlain text content.
- class microsoft.opentelemetry.a365.core.ToolCallRequestPart(name, id=None, arguments=None)[source]
Bases:
objectA tool call requested by the model.
- class microsoft.opentelemetry.a365.core.ToolCallResponsePart(id=None, response=None)[source]
Bases:
objectResult of a tool call.
- class microsoft.opentelemetry.a365.core.ReasoningPart(content)[source]
Bases:
objectModel reasoning / chain-of-thought content.
- class microsoft.opentelemetry.a365.core.BlobPart(modality, content, mime_type=None)[source]
Bases:
objectInline binary data (base64-encoded).
- class microsoft.opentelemetry.a365.core.FilePart(modality, file_id, mime_type=None)[source]
Bases:
objectReference to a pre-uploaded file.
- class microsoft.opentelemetry.a365.core.UriPart(modality, uri, mime_type=None)[source]
Bases:
objectExternal URI reference.
- class microsoft.opentelemetry.a365.core.ServerToolCallPart(name, server_tool_call, id=None)[source]
Bases:
objectServer-side tool invocation.
- class microsoft.opentelemetry.a365.core.ServerToolCallResponsePart(server_tool_call_response, id=None)[source]
Bases:
objectServer-side tool response.
- class microsoft.opentelemetry.a365.core.GenericPart(type, data=<factory>)[source]
Bases:
objectExtensible part for custom / future types.
- class microsoft.opentelemetry.a365.core.ChatMessage(role, parts=<factory>, name=None)[source]
Bases:
objectAn input message sent to a model (OTEL gen-ai semantic conventions).
- role: MessageRole
- parts: list[TextPart | ToolCallRequestPart | ToolCallResponsePart | ReasoningPart | BlobPart | FilePart | UriPart | ServerToolCallPart | ServerToolCallResponsePart | GenericPart]
- class microsoft.opentelemetry.a365.core.OutputMessage(role, parts=<factory>, name=None, finish_reason=None)[source]
Bases:
ChatMessageAn output message produced by a model (OTEL gen-ai semantic conventions).
- class microsoft.opentelemetry.a365.core.InputMessages(messages=<factory>)[source]
Bases:
objectVersioned wrapper for input messages.
- messages: list[ChatMessage]
- class microsoft.opentelemetry.a365.core.OutputMessages(messages=<factory>)[source]
Bases:
objectVersioned wrapper for output messages.
- messages: list[OutputMessage]
Subpackages
- microsoft.opentelemetry.a365.core.exporters package
- Submodules
- microsoft.opentelemetry.a365.core.exporters.agent365_exporter module
- microsoft.opentelemetry.a365.core.exporters.agent365_exporter_options module
- microsoft.opentelemetry.a365.core.exporters.enriched_span module
- microsoft.opentelemetry.a365.core.exporters.enriching_span_processor module
- microsoft.opentelemetry.a365.core.exporters.span_processor module
- microsoft.opentelemetry.a365.core.exporters.spectra_exporter_options module
- microsoft.opentelemetry.a365.core.exporters.utils module
hex_trace_id()hex_span_id()kind_name()status_name()truncate_span()filter_and_partition_by_identity()get_validated_domain_override()build_export_url()parse_retry_after()is_agent365_exporter_enabled()estimate_value_bytes()estimate_span_bytes()chunk_by_size()A365Handlersis_a365_enabled()create_a365_components()
- Submodules
- microsoft.opentelemetry.a365.core.middleware package
BaggageBuilderBaggageBuilder.operation_source()BaggageBuilder.tenant_id()BaggageBuilder.agent_id()BaggageBuilder.agentic_user_id()BaggageBuilder.agentic_user_email()BaggageBuilder.agent_blueprint_id()BaggageBuilder.user_id()BaggageBuilder.agent_name()BaggageBuilder.agent_description()BaggageBuilder.agent_version()BaggageBuilder.user_name()BaggageBuilder.user_email()BaggageBuilder.user_client_ip()BaggageBuilder.invoke_agent_server()BaggageBuilder.conversation_id()BaggageBuilder.conversation_item_link()BaggageBuilder.session_id()BaggageBuilder.session_description()BaggageBuilder.channel_name()BaggageBuilder.channel_links()BaggageBuilder.set_pairs()BaggageBuilder.build()
- Submodules
- microsoft.opentelemetry.a365.core.models package
- Submodules
- microsoft.opentelemetry.a365.core.models.caller_details module
- microsoft.opentelemetry.a365.core.models.messages module
MessageRoleFinishReasonModalityTextPartToolCallRequestPartToolCallResponsePartReasoningPartBlobPartFilePartUriPartServerToolCallPartServerToolCallResponsePartGenericPartMessagePartChatMessageOutputMessageA365_MESSAGE_SCHEMA_VERSIONInputMessagesOutputMessagesInputMessagesParamOutputMessagesParam
- microsoft.opentelemetry.a365.core.models.response module
- microsoft.opentelemetry.a365.core.models.service_endpoint module
- microsoft.opentelemetry.a365.core.models.user_details module
- Submodules
- microsoft.opentelemetry.a365.core.spans_scopes package
Submodules
- microsoft.opentelemetry.a365.core.agent_details module
- microsoft.opentelemetry.a365.core.channel module
- microsoft.opentelemetry.a365.core.constants module
- microsoft.opentelemetry.a365.core.execute_tool_scope module
- microsoft.opentelemetry.a365.core.inference_call_details module
- microsoft.opentelemetry.a365.core.inference_operation_type module
- microsoft.opentelemetry.a365.core.inference_scope module
- microsoft.opentelemetry.a365.core.invoke_agent_details module
- microsoft.opentelemetry.a365.core.invoke_agent_scope module
- microsoft.opentelemetry.a365.core.message_utils module
- microsoft.opentelemetry.a365.core.opentelemetry_scope module
OpenTelemetryScopeOpenTelemetryScope.record_error()OpenTelemetryScope.record_response()OpenTelemetryScope.record_cancellation()OpenTelemetryScope.set_tag_maybe()OpenTelemetryScope.record_attributes()OpenTelemetryScope.set_end_time()OpenTelemetryScope.get_context()OpenTelemetryScope.inject_context_to_headers()OpenTelemetryScope.dispose()
- microsoft.opentelemetry.a365.core.request module
- microsoft.opentelemetry.a365.core.span_details module
- microsoft.opentelemetry.a365.core.tool_call_details module
- microsoft.opentelemetry.a365.core.tool_type module
- microsoft.opentelemetry.a365.core.utils module