Skip to content

Commit 98658ac

Browse files
committed
Logging configuration for Application Insights
1 parent 17dbcca commit 98658ac

3 files changed

Lines changed: 3 additions & 23 deletions

File tree

manage_breast_screening/config/settings.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -305,29 +305,12 @@ def list_env(key):
305305
"loggers": {
306306
"django": {
307307
"level": "INFO",
308-
"handlers": ["console"],
309-
"propagate": False,
310308
},
311309
"django.request": {
312-
"handlers": ["console"],
313-
"level": "INFO",
314-
"propagate": False,
315310
"filters": ["suppress_duplicate_exceptions"],
316311
},
317312
"django.db.backends": {
318313
"level": "DEBUG" if LOG_QUERIES else "INFO",
319-
"handlers": ["console"],
320-
"propagate": False,
321-
},
322-
"django.server": {
323-
"level": "INFO",
324-
"handlers": ["console"],
325-
"propagate": False,
326-
},
327-
"django.utils.autoreload": {
328-
"level": "INFO",
329-
"handlers": ["console"],
330-
"propagate": False,
331314
},
332315
"faker": {"level": "INFO"},
333316
"msal": {"level": "INFO"},

manage_breast_screening/core/services/application_insights_logging.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self) -> None:
1111
self.logger_name = os.getenv(
1212
"APPLICATIONINSIGHTS_LOGGER_NAME", "insights-logger"
1313
)
14-
os.environ.setdefault("OTEL_SERVICE_NAME", self.logger_name)
14+
os.environ.setdefault("OTEL_SERVICE_NAME", "manage-breast-screening")
1515
self.logger = self.getLogger()
1616

1717
def configure_azure_monitor(self):
@@ -20,10 +20,7 @@ def configure_azure_monitor(self):
2020
):
2121
# Configure OpenTelemetry to use Azure Monitor with the
2222
# APPLICATIONINSIGHTS_CONNECTION_STRING environment variable.
23-
configure_azure_monitor(
24-
# Set the namespace for the logger in which you would like to collect telemetry for if you are collecting logging telemetry. This is imperative so you do not collect logging telemetry from the SDK itself.
25-
logger_name=self.logger_name,
26-
)
23+
configure_azure_monitor()
2724
else:
2825
default_logger = logging.getLogger(__name__)
2926
default_logger.info("Application Insights logging not enabled")

manage_breast_screening/core/tests/services/test_application_insights_logging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_configures_azure_monitor_when_env_correct(
2424
monkeypatch.setenv("APPLICATIONINSIGHTS_IS_ENABLED", "True")
2525
monkeypatch.setenv("APPLICATIONINSIGHTS_CONNECTION_STRING", "something")
2626
ApplicationInsightsLogging().configure_azure_monitor()
27-
mock_configure_azure.assert_called_with(logger_name="insights-logger")
27+
mock_configure_azure.assert_called_with()
2828

2929
def test_does_not_configure_if_flag_not_enabled(
3030
self, mock_logging, mock_configure_azure, monkeypatch

0 commit comments

Comments
 (0)