From 38cf2a977a6d21be247ec7626a7665ea7465456a Mon Sep 17 00:00:00 2001 From: sudivate Date: Thu, 14 Nov 2024 22:21:18 +0000 Subject: [PATCH] Fix AI project connectin string and update azure identity Signed-off-by: sudivate --- requirements.txt | 2 +- src/api/requirements.txt | 2 +- src/api/telemetry.py | 14 +++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/requirements.txt b/requirements.txt index e9950118..581b19c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ gunicorn==21.2.0 jupyter opentelemetry-sdk opentelemetry-instrumentation -azure-identity==1.17.1 +azure-identity==1.19.0 https://remoteevalbugbash.blob.core.windows.net/remoteevalbugbash/azure_ai_project-1.0.0b1-py3-none-any.whl gunicorn==21.2.0 azure-keyvault-secrets diff --git a/src/api/requirements.txt b/src/api/requirements.txt index f5f68109..22965fd8 100644 --- a/src/api/requirements.txt +++ b/src/api/requirements.txt @@ -14,7 +14,7 @@ gunicorn==21.2.0 jupyter opentelemetry-sdk opentelemetry-instrumentation -azure-identity==1.17.1 +azure-identity==1.19.0 https://remoteevalbugbash.blob.core.windows.net/remoteevalbugbash/azure_ai_project-1.0.0b1-py3-none-any.whl gunicorn==21.2.0 azure-keyvault-secrets diff --git a/src/api/telemetry.py b/src/api/telemetry.py index b5f6d10c..120bdcfe 100644 --- a/src/api/telemetry.py +++ b/src/api/telemetry.py @@ -30,14 +30,10 @@ def setup_telemetry(app: FastAPI): local_tracing_enabled=os.getenv("LOCAL_TRACING_ENABLED") otel_exporter_endpoint = os.getenv("OTEL_EXPORTER_OTLP_ENDPOINT") - location = os.environ["AZURE_LOCATION"]+".api.azureml.ms;" - subscription = os.environ["AZURE_SUBSCRIPTION_ID"]+";" - resource_group = os.environ["AZURE_RESOURCE_GROUP"]+";" - project_name = os.environ["AZURE_AI_PROJECT_NAME"]+";" - - # Configure OpenTelemetry using Azure AI Project - ai_project_conn_str = location + subscription +resource_group + project_name - + # Get the connection string from the environment variables + ai_project_conn_str = os.getenv("AZURE_LOCATION")+".api.azureml.ms;"+os.getenv( + "AZURE_SUBSCRIPTION_ID")+";"+os.getenv("AZURE_RESOURCE_GROUP")+";"+os.getenv("AZURE_AI_PROJECT_NAME") + # Configure OpenTelemetry using Azure AI Project with AIProjectClient.from_connection_string( credential=DefaultAzureCredential(), @@ -67,7 +63,7 @@ def setup_telemetry(app: FastAPI): # Set the EventLoggerProvider as opentelemetry-instrumentation-openai-v2 use log events to log tokens event_provider = EventLoggerProvider() - set_event_logger_provider(event_provider) + set_event_logger_provider(event_provider) # Instrument FastAPI and exclude the send span to reduce noise FastAPIInstrumentor.instrument_app(app,exclude_spans=["send"])