Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AI project connection string and updated Azure Identity #268

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gunicorn==21.2.0
jupyter
opentelemetry-sdk
opentelemetry-instrumentation
azure-identity==1.17.1
azure-identity==1.19.0
azure-ai-contentsafety
azure-ai-inference
https://remoteevalbugbash.blob.core.windows.net/remoteevalbugbash/azure_ai_project-1.0.0b1-py3-none-any.whl
Expand Down
14 changes: 5 additions & 9 deletions src/api/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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"])