Skip to content

Exclude App Insights URL Dependency #97

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

Merged
merged 9 commits into from
Jan 8, 2024
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 code/function/fastapp/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 2 additions & 4 deletions code/function/fastapp/utils.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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,
)
Expand Down
5 changes: 3 additions & 2 deletions code/function/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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