OpenInference span processor for Microsoft Agent Framework - transforms native OpenTelemetry spans to OpenInference format
Project description
OpenInference Microsoft Agent Framework Instrumentation
OpenInference span processor for Microsoft Agent Framework that transforms native OpenTelemetry spans to OpenInference format for compatibility with OpenInference-compliant backends like Arize Phoenix.
Tested with Agent Framework core/OpenAI packages 1.0.0
Installation
pip install openinference-instrumentation-agent-framework
Install with Microsoft Agent Framework core and OpenAI support:
pip install openinference-instrumentation-agent-framework[instruments]
Overview
Microsoft Agent Framework emits telemetry using GenAI semantic conventions (gen_ai.* attributes). This package provides a SpanProcessor that transforms these spans to OpenInference format, enabling compatibility with observability tools that support the OpenInference standard.
Note: This instrumentation targets Agent Framework's stable 1.0.0+ API surface and tracks later stable releases in CI.
Usage
Basic Setup
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
from agent_framework.observability import enable_instrumentation
from openinference.instrumentation.agent_framework import (
AgentFrameworkToOpenInferenceProcessor
)
# Create tracer provider
tracer_provider = TracerProvider()
# Add OpenInference processor to transform spans
tracer_provider.add_span_processor(
AgentFrameworkToOpenInferenceProcessor()
)
# Add exporter (Console for demo, use OTLP for Phoenix)
tracer_provider.add_span_processor(
SimpleSpanProcessor(ConsoleSpanExporter())
)
# Set as global tracer provider
trace.set_tracer_provider(tracer_provider)
# Enable agent-framework instrumentation
enable_instrumentation(enable_sensitive_data=True)
# Use framework normally - spans will be transformed automatically
from agent_framework.openai import OpenAIChatClient
client = OpenAIChatClient(model="gpt-4o-mini", api_key="your-key")
agent = client.as_agent(name="Assistant", instructions="You are helpful.")
response = await agent.run("Hello!")
With Phoenix (Arize)
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from agent_framework.observability import enable_instrumentation
from openinference.instrumentation.agent_framework import (
AgentFrameworkToOpenInferenceProcessor
)
# Configure Phoenix endpoint
endpoint = "http://localhost:6006/v1/traces"
# Setup tracer with OpenInference processor
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(AgentFrameworkToOpenInferenceProcessor())
tracer_provider.add_span_processor(
SimpleSpanProcessor(OTLPSpanExporter(endpoint=endpoint))
)
trace.set_tracer_provider(tracer_provider)
# Enable instrumentation
enable_instrumentation(enable_sensitive_data=True)
# Your agent code here
Transformation Details
Span Kind Mapping
| MS Agent Framework Operation | OpenInference Span Kind |
|---|---|
chat |
LLM |
execute_tool |
TOOL |
invoke_agent |
AGENT |
workflow.run |
CHAIN |
executor.process |
CHAIN |
Attribute Mapping
| Source (GenAI) | Target (OpenInference) |
|---|---|
gen_ai.request.model |
llm.model_name |
gen_ai.provider.name |
llm.provider |
gen_ai.usage.input_tokens |
llm.token_count.prompt |
gen_ai.usage.output_tokens |
llm.token_count.completion |
gen_ai.input.messages |
llm.input_messages.* (flattened) |
gen_ai.output.messages |
llm.output_messages.* (flattened) |
gen_ai.tool.name |
tool.name |
gen_ai.tool.call.id |
tool.call_id |
gen_ai.tool.call.arguments |
tool.parameters |
gen_ai.conversation.id |
session.id |
Message Format Transformation
MS Agent Framework messages:
{
"role": "user",
"parts": [
{"type": "text", "content": "Hello"}
]
}
Transformed to OpenInference flattened format:
llm.input_messages.0.message.role = "user"
llm.input_messages.0.message.content = "Hello"
Debug Mode
Enable debug mode to log transformation details:
processor = AgentFrameworkToOpenInferenceProcessor(debug=True)
Requirements
- Python >= 3.10, < 3.15
- opentelemetry-api >= 1.39.0
- opentelemetry-sdk >= 1.39.0
- openinference-semantic-conventions >= 0.1.25
- agent-framework-core >= 1.0.0 (optional, install with
[instruments]extra) - agent-framework-openai >= 1.0.0 (optional, install with
[instruments]extra)
Important Notes
Agent Framework API Stability
Microsoft Agent Framework's stable OpenAI client changed meaningfully at 1.0.0:
- This instrumentation is tested against
agent-framework-core==1.0.0andagent-framework-openai==1.0.0 - The
-latesttest variant tracks breaking changes in new releases - If you encounter API compatibility issues, pin to the tested stable version:
pip install agent-framework-core==1.0.0 agent-framework-openai==1.0.0
If you have existing VCR cassettes from the 1.0.0rc1 line, re-record them after upgrading. The stable OpenAIChatClient uses the OpenAI Responses API rather than the older Chat Completions path.
Sensitive Data
Set enable_sensitive_data=True when calling enable_instrumentation() to capture message content in traces. This is required for full observability but may include PII.
Development
Running Tests
Tests use VCR cassettes to replay recorded API interactions:
# Run with recorded cassettes (no API key needed)
pytest tests/test_processor.py -v
# Re-record cassettes (requires OPENAI_API_KEY)
export OPENAI_API_KEY=your_key
rm -rf tests/cassettes/
pytest tests/test_processor.py -v --record-mode=rewrite
License
Apache-2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openinference_instrumentation_agent_framework-0.1.5.tar.gz.
File metadata
- Download URL: openinference_instrumentation_agent_framework-0.1.5.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d1269262e7f63b80270693e710d61c45f77846c2b96ea8fd4749a0df873253b
|
|
| MD5 |
7537668fea66b22b060772b4a26113c8
|
|
| BLAKE2b-256 |
8309b48ba01ccaee73c63427e5f2d31766480d0e3de83dbbe64082c046c7490f
|
Provenance
The following attestation bundles were made for openinference_instrumentation_agent_framework-0.1.5.tar.gz:
Publisher:
publish.yaml on Arize-ai/openinference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openinference_instrumentation_agent_framework-0.1.5.tar.gz -
Subject digest:
3d1269262e7f63b80270693e710d61c45f77846c2b96ea8fd4749a0df873253b - Sigstore transparency entry: 1607852001
- Sigstore integration time:
-
Permalink:
Arize-ai/openinference@789d41974c08a9a13147977f28ef4142a07e2106 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Arize-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@789d41974c08a9a13147977f28ef4142a07e2106 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file openinference_instrumentation_agent_framework-0.1.5-py3-none-any.whl.
File metadata
- Download URL: openinference_instrumentation_agent_framework-0.1.5-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7af906938f4f5ecca37e01dcf684dc3b31159e335738ef130c1dbfd7fae49808
|
|
| MD5 |
1b0ee5fa946d24899aa040b47498bf0d
|
|
| BLAKE2b-256 |
bd5182db5cf6379556ab846362564df04cc77a87a44c459e0b1a35b5f5e26dbb
|
Provenance
The following attestation bundles were made for openinference_instrumentation_agent_framework-0.1.5-py3-none-any.whl:
Publisher:
publish.yaml on Arize-ai/openinference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openinference_instrumentation_agent_framework-0.1.5-py3-none-any.whl -
Subject digest:
7af906938f4f5ecca37e01dcf684dc3b31159e335738ef130c1dbfd7fae49808 - Sigstore transparency entry: 1607852061
- Sigstore integration time:
-
Permalink:
Arize-ai/openinference@789d41974c08a9a13147977f28ef4142a07e2106 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Arize-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@789d41974c08a9a13147977f28ef4142a07e2106 -
Trigger Event:
workflow_dispatch
-
Statement type: