From d4f7d56f4a2bdd123d9aae4529d5344bd299701b Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 1 Jan 2024 23:22:30 +0100 Subject: [PATCH 1/8] Exclude App Insights URL Dependency --- code/function/fastapp/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/function/fastapp/utils.py b/code/function/fastapp/utils.py index 9a3d10c..28ab0bb 100644 --- a/code/function/fastapp/utils.py +++ b/code/function/fastapp/utils.py @@ -130,7 +130,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, ) From c2b4027035b6dcad8fe50f3280663b9f94bc8a8f Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 8 Jan 2024 10:07:25 +0100 Subject: [PATCH 2/8] Update requirements --- code/function/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/function/requirements.txt b/code/function/requirements.txt index 5d01136..41b9017 100644 --- a/code/function/requirements.txt +++ b/code/function/requirements.txt @@ -7,6 +7,7 @@ azure-functions~=1.17.0 fastapi~=0.106.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 From 6d636e88a738e1240c06aaa2d4e3f25583ae10c2 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 8 Jan 2024 10:07:33 +0100 Subject: [PATCH 3/8] Remove import --- code/function/fastapp/utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/function/fastapp/utils.py b/code/function/fastapp/utils.py index 28ab0bb..714cd8e 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, From dddddd772b6d0fc66e11be86aeeb8c42aa9e0d91 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 8 Jan 2024 10:07:43 +0100 Subject: [PATCH 4/8] Update settings --- code/function/fastapp/core/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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") From 8892e0e237670fb34edb1895c23cbd00d1ea1640 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 8 Jan 2024 10:08:56 +0100 Subject: [PATCH 5/8] Update fastapi --- code/function/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/function/requirements.txt b/code/function/requirements.txt index 41b9017..f902930 100644 --- a/code/function/requirements.txt +++ b/code/function/requirements.txt @@ -4,7 +4,7 @@ # 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-exporter==1.0.0b20 From 228fd6764ca69a694d5b112ab1f8e6c9b1063856 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 8 Jan 2024 10:14:45 +0100 Subject: [PATCH 6/8] Remove import --- code/function/fastapp/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/function/fastapp/utils.py b/code/function/fastapp/utils.py index 714cd8e..37b55ff 100644 --- a/code/function/fastapp/utils.py +++ b/code/function/fastapp/utils.py @@ -23,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: From 4cce44054fc5087a8d2d913ba2be6227c281ffd6 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 8 Jan 2024 10:14:51 +0100 Subject: [PATCH 7/8] Test build --- .github/workflows/_containerTemplate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_containerTemplate.yml b/.github/workflows/_containerTemplate.yml index e535e15..a48de63 100644 --- a/.github/workflows/_containerTemplate.yml +++ b/.github/workflows/_containerTemplate.yml @@ -74,7 +74,7 @@ jobs: - name: Login Container Registry uses: docker/login-action@v3.0.0 id: registry_login - if: github.event_name != 'pull_request' + # if: github.event_name != 'pull_request' with: registry: ${{ inputs.registry_uri }} username: ${{ secrets.USER_NAME }} @@ -101,7 +101,7 @@ jobs: with: context: ${{ inputs.working_directory }} file: ${{ inputs.working_directory }}/Dockerfile - push: ${{ github.event_name != 'pull_request' }} + push: true # ${{ github.event_name != 'pull_request' }} tags: ${{ steps.metadata.outputs.tags }} labels: ${{ steps.metadata.outputs.labels }} cache-from: type=gha From d96dd8326d0e84a0c10d7c4460ce0b352682f501 Mon Sep 17 00:00:00 2001 From: Marvin Buss Date: Mon, 8 Jan 2024 10:32:44 +0100 Subject: [PATCH 8/8] Revert changes --- .github/workflows/_containerTemplate.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_containerTemplate.yml b/.github/workflows/_containerTemplate.yml index a48de63..e535e15 100644 --- a/.github/workflows/_containerTemplate.yml +++ b/.github/workflows/_containerTemplate.yml @@ -74,7 +74,7 @@ jobs: - name: Login Container Registry uses: docker/login-action@v3.0.0 id: registry_login - # if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' with: registry: ${{ inputs.registry_uri }} username: ${{ secrets.USER_NAME }} @@ -101,7 +101,7 @@ jobs: with: context: ${{ inputs.working_directory }} file: ${{ inputs.working_directory }}/Dockerfile - push: true # ${{ github.event_name != 'pull_request' }} + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.metadata.outputs.tags }} labels: ${{ steps.metadata.outputs.labels }} cache-from: type=gha