mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix observability samples (#5016)
* Fix observability samples * Update python/samples/02-agents/observability/configure_otel_providers_with_parameters.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update python/samples/02-agents/observability/agent_observability.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update python/samples/02-agents/observability/agent_observability.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
b065a4ce51
commit
86f8efc8ff
@@ -7,6 +7,7 @@ from typing import Annotated
|
||||
from agent_framework import Agent, tool
|
||||
from agent_framework.foundry import FoundryChatClient
|
||||
from agent_framework.observability import configure_otel_providers, get_tracer
|
||||
from azure.identity import AzureCliCredential
|
||||
from dotenv import load_dotenv
|
||||
from opentelemetry.trace import SpanKind
|
||||
from opentelemetry.trace.span import format_trace_id
|
||||
@@ -18,6 +19,12 @@ load_dotenv()
|
||||
"""
|
||||
This sample shows how you can observe an agent in Agent Framework by using the
|
||||
same observability setup function.
|
||||
|
||||
Pre-requisites:
|
||||
- A Foundry project
|
||||
- An observability backend to receive traces and metrics (for example, a local or remote
|
||||
OpenTelemetry Collector, another OTLP-compatible backend, or console exporters enabled
|
||||
via environment variables).
|
||||
"""
|
||||
|
||||
|
||||
@@ -47,7 +54,7 @@ async def main():
|
||||
print(f"Trace ID: {format_trace_id(current_span.get_span_context().trace_id)}")
|
||||
|
||||
agent = Agent(
|
||||
client=FoundryChatClient(),
|
||||
client=FoundryChatClient(credential=AzureCliCredential()),
|
||||
tools=get_weather,
|
||||
name="WeatherAgent",
|
||||
instructions="You are a weather assistant.",
|
||||
|
||||
Reference in New Issue
Block a user