Microsoft Agent Framework OpenTelemetry Integration
Overview
This integration provides support for using OpenTelemetry with Microsoft Agent Framework. It enables tracing and monitoring of applications built with Agent Framework.
Installation
- Install traceAI Agent Framework
pip install traceAI-agent-framework
- Install Microsoft Agent Framework
pip install agent-framework
Set Environment Variables
Set up your environment variables to authenticate with FutureAGI
import os
os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
Quickstart
Register Tracer Provider
Set up the trace provider to establish the observability pipeline. The trace provider:
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="agent_framework_app",
set_global_tracer_provider=True,
)
Configure Agent Framework Instrumentation
Turn on Agent Framework's native OpenTelemetry emission and install the FI attribute mapping.
from agent_framework.observability import enable_instrumentation
from traceai_agent_framework import enable_fi_attribute_mapping
enable_instrumentation(enable_sensitive_data=True)
enable_fi_attribute_mapping()
enable_sensitive_data=True records prompts, completions and tool arguments on the spans. Leave it off to keep that content out of your traces.
Privacy
Content is captured by default (as in every traceAI integration) once enable_sensitive_data is on. Hide it with the standard FI_HIDE_INPUTS, FI_HIDE_OUTPUTS, FI_HIDE_INPUT_MESSAGES, FI_HIDE_OUTPUT_MESSAGES, FI_HIDE_INPUT_TEXT and FI_HIDE_OUTPUT_TEXT environment variables, or pass enable_fi_attribute_mapping(config=TraceConfig(...)). Tool arguments/results and system instructions follow hide_inputs / hide_outputs. Raw exception text and stack traces are never exported: an errored span keeps ERROR status and the exception class name.
Agent Framework emits on the global tracer provider only, so keep set_global_tracer_provider=True in register(...).
Create Agent Framework Components
Set up your Agent Framework client with built-in observability.
import asyncio
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient
agent = Agent(
OpenAIChatClient(model="gpt-4o-mini"),
name="weather_agent",
instructions="You are a concise weather assistant.",
)
async def main():
response = await agent.run("What's the weather in Paris?")
print(response)
asyncio.run(main())
Token usage
Model-call spans keep gen_ai.usage.*. Native agent totals summarize those calls and are retained as agent_framework.usage.* diagnostics, not additional billable tokens. This prevents trace totals from counting the same usage twice.
Sessions
All spans of one run get the same session.id, which Observe groups sessions on. It comes from, in order:
using_session(...)around the run. This works with every chat client, including ones that keep history locally such asOpenAIChatCompletionClient:
from fi_instrumentation import using_session
session = agent.create_session()
with using_session("support-chat-42"):
await agent.run("What's the weather in Paris?", session=session)
await agent.run("And in Tokyo?", session=session)
- The
gen_ai.conversation.idthe run starts with, which is the session'sservice_session_id. With the Responses API and no stored conversation, that id is the previous response id, so each turn lands in its own session. Useusing_sessionfor one session across turns.
Metadata
Release files for traceAI-agent-framework 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_agent_framework-0.1.0.tar.gz | 12.7 kB | With provenance | Details for traceai_agent_framework-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_agent_framework-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for traceai_agent_framework-0.1.0-py3-none-any.whl |
Total release size: 25.6 kB
Release files / traceai_agent_framework-0.1.0.tar.gz
| Download URL | traceai_agent_framework-0.1.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf50f3354dd34615b9e10e1392e3736b32cc323befdf644e7410e28927d38055
|
|
BLAKE2b-256 checksum How to use checksums |
ccca0f1f4ce0431eb525b88538099f07ad9525946efd52d15fe22e46ddc1adf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logRelease files / traceai_agent_framework-0.1.0-py3-none-any.whl
| Download URL | traceai_agent_framework-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd05dc1e217c573b51228373467059131cf76882f2a90e0194bdcc74bba5dcea
|
|
BLAKE2b-256 checksum How to use checksums |
694e0cc8b2ed8f068482db0185d7bd27af236bce1925f65248e8ab7fdc89600a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logSecurity for traceAI-agent-framework 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for traceai_agent_framework-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.