|
48 | 48 | appinsights_connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING") |
49 | 49 | if appinsights_connection_string: |
50 | 50 | # Configure Application Insights if the connection string is found |
51 | | - # logging_level=WARNING sends only WARNING/ERROR/CRITICAL to App Insights |
52 | | - # (INFO traces like "Loaded product", "Uploaded image", workflow steps stay in container logs only) |
53 | 51 | configure_azure_monitor( |
54 | 52 | connection_string=appinsights_connection_string, |
55 | 53 | enable_live_metrics=False, |
56 | 54 | enable_performance_counters=False, |
57 | | - logging_level=logging.WARNING, |
58 | 55 | ) |
| 56 | + # Suppress verbose Azure SDK INFO logs from App Insights |
| 57 | + # WARNING/ERROR/CRITICAL from these loggers still come through |
| 58 | + logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(logging.WARNING) |
| 59 | + logging.getLogger("azure.monitor.opentelemetry.exporter").setLevel(logging.WARNING) |
| 60 | + logging.getLogger("azure.identity").setLevel(logging.WARNING) |
| 61 | + logging.getLogger("azure.cosmos").setLevel(logging.WARNING) |
59 | 62 | # Disable Azure SDK native span creation (ContainerProxy.*, BlobClient.* InProc spans) |
60 | 63 | azure_settings.tracing_implementation = None |
61 | 64 | # Apply ASGI middleware for request tracing (Quart is not auto-instrumented by configure_azure_monitor) |
| 65 | + # Exclude health probes, post-deploy admin calls, and polling endpoints from telemetry |
62 | 66 | app.asgi_app = OpenTelemetryMiddleware( |
63 | 67 | app.asgi_app, |
64 | 68 | exclude_spans=["receive", "send"], |
65 | | - excluded_urls="api/generate/status", |
| 69 | + excluded_urls="health,api/generate/status", |
66 | 70 | ) |
67 | 71 | logger.info("Application Insights configured with the provided connection string") |
68 | 72 | else: |
|
0 commit comments