diff --git a/code/function/fastapp/core/config.py b/code/function/fastapp/core/config.py index 62846bd..5366145 100644 --- a/code/function/fastapp/core/config.py +++ b/code/function/fastapp/core/config.py @@ -14,7 +14,7 @@ class Settings(BaseSettings): LOGGING_SCHEDULE_DELAY: int = 5000 DEBUG: bool = False APPLICATIONINSIGHTS_CONNECTION_STRING: str = Field( - default="", env="APPLICATIONINSIGHTS_CONNECTION_STRING" + default="", alias="APPLICATIONINSIGHTS_CONNECTION_STRING" ) WEBSITE_NAME: str = Field(default="test", alias="WEBSITE_SITE_NAME") WEBSITE_INSTANCE_ID: str = Field(default="0", alias="WEBSITE_INSTANCE_ID") diff --git a/code/function/fastapp/utils.py b/code/function/fastapp/utils.py index 9a3d10c..37b55ff 100644 --- a/code/function/fastapp/utils.py +++ b/code/function/fastapp/utils.py @@ -1,8 +1,6 @@ import logging from logging import Logger -from azure.monitor.opentelemetry import configure_azure_monitor - # from azure.identity import ManagedIdentityCredential from azure.monitor.opentelemetry.exporter import ( ApplicationInsightsSampler, @@ -25,7 +23,7 @@ from opentelemetry.sdk.resources import SERVICE_NAME, Resource from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import BatchSpanProcessor -from opentelemetry.trace import Tracer, get_tracer_provider, set_tracer_provider +from opentelemetry.trace import Tracer, set_tracer_provider def setup_logging(module) -> Logger: @@ -130,7 +128,7 @@ def setup_opentelemetry(app: FastAPI): # Create instrumenter FastAPIInstrumentor.instrument_app( app, - excluded_urls=f"{settings.API_V1_STR}/health/heartbeat", + excluded_urls=f".*.in.applicationinsights.azure.com/.*,{settings.API_V1_STR}/health/heartbeat", tracer_provider=tracer_provider, meter_provider=meter_provider, ) diff --git a/code/function/requirements.txt b/code/function/requirements.txt index 5d01136..f902930 100644 --- a/code/function/requirements.txt +++ b/code/function/requirements.txt @@ -4,9 +4,10 @@ # azure-identity~=1.15.0 azure-functions~=1.17.0 -fastapi~=0.106.0 +fastapi~=0.108.0 pydantic-settings~=2.1.0 httpx~=0.26.0 -azure-monitor-opentelemetry~=1.1.1 +azure-monitor-opentelemetry-exporter==1.0.0b20 +opentelemetry-instrumentation-fastapi==0.43b0 opentelemetry-instrumentation-httpx~=0.43b0 opentelemetry-instrumentation-system-metrics~=0.43b0