Skip to content
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

Fix Metrics for Oracle DPI errors #3944

Merged
merged 1 commit into from
Jan 8, 2025
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
6 changes: 3 additions & 3 deletions apps/useradmin/src/useradmin/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from datetime import datetime, timedelta

from django.db import connection
from django.db.utils import OperationalError
from django.db.utils import DatabaseError, OperationalError
from prometheus_client import Gauge

from desktop.lib.metrics import global_registry
Expand All @@ -35,7 +35,7 @@ def active_users():
first_login=False,
hostname__isnull=False
).count()
except OperationalError as oe:
except (OperationalError, DatabaseError) as oe:
LOG.debug('active_users recovering from %s' % str(oe))
connection.close()
connection.connect()
Expand Down Expand Up @@ -67,7 +67,7 @@ def active_users_per_instance():
try:
count = UserProfile.objects.filter(last_activity__gt=datetime.now() - timedelta(hours=1),
hostname=get_localhost_name()).count()
except OperationalError as oe:
except (OperationalError, DatabaseError) as oe:
LOG.debug('active_users_per_instance recovering from %s' % str(oe))
connection.close()
connection.connect()
Expand Down
6 changes: 3 additions & 3 deletions desktop/core/src/desktop/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from datetime import datetime, timedelta

from django.db import connection
from django.db.utils import OperationalError
from django.db.utils import DatabaseError, OperationalError
from future import standard_library
from prometheus_client import REGISTRY, Gauge

Expand Down Expand Up @@ -149,7 +149,7 @@ def user_count():
users = 0
try:
users = User.objects.count()
except OperationalError as oe:
except (OperationalError, DatabaseError) as oe:
LOG.debug('user_count recovering from %s' % str(oe))
connection.close()
connection.connect()
Expand Down Expand Up @@ -207,7 +207,7 @@ def num_of_queries():
is_history=True,
last_modified__gt=datetime.now() - timedelta(minutes=10)
).count()
except OperationalError as oe:
except (OperationalError, DatabaseError) as oe:
LOG.debug('num_of_queries recovering from %s' % str(oe))
connection.close()
connection.connect()
Expand Down
Loading