diff --git a/sdk/ai/azure-ai-agents/README.md b/sdk/ai/azure-ai-agents/README.md index 6c66cdb234a0..f1d29e780e96 100644 --- a/sdk/ai/azure-ai-agents/README.md +++ b/sdk/ai/azure-ai-agents/README.md @@ -1143,15 +1143,6 @@ from azure.monitor.opentelemetry import configure_azure_monitor application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] configure_azure_monitor(connection_string=application_insights_connection_string) -try: - from azure.ai.agents.telemetry import AIAgentsInstrumentor - - agents_instrumentor = AIAgentsInstrumentor() - if not agents_instrumentor.is_instrumented(): - agents_instrumentor.instrument() -except Exception as exc: # pylint: disable=broad-exception-caught - print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}") - scenario = os.path.basename(__file__) tracer = trace.get_tracer(__name__) diff --git a/sdk/ai/azure-ai-agents/samples/agents_multiagent/utils/agent_trace_configurator.py b/sdk/ai/azure-ai-agents/samples/agents_multiagent/utils/agent_trace_configurator.py index 8ba54dc149eb..7c03cb453d58 100644 --- a/sdk/ai/azure-ai-agents/samples/agents_multiagent/utils/agent_trace_configurator.py +++ b/sdk/ai/azure-ai-agents/samples/agents_multiagent/utils/agent_trace_configurator.py @@ -25,14 +25,6 @@ def enable_azure_monitor_tracing(self): print("Enable it via the 'Tracing' tab in your AI Foundry project page.") exit() configure_azure_monitor(connection_string=application_insights_connection_string) - try: - from azure.ai.agents.telemetry import AIAgentsInstrumentor - - agents_instrumentor = AIAgentsInstrumentor() - if not agents_instrumentor.is_instrumented(): - agents_instrumentor.instrument() - except Exception as exc: # pylint: disable=broad-exception-caught - print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}") def enable_console_tracing_without_genai(self): exporter = ConsoleSpanExporter() diff --git a/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_async_with_azure_monitor_tracing.py b/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_async_with_azure_monitor_tracing.py index 09da43a6ca7c..69e938c24a29 100644 --- a/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_async_with_azure_monitor_tracing.py +++ b/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_async_with_azure_monitor_tracing.py @@ -52,15 +52,6 @@ async def main() -> None: application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] configure_azure_monitor(connection_string=application_insights_connection_string) - try: - from azure.ai.agents.telemetry import AIAgentsInstrumentor - - agents_instrumentor = AIAgentsInstrumentor() - if not agents_instrumentor.is_instrumented(): - agents_instrumentor.instrument() - except Exception as exc: # pylint: disable=broad-exception-caught - print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}") - with tracer.start_as_current_span(scenario): async with agents_client: agent = await agents_client.create_agent( diff --git a/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_with_azure_monitor_tracing.py b/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_with_azure_monitor_tracing.py index 517cb4820dfd..9d8ecaea9a6c 100644 --- a/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_with_azure_monitor_tracing.py +++ b/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_with_azure_monitor_tracing.py @@ -28,7 +28,7 @@ can be found in the `sample_telemetry.py` file in the azure-ai-projects telemetry samples. """ -import os, time +import os from azure.ai.agents import AgentsClient from azure.ai.agents.models import ListSortOrder from azure.identity import DefaultAzureCredential @@ -46,15 +46,6 @@ application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] configure_azure_monitor(connection_string=application_insights_connection_string) -try: - from azure.ai.agents.telemetry import AIAgentsInstrumentor - - agents_instrumentor = AIAgentsInstrumentor() - if not agents_instrumentor.is_instrumented(): - agents_instrumentor.instrument() -except Exception as exc: # pylint: disable=broad-exception-caught - print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}") - scenario = os.path.basename(__file__) tracer = trace.get_tracer(__name__) diff --git a/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_stream_eventhandler_with_azure_monitor_tracing.py b/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_stream_eventhandler_with_azure_monitor_tracing.py index 984aa21910e3..97a053a8c4e5 100644 --- a/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_stream_eventhandler_with_azure_monitor_tracing.py +++ b/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_stream_eventhandler_with_azure_monitor_tracing.py @@ -82,15 +82,6 @@ def on_unhandled_event(self, event_type: str, event_data: Any) -> None: application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] configure_azure_monitor(connection_string=application_insights_connection_string) -try: - from azure.ai.agents.telemetry import AIAgentsInstrumentor - - agents_instrumentor = AIAgentsInstrumentor() - if not agents_instrumentor.is_instrumented(): - agents_instrumentor.instrument() -except Exception as exc: # pylint: disable=broad-exception-caught - print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}") - scenario = os.path.basename(__file__) tracer = trace.get_tracer(__name__) diff --git a/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_toolset_with_azure_monitor_tracing.py b/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_toolset_with_azure_monitor_tracing.py index 9b5711752952..10ad351fafe2 100644 --- a/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_toolset_with_azure_monitor_tracing.py +++ b/sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_toolset_with_azure_monitor_tracing.py @@ -50,15 +50,6 @@ application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"] configure_azure_monitor(connection_string=application_insights_connection_string) -try: - from azure.ai.agents.telemetry import AIAgentsInstrumentor - - agents_instrumentor = AIAgentsInstrumentor() - if not agents_instrumentor.is_instrumented(): - agents_instrumentor.instrument() -except Exception as exc: # pylint: disable=broad-exception-caught - print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}") - scenario = os.path.basename(__file__) tracer = trace.get_tracer(__name__)