Skip to content

Commit 41db3b2

Browse files
authored
removing instrumentor call for azure monitor samples (#41068)
* removing instrumentor call for azure monitor samples * updating code snippet * removing unused import from sample to restart build
1 parent d992724 commit 41db3b2

6 files changed

+1
-54
lines changed

sdk/ai/azure-ai-agents/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,15 +1143,6 @@ from azure.monitor.opentelemetry import configure_azure_monitor
11431143
application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
11441144
configure_azure_monitor(connection_string=application_insights_connection_string)
11451145

1146-
try:
1147-
from azure.ai.agents.telemetry import AIAgentsInstrumentor
1148-
1149-
agents_instrumentor = AIAgentsInstrumentor()
1150-
if not agents_instrumentor.is_instrumented():
1151-
agents_instrumentor.instrument()
1152-
except Exception as exc: # pylint: disable=broad-exception-caught
1153-
print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}")
1154-
11551146
scenario = os.path.basename(__file__)
11561147
tracer = trace.get_tracer(__name__)
11571148

sdk/ai/azure-ai-agents/samples/agents_multiagent/utils/agent_trace_configurator.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ def enable_azure_monitor_tracing(self):
2525
print("Enable it via the 'Tracing' tab in your AI Foundry project page.")
2626
exit()
2727
configure_azure_monitor(connection_string=application_insights_connection_string)
28-
try:
29-
from azure.ai.agents.telemetry import AIAgentsInstrumentor
30-
31-
agents_instrumentor = AIAgentsInstrumentor()
32-
if not agents_instrumentor.is_instrumented():
33-
agents_instrumentor.instrument()
34-
except Exception as exc: # pylint: disable=broad-exception-caught
35-
print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}")
3628

3729
def enable_console_tracing_without_genai(self):
3830
exporter = ConsoleSpanExporter()

sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_async_with_azure_monitor_tracing.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ async def main() -> None:
5252
application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
5353
configure_azure_monitor(connection_string=application_insights_connection_string)
5454

55-
try:
56-
from azure.ai.agents.telemetry import AIAgentsInstrumentor
57-
58-
agents_instrumentor = AIAgentsInstrumentor()
59-
if not agents_instrumentor.is_instrumented():
60-
agents_instrumentor.instrument()
61-
except Exception as exc: # pylint: disable=broad-exception-caught
62-
print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}")
63-
6455
with tracer.start_as_current_span(scenario):
6556
async with agents_client:
6657
agent = await agents_client.create_agent(

sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_basics_with_azure_monitor_tracing.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
can be found in the `sample_telemetry.py` file in the azure-ai-projects telemetry samples.
2929
"""
3030

31-
import os, time
31+
import os
3232
from azure.ai.agents import AgentsClient
3333
from azure.ai.agents.models import ListSortOrder
3434
from azure.identity import DefaultAzureCredential
@@ -46,15 +46,6 @@
4646
application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
4747
configure_azure_monitor(connection_string=application_insights_connection_string)
4848

49-
try:
50-
from azure.ai.agents.telemetry import AIAgentsInstrumentor
51-
52-
agents_instrumentor = AIAgentsInstrumentor()
53-
if not agents_instrumentor.is_instrumented():
54-
agents_instrumentor.instrument()
55-
except Exception as exc: # pylint: disable=broad-exception-caught
56-
print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}")
57-
5849
scenario = os.path.basename(__file__)
5950
tracer = trace.get_tracer(__name__)
6051

sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_stream_eventhandler_with_azure_monitor_tracing.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ def on_unhandled_event(self, event_type: str, event_data: Any) -> None:
8282
application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
8383
configure_azure_monitor(connection_string=application_insights_connection_string)
8484

85-
try:
86-
from azure.ai.agents.telemetry import AIAgentsInstrumentor
87-
88-
agents_instrumentor = AIAgentsInstrumentor()
89-
if not agents_instrumentor.is_instrumented():
90-
agents_instrumentor.instrument()
91-
except Exception as exc: # pylint: disable=broad-exception-caught
92-
print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}")
93-
9485
scenario = os.path.basename(__file__)
9586
tracer = trace.get_tracer(__name__)
9687

sdk/ai/azure-ai-agents/samples/agents_telemetry/sample_agents_toolset_with_azure_monitor_tracing.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@
5050
application_insights_connection_string = os.environ["APPLICATIONINSIGHTS_CONNECTION_STRING"]
5151
configure_azure_monitor(connection_string=application_insights_connection_string)
5252

53-
try:
54-
from azure.ai.agents.telemetry import AIAgentsInstrumentor
55-
56-
agents_instrumentor = AIAgentsInstrumentor()
57-
if not agents_instrumentor.is_instrumented():
58-
agents_instrumentor.instrument()
59-
except Exception as exc: # pylint: disable=broad-exception-caught
60-
print(f"Could not call `AIAgentsInstrumentor().instrument()`. Exception: {exc}")
61-
6253
scenario = os.path.basename(__file__)
6354
tracer = trace.get_tracer(__name__)
6455

0 commit comments

Comments
 (0)