Integrations
AutoGen
Trace Microsoft AutoGen multi-agent applications in Muster via OpenLit instrumentation.
AutoGen is an open-source framework from Microsoft for building LLM applications with conversational agents. Muster traces AutoGen runs through the OpenLit instrumentation, capturing every agent message and LLM call as OpenTelemetry spans.
Setup
1. Install dependencies
pip install langfuse openlit autogen-agentchat autogen-ext2. Configure credentials
import os
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_BASE_URL"] = "https://app.getmuster.io"
os.environ["OPENAI_API_KEY"] = "sk-proj-..."3. Initialize OpenLit instrumentation
import openlit
openlit.init()Once initialised, every AutoGen agent invocation is captured automatically as an OTel span and forwarded to Muster.
4. Run an AutoGen agent
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
import asyncio
async def main():
model_client = OpenAIChatCompletionClient(model="gpt-4o-mini")
assistant = AssistantAgent("assistant", model_client=model_client)
response = await assistant.on_messages_stream(
[{"role": "user", "content": "Tell me about Muster"}],
cancellation_token=None,
)
async for msg in response:
print(msg)
asyncio.run(main())Add user/session attributes
from langfuse import propagate_attributes
with propagate_attributes(user_id="user_123", session_id="sess_abc"):
# run your AutoGen workflow
...Troubleshooting
- Enable debug logging:
export LANGFUSE_DEBUG="True". - Call
langfuse.flush()before exit in short-lived scripts. - Filter unrelated OTel spans to reduce billable units.