![dependabot[bot]](/assets/img/avatar_default.png)
* core: bump django from 4.1.7 to 4.2 Bumps [django](https://github.com/django/django) from 4.1.7 to 4.2. - [Release notes](https://github.com/django/django/releases) - [Commits](https://github.com/django/django/compare/4.1.7...4.2) --- updated-dependencies: - dependency-name: django dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * upgrade to psycopg3, use custom engine for prometheus metrics See https://github.com/korfuri/django-prometheus/issues/350 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * make scripts use pscopg3 Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
22 lines
866 B
Python
22 lines
866 B
Python
"""Database engine that uses prometheus exporter"""
|
|
from django.db.backends.postgresql import base
|
|
from django_prometheus.db.common import DatabaseWrapperMixin, ExportingCursorWrapper
|
|
|
|
|
|
class DatabaseFeatures(base.DatabaseFeatures):
|
|
"""Our database has the exact same features as the base one."""
|
|
|
|
|
|
class DatabaseWrapper(DatabaseWrapperMixin, base.DatabaseWrapper):
|
|
"""Database wrapper which exports metrics to prometheus"""
|
|
|
|
def get_connection_params(self):
|
|
conn_params = super().get_connection_params()
|
|
conn_params["cursor_factory"] = ExportingCursorWrapper(base.Cursor, self.alias, self.vendor)
|
|
return conn_params
|
|
|
|
def create_cursor(self, name=None):
|
|
# cursor_factory is a kwarg to connect() so restore create_cursor()'s
|
|
# default behavior
|
|
return base.DatabaseWrapper.create_cursor(self, name=name)
|