Skip to content

Commit

Permalink
chore(Azure): remove Azure error monitoring
Browse files Browse the repository at this point in the history
Wasn't working anyway.
  • Loading branch information
afeld committed Feb 11, 2023
1 parent f97a4c6 commit 522d448
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
15 changes: 0 additions & 15 deletions benefits/core/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,6 @@ def process_view(self, request, view_func, view_args, view_kwargs):
return redirect("oauth:login")


# https://github.com/census-instrumentation/opencensus-python/issues/766
class LogErrorToAzure(MiddlewareMixin):
def __init__(self, get_response):
self.get_response = get_response
# wait to do this here to be sure the handler is initialized
self.azure_logger = logging.getLogger("azure")

def process_exception(self, request, exception):
# https://stackoverflow.com/a/45532289
msg = getattr(exception, "message", repr(exception))
self.azure_logger.exception(msg, exc_info=exception)

return None


class RecaptchaEnabled(MiddlewareMixin):
"""Middleware configures the request with required reCAPTCHA settings."""

Expand Down
7 changes: 1 addition & 6 deletions benefits/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ def _filter_empty(ls):
ENABLE_AZURE_INSIGHTS = "APPLICATIONINSIGHTS_CONNECTION_STRING" in os.environ
print("ENABLE_AZURE_INSIGHTS: ", ENABLE_AZURE_INSIGHTS)
if ENABLE_AZURE_INSIGHTS:
MIDDLEWARE.extend(
[
"opencensus.ext.django.middleware.OpencensusMiddleware",
"benefits.core.middleware.LogErrorToAzure",
]
)
MIDDLEWARE.append("opencensus.ext.django.middleware.OpencensusMiddleware")

# only used if enabled above
OPENCENSUS = {
Expand Down
2 changes: 1 addition & 1 deletion docs/deployment/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The following [tables](https://docs.microsoft.com/en-us/azure/azure-monitor/app/

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).

See [`Failures`](https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-exceptions#diagnose-failures-using-the-azure-portal) in the sidebar (or `exceptions` under `Logs`) for application errors/exceptions.
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`.

### Live tail

Expand Down

0 comments on commit 522d448

Please sign in to comment.