Trace Microsoft Agent Framework applications

no

Original Documentation

Documentation Index#

Fetch the complete documentation index at: https://docs.langchain.com/llms.txt Use this file to discover all available pages before exploring further.

LangSmith can capture traces generated by Microsoft Agent Framework using its built-in OpenTelemetry instrumentation. This guide shows you how to automatically capture traces from your Microsoft Agent Framework agents and send them to LangSmith for monitoring and analysis.

Installation#

Install the required packages:

pip install agent-framework opentelemetry-exporter-otlp-proto-http
uv add agent-framework opentelemetry-exporter-otlp-proto-http

Setup#

1. Configure environment variables#

Enable OpenTelemetry instrumentation of the agent and set the OpenTelemetry environment variables to point to the LangSmith OTEL endpoint:

export ENABLE_INSTRUMENTATION=true
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT=https://api.smith.langchain.com/otel/v1/traces
export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=<your_langsmith_api_key>,Langsmith-Project=<your_project_name>"

2. Enable OpenTelemetry in your application#

In your Microsoft Agent Framework application, enable OpenTelemetry tracing using the built-in configure_otel_providers function:

from agent_framework.observability import configure_otel_providers

# Enable OpenTelemetry tracing
configure_otel_providers(enable_sensitive_data=True)

Setting enable_sensitive_data=True allows capturing input and output content in traces. Set to False if you want to exclude sensitive data from traces.

3. Create and run your agent#

Once configured, your Microsoft Agent Framework agents will automatically send traces to LangSmith:

from agent_framework import ChatAgent
from agent_framework.observability import configure_otel_providers
from agent_framework.openai import OpenAIChatClient

# Enable OpenTelemetry tracing
configure_otel_providers(enable_sensitive_data=True)


agent = ChatAgent(
    chat_client=OpenAIChatClient(model_id="gpt-4o"),
)

result = await agent.run("What's the the capital of Bavaria?")
print(result.text)

Edit this page on GitHub or file an issue.

Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

Link last verified June 7, 2026. View original ↗
Source: LangChain Docs
Link last verified: 2026-03-04