Skip to content

Commit 09a7bee

Browse files
committed
chore(Azure): remove Azure OpenCensus integration
Now that we have Sentry, we determined that the App Service logs are sufficient for other logs, and thus it isn't worth the complexity/confusion of having the logs sent to Azure Monitor.
1 parent f72883a commit 09a7bee

File tree

6 files changed

+27
-112
lines changed

6 files changed

+27
-112
lines changed

appcontainer/requirements.txt

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ Authlib==1.2.0
22
Django==4.1.6
33
django-csp==3.7
44
eligibility-api==2023.01.1
5-
opencensus-ext-azure==1.1.8
6-
opencensus-ext-django==0.8.0
75
requests==2.28.2
86
sentry-sdk==1.15.0
97
six==1.16.0

benefits/logging.py

-49
This file was deleted.

benefits/settings.py

+27-19
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
import os
55
from benefits import sentry
6-
import benefits.logging
76

87

98
def _filter_empty(ls):
@@ -69,23 +68,6 @@ def _filter_empty(ls):
6968
MIDDLEWARE.append("benefits.core.middleware.DebugSession")
7069

7170

72-
# Azure Insights
73-
# https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-python-request#tracking-django-applications
74-
75-
ENABLE_AZURE_INSIGHTS = "APPLICATIONINSIGHTS_CONNECTION_STRING" in os.environ
76-
print("ENABLE_AZURE_INSIGHTS: ", ENABLE_AZURE_INSIGHTS)
77-
if ENABLE_AZURE_INSIGHTS:
78-
MIDDLEWARE.append("opencensus.ext.django.middleware.OpencensusMiddleware")
79-
80-
# only used if enabled above
81-
OPENCENSUS = {
82-
"TRACE": {
83-
"SAMPLER": "opencensus.trace.samplers.AlwaysOnSampler()",
84-
"EXPORTER": "opencensus.ext.azure.trace_exporter.AzureExporter()",
85-
}
86-
}
87-
88-
8971
CSRF_COOKIE_AGE = None
9072
CSRF_COOKIE_SAMESITE = "Strict"
9173
CSRF_COOKIE_HTTPONLY = True
@@ -221,7 +203,33 @@ def _filter_empty(ls):
221203

222204
# Logging configuration
223205
LOG_LEVEL = os.environ.get("DJANGO_LOG_LEVEL", "DEBUG" if DEBUG else "WARNING")
224-
LOGGING = benefits.logging.get_config(LOG_LEVEL, enable_azure=ENABLE_AZURE_INSIGHTS)
206+
LOGGING = {
207+
"version": 1,
208+
"disable_existing_loggers": False,
209+
"formatters": {
210+
"default": {
211+
"format": "[{asctime}] {levelname} {name}:{lineno} {message}",
212+
"datefmt": "%d/%b/%Y %H:%M:%S",
213+
"style": "{",
214+
},
215+
},
216+
"handlers": {
217+
"console": {
218+
"class": "logging.StreamHandler",
219+
"formatter": "default",
220+
},
221+
},
222+
"root": {
223+
"handlers": ["console"],
224+
"level": LOG_LEVEL,
225+
},
226+
"loggers": {
227+
"django": {
228+
"handlers": ["console"],
229+
"propagate": False,
230+
},
231+
},
232+
}
225233

226234
sentry.configure()
227235

docs/configuration/environment-variables.md

-14
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,6 @@ The base URL for the (running) application, against which all Cypress `.visit()`
158158
When Cypress is running inside the devcontainer, this should be `http://localhost:8000`. When Cypress is running outside the
159159
devcontainer, check the [`DJANGO_LOCAL_PORT`](#django_local_port).
160160

161-
## Azure
162-
163-
### `APPLICATIONINSIGHTS_CONNECTION_STRING`
164-
165-
!!! tldr "Azure docs"
166-
167-
[Azure Monitor connection strings](https://docs.microsoft.com/en-us/azure/azure-monitor/app/sdk-connection-string)
168-
169-
Enables [log collection](../../deployment/troubleshooting/#logs). Set the value in quotes, e.g. `APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=…"`.
170-
171-
[app-service-config]: https://docs.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal
172-
[benefits-secrets]: https://github.com/cal-itp/benefits-secrets
173-
[getting-started_create-env]: ../getting-started/README.md#create-an-environment-file
174-
175161
## Sentry
176162

177163
### `SENTRY_DSN`

docs/deployment/troubleshooting.md

-15
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ We have [ping tests](https://docs.microsoft.com/en-us/azure/azure-monitor/app/mo
88

99
### Logs
1010

11-
Logs can be found a couple of places:
12-
1311
#### Azure App Service Logs
1412

1513
[Open the `Logs` for the environment you are interested in.](https://docs.google.com/document/d/11EPDIROBvg7cRtU2V42c6VBxcW_o8HhcyORALNtL_XY/edit#heading=h.6pxjhslhxwvj) The following tables are likely of interest:
@@ -20,19 +18,6 @@ Logs can be found a couple of places:
2018

2119
For some pre-defined queries, click `Queries`, then `Group by: Query type`, and look under `Query pack queries`.
2220

23-
#### [Azure Monitor Logs](https://docs.microsoft.com/en-us/azure/azure-monitor/logs/data-platform-logs)
24-
25-
[Open the `Logs` for the environment you are interested in.](https://docs.google.com/document/d/11EPDIROBvg7cRtU2V42c6VBxcW_o8HhcyORALNtL_XY/edit#heading=h.n0oq4r1jo7zs)
26-
27-
The following [tables](https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-python#telemetry-type-mappings) are likely of interest:
28-
29-
- `requests`
30-
- `traces`
31-
32-
In the latter two, you should see recent log output. Note [there is some latency](https://docs.microsoft.com/en-us/azure/azure-monitor/logs/data-ingestion-time).
33-
34-
Note that we aren't [sending exceptions to Azure Monitor](https://learn.microsoft.com/en-us/azure/azure-monitor/app/opencensus-python#send-exceptions) (aside from the logs), so you won't see anything show up under `Failures` or `Logs`->`exceptions`.
35-
3621
#### Live tail
3722

3823
After [setting up the Azure CLI](#making-changes), you can use the following command to [stream live logs](https://docs.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs#in-local-terminal):

tests/pytest/test_logging.py

-13
This file was deleted.

0 commit comments

Comments
 (0)