Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

with tracer.start_as_current_span(scenario):
with project_client:
project_client.telemetry.enable()
#project_client.telemetry.enable()
# [END enable_tracing]
agent = project_client.agents.create_agent(
model=os.environ["MODEL_DEPLOYMENT_NAME"], name="my-assistant", instructions="You are helpful assistant"
Expand All @@ -62,7 +62,7 @@
print(f"Created thread, thread ID: {thread.id}")

message = project_client.agents.create_message(
thread_id=thread.id, role="user", content="Hello, tell me a joke"
thread_id=thread.id, role="user", content="Hello, tell me a hilarious joke"
)
print(f"Created message, message ID: {message.id}")

Expand Down
3 changes: 3 additions & 0 deletions sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Features Added

- Enable Azure AI Agents instrumentation
([#40043](https://github.com/Azure/azure-sdk-for-python/pull/40043))

### Breaking Changes

### Bugs Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,42 @@ def _setup_additional_azure_sdk_instrumentations(configurations: Dict[str, Confi
_logger.debug("Instrumentation skipped for library azure_sdk")
return

ai_inference_instrumentor_imported = False
try:
from azure.ai.inference.tracing import AIInferenceInstrumentor # pylint: disable=import-error,no-name-in-module
ai_inference_instrumentor_imported = True
except Exception as ex: # pylint: disable=broad-except
_logger.debug(
"Failed to import AIInferenceInstrumentor from azure-ai-inference",
exc_info=ex,
)
return

if ai_inference_instrumentor_imported:
Comment thread
lmolkova marked this conversation as resolved.
Outdated
try:
AIInferenceInstrumentor().instrument()
except Exception as ex: # pylint: disable=broad-except
_logger.warning(
"Exception occurred when instrumenting: %s.",
"azure-ai-inference",
exc_info=ex,
)

ai_agents_instrumentor_imported = False
try:
AIInferenceInstrumentor().instrument()
from azure.ai.projects.telemetry.agents import AIAgentsInstrumentor # pylint: disable=import-error,no-name-in-module
ai_agents_instrumentor_imported = True
except Exception as ex: # pylint: disable=broad-except
_logger.warning(
"Exception occurred when instrumenting: %s.",
"azure-ai-inference",
_logger.debug(
"Failed to import AIAgentsInstrumentor from azure-ai-projects-telemetry-agents",
exc_info=ex,
)

if ai_agents_instrumentor_imported:
try:
AIAgentsInstrumentor().instrument()
Comment thread
lmolkova marked this conversation as resolved.
Outdated
Comment thread
lmolkova marked this conversation as resolved.
Outdated
except Exception as ex: # pylint: disable=broad-except
_logger.warning(
"Exception occurred when instrumenting: %s.",
"azure-ai-projects-telemetry-agents",
exc_info=ex,
)
Loading