django-prometheus 2.5.0.dev7__tar.gz → 2.5.0.dev12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_prometheus-2.5.0.dev7/django_prometheus.egg-info → django_prometheus-2.5.0.dev12}/PKG-INFO +3 -2
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/__init__.py +1 -1
- django_prometheus-2.5.0.dev12/django_prometheus/db/backends/postgis/base.py +16 -0
- django_prometheus-2.5.0.dev12/django_prometheus/db/backends/postgresql/base.py +16 -0
- django_prometheus-2.5.0.dev12/django_prometheus/tests/test_db_wrapper.py +192 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12/django_prometheus.egg-info}/PKG-INFO +3 -2
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus.egg-info/SOURCES.txt +1 -0
- django_prometheus-2.5.0.dev12/django_prometheus.egg-info/requires.txt +2 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/setup.py +2 -1
- django_prometheus-2.5.0.dev7/django_prometheus/db/backends/postgis/base.py +0 -21
- django_prometheus-2.5.0.dev7/django_prometheus/db/backends/postgresql/base.py +0 -21
- django_prometheus-2.5.0.dev7/django_prometheus.egg-info/requires.txt +0 -2
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/LICENSE +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/MANIFEST.in +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/README.md +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/apps.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/backends/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/backends/django_memcached_consul.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/backends/filebased.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/backends/locmem.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/backends/memcached.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/backends/redis.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/metrics.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/conf/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/backends/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/backends/mysql/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/backends/mysql/base.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/backends/postgis/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/backends/postgresql/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/backends/spatialite/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/backends/spatialite/base.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/backends/sqlite3/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/backends/sqlite3/base.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/common.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/metrics.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/exports.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/middleware.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/migrations.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/models.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/tests/__init__.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/tests/test_django_prometheus.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/tests/test_exports.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/tests/test_testutils.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/testutils.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/urls.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/utils.py +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus.egg-info/dependency_links.txt +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus.egg-info/top_level.txt +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/pyproject.toml +0 -0
- {django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/setup.cfg +0 -0
{django_prometheus-2.5.0.dev7/django_prometheus.egg-info → django_prometheus-2.5.0.dev12}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: django-prometheus
|
|
3
|
-
Version: 2.5.0.
|
|
3
|
+
Version: 2.5.0.dev12
|
|
4
4
|
Summary: Django middlewares to monitor your application with Prometheus.io.
|
|
5
5
|
Home-page: http://github.com/korfuri/django-prometheus
|
|
6
6
|
Author: Uriel Corfa
|
|
@@ -26,11 +26,12 @@ Classifier: Programming Language :: Python :: Free Threading
|
|
|
26
26
|
Classifier: Framework :: Django :: 4.2
|
|
27
27
|
Classifier: Framework :: Django :: 5.1
|
|
28
28
|
Classifier: Framework :: Django :: 5.2
|
|
29
|
+
Classifier: Framework :: Django :: 6.0
|
|
29
30
|
Classifier: Topic :: System :: Monitoring
|
|
30
31
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
31
32
|
Description-Content-Type: text/markdown
|
|
32
33
|
License-File: LICENSE
|
|
33
|
-
Requires-Dist: Django!=5.0.*,<
|
|
34
|
+
Requires-Dist: Django!=5.0.*,<6.1,>=4.2
|
|
34
35
|
Requires-Dist: prometheus-client>=0.7
|
|
35
36
|
|
|
36
37
|
# django-prometheus
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from django.contrib.gis.db.backends.postgis import base
|
|
2
|
+
|
|
3
|
+
from django_prometheus.db.common import DatabaseWrapperMixin, ExportingCursorWrapper
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DatabaseWrapper(DatabaseWrapperMixin, base.DatabaseWrapper):
|
|
7
|
+
def get_connection_params(self):
|
|
8
|
+
conn_params = super().get_connection_params()
|
|
9
|
+
conn_params["cursor_factory"] = ExportingCursorWrapper(conn_params["cursor_factory"], self.alias, self.vendor)
|
|
10
|
+
return conn_params
|
|
11
|
+
|
|
12
|
+
def create_cursor(self, name=None):
|
|
13
|
+
# cursor_factory is set in get_connection_params() so psycopg already
|
|
14
|
+
# creates instrumented cursors. Delegate to Django's implementation to
|
|
15
|
+
# avoid the mixin's create_cursor which is incompatible with psycopg3.
|
|
16
|
+
return base.DatabaseWrapper.create_cursor(self, name=name)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from django.db.backends.postgresql import base
|
|
2
|
+
|
|
3
|
+
from django_prometheus.db.common import DatabaseWrapperMixin, ExportingCursorWrapper
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DatabaseWrapper(DatabaseWrapperMixin, base.DatabaseWrapper):
|
|
7
|
+
def get_connection_params(self):
|
|
8
|
+
conn_params = super().get_connection_params()
|
|
9
|
+
conn_params["cursor_factory"] = ExportingCursorWrapper(conn_params["cursor_factory"], self.alias, self.vendor)
|
|
10
|
+
return conn_params
|
|
11
|
+
|
|
12
|
+
def create_cursor(self, name=None):
|
|
13
|
+
# cursor_factory is set in get_connection_params() so psycopg already
|
|
14
|
+
# creates instrumented cursors. Delegate to Django's implementation to
|
|
15
|
+
# avoid the mixin's create_cursor which is incompatible with psycopg3.
|
|
16
|
+
return base.DatabaseWrapper.create_cursor(self, name=name)
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"""Tests for the PostgreSQL and PostGIS database backend wrappers.
|
|
2
|
+
|
|
3
|
+
Verifies that cursor_factory wrapping works correctly and does not
|
|
4
|
+
re-wrap when connections are reused from a pool (issue #445).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from unittest.mock import MagicMock, patch
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
from django_prometheus.db.common import ExportingCursorWrapper
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from django.contrib.gis.gdal import libgdal # noqa: F401
|
|
15
|
+
|
|
16
|
+
_has_gdal = True
|
|
17
|
+
except Exception:
|
|
18
|
+
_has_gdal = False
|
|
19
|
+
|
|
20
|
+
import os
|
|
21
|
+
|
|
22
|
+
_can_import_postgis_backend = False
|
|
23
|
+
if os.environ.get("DJANGO_SETTINGS_MODULE"):
|
|
24
|
+
try:
|
|
25
|
+
import django.contrib.gis.db.backends.postgis.base # noqa: F401
|
|
26
|
+
|
|
27
|
+
_can_import_postgis_backend = True
|
|
28
|
+
except Exception:
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class DummyCursor:
|
|
33
|
+
"""A stand-in cursor class used as the base cursor_factory."""
|
|
34
|
+
|
|
35
|
+
def execute(self, *args, **kwargs):
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
def executemany(self, query, param_list, *args, **kwargs):
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class TestExportingCursorWrapper:
|
|
43
|
+
def test_wraps_cursor_class(self):
|
|
44
|
+
"""ExportingCursorWrapper returns a subclass of the given cursor class."""
|
|
45
|
+
wrapped = ExportingCursorWrapper(DummyCursor, "default", "postgresql")
|
|
46
|
+
assert issubclass(wrapped, DummyCursor)
|
|
47
|
+
|
|
48
|
+
def test_double_wrapping_increases_mro(self):
|
|
49
|
+
"""Wrapping an already-wrapped class creates deeper inheritance.
|
|
50
|
+
|
|
51
|
+
This is the root cause of #445: each re-wrap adds a layer to the
|
|
52
|
+
MRO, so execute() traverses more super() calls over time.
|
|
53
|
+
"""
|
|
54
|
+
wrapped_once = ExportingCursorWrapper(DummyCursor, "default", "postgresql")
|
|
55
|
+
wrapped_twice = ExportingCursorWrapper(wrapped_once, "default", "postgresql")
|
|
56
|
+
assert len(wrapped_twice.__mro__) > len(wrapped_once.__mro__)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class TestPostgresqlGetConnectionParams:
|
|
60
|
+
"""Test that the postgresql backend wraps cursor_factory in get_connection_params."""
|
|
61
|
+
|
|
62
|
+
def _make_wrapper(self):
|
|
63
|
+
"""Create a DatabaseWrapper instance with mocked internals."""
|
|
64
|
+
from django_prometheus.db.backends.postgresql import base as pg_base
|
|
65
|
+
|
|
66
|
+
wrapper = pg_base.DatabaseWrapper.__new__(pg_base.DatabaseWrapper)
|
|
67
|
+
wrapper.alias = "default"
|
|
68
|
+
wrapper.vendor = "postgresql"
|
|
69
|
+
return wrapper
|
|
70
|
+
|
|
71
|
+
@patch("django.db.backends.postgresql.base.DatabaseWrapper.get_connection_params")
|
|
72
|
+
def test_wraps_cursor_factory(self, mock_super_params):
|
|
73
|
+
mock_super_params.return_value = {"cursor_factory": DummyCursor}
|
|
74
|
+
wrapper = self._make_wrapper()
|
|
75
|
+
|
|
76
|
+
params = wrapper.get_connection_params()
|
|
77
|
+
|
|
78
|
+
assert params["cursor_factory"] is not DummyCursor
|
|
79
|
+
assert issubclass(params["cursor_factory"], DummyCursor)
|
|
80
|
+
|
|
81
|
+
@patch("django.db.backends.postgresql.base.DatabaseWrapper.get_connection_params")
|
|
82
|
+
def test_wrapping_is_single_layer(self, mock_super_params):
|
|
83
|
+
"""Calling get_connection_params() always wraps the base cursor class,
|
|
84
|
+
not a previously wrapped one, because super() returns the original params.
|
|
85
|
+
|
|
86
|
+
With connection pooling, get_connection_params() is called once at pool
|
|
87
|
+
creation, so the cursor_factory is wrapped exactly once per pool.
|
|
88
|
+
"""
|
|
89
|
+
mock_super_params.side_effect = lambda: {"cursor_factory": DummyCursor}
|
|
90
|
+
wrapper = self._make_wrapper()
|
|
91
|
+
|
|
92
|
+
params_first = wrapper.get_connection_params()
|
|
93
|
+
params_second = wrapper.get_connection_params()
|
|
94
|
+
|
|
95
|
+
# Both calls produce the same MRO depth because super() always
|
|
96
|
+
# returns the unwrapped DummyCursor as the base.
|
|
97
|
+
assert len(params_first["cursor_factory"].__mro__) == len(params_second["cursor_factory"].__mro__)
|
|
98
|
+
|
|
99
|
+
@patch("django.db.backends.postgresql.base.DatabaseWrapper.get_new_connection")
|
|
100
|
+
def test_get_new_connection_does_not_rewrap(self, mock_super_conn):
|
|
101
|
+
"""get_new_connection() no longer modifies cursor_factory on the
|
|
102
|
+
connection, so pooled connections are not re-wrapped.
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
mock_conn = MagicMock()
|
|
106
|
+
already_wrapped = ExportingCursorWrapper(DummyCursor, "default", "postgresql")
|
|
107
|
+
mock_conn.cursor_factory = already_wrapped
|
|
108
|
+
mock_super_conn.return_value = mock_conn
|
|
109
|
+
|
|
110
|
+
wrapper = self._make_wrapper()
|
|
111
|
+
conn = wrapper.get_new_connection({})
|
|
112
|
+
|
|
113
|
+
# cursor_factory should be untouched — still the same class
|
|
114
|
+
assert conn.cursor_factory is already_wrapped
|
|
115
|
+
|
|
116
|
+
@patch("django.db.backends.postgresql.base.DatabaseWrapper.create_cursor")
|
|
117
|
+
def test_create_cursor_delegates_to_django(self, mock_django_create_cursor):
|
|
118
|
+
"""create_cursor() delegates to Django's base implementation,
|
|
119
|
+
not the mixin's version which is incompatible with psycopg3.
|
|
120
|
+
"""
|
|
121
|
+
mock_django_create_cursor.return_value = MagicMock()
|
|
122
|
+
wrapper = self._make_wrapper()
|
|
123
|
+
|
|
124
|
+
wrapper.create_cursor(name=None)
|
|
125
|
+
|
|
126
|
+
# Called as an unbound method: base.DatabaseWrapper.create_cursor(self, name=None)
|
|
127
|
+
mock_django_create_cursor.assert_called_once_with(wrapper, name=None)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@pytest.mark.skipif(
|
|
131
|
+
not _has_gdal or not _can_import_postgis_backend,
|
|
132
|
+
reason="PostGIS tests require GDAL and a fully configured Django environment",
|
|
133
|
+
)
|
|
134
|
+
class TestPostgisGetConnectionParams:
|
|
135
|
+
"""Test that the postgis backend wraps cursor_factory in get_connection_params."""
|
|
136
|
+
|
|
137
|
+
def _get_django_postgis_dbwrapper(self):
|
|
138
|
+
"""Return the Django PostGIS DatabaseWrapper class for patch.object()."""
|
|
139
|
+
from django.contrib.gis.db.backends.postgis.base import DatabaseWrapper
|
|
140
|
+
|
|
141
|
+
return DatabaseWrapper
|
|
142
|
+
|
|
143
|
+
def _make_wrapper(self):
|
|
144
|
+
"""Create a PostGIS DatabaseWrapper instance with mocked internals."""
|
|
145
|
+
from django_prometheus.db.backends.postgis import base as gis_base
|
|
146
|
+
|
|
147
|
+
wrapper = gis_base.DatabaseWrapper.__new__(gis_base.DatabaseWrapper)
|
|
148
|
+
wrapper.alias = "geo_db"
|
|
149
|
+
wrapper.vendor = "postgresql"
|
|
150
|
+
return wrapper
|
|
151
|
+
|
|
152
|
+
def test_wraps_cursor_factory(self):
|
|
153
|
+
with patch.object(self._get_django_postgis_dbwrapper(), "get_connection_params") as mock_super_params:
|
|
154
|
+
mock_super_params.return_value = {"cursor_factory": DummyCursor}
|
|
155
|
+
wrapper = self._make_wrapper()
|
|
156
|
+
|
|
157
|
+
params = wrapper.get_connection_params()
|
|
158
|
+
|
|
159
|
+
assert params["cursor_factory"] is not DummyCursor
|
|
160
|
+
assert issubclass(params["cursor_factory"], DummyCursor)
|
|
161
|
+
|
|
162
|
+
def test_wrapping_is_single_layer(self):
|
|
163
|
+
"""Each call wraps the original cursor class, not a previously wrapped one."""
|
|
164
|
+
with patch.object(self._get_django_postgis_dbwrapper(), "get_connection_params") as mock_super_params:
|
|
165
|
+
mock_super_params.side_effect = lambda: {"cursor_factory": DummyCursor}
|
|
166
|
+
wrapper = self._make_wrapper()
|
|
167
|
+
|
|
168
|
+
params_first = wrapper.get_connection_params()
|
|
169
|
+
params_second = wrapper.get_connection_params()
|
|
170
|
+
|
|
171
|
+
assert len(params_first["cursor_factory"].__mro__) == len(params_second["cursor_factory"].__mro__)
|
|
172
|
+
|
|
173
|
+
def test_uses_self_alias(self):
|
|
174
|
+
"""The postgis backend uses self.alias, not a hardcoded string."""
|
|
175
|
+
with patch.object(self._get_django_postgis_dbwrapper(), "get_connection_params") as mock_super_params:
|
|
176
|
+
mock_super_params.return_value = {"cursor_factory": DummyCursor}
|
|
177
|
+
wrapper = self._make_wrapper()
|
|
178
|
+
|
|
179
|
+
with patch("django_prometheus.db.common.ExportingCursorWrapper") as mock_ecw:
|
|
180
|
+
mock_ecw.return_value = DummyCursor
|
|
181
|
+
wrapper.get_connection_params()
|
|
182
|
+
mock_ecw.assert_called_once_with(DummyCursor, "geo_db", "postgresql")
|
|
183
|
+
|
|
184
|
+
def test_create_cursor_delegates_to_django(self):
|
|
185
|
+
"""create_cursor() delegates to Django's postgis base implementation."""
|
|
186
|
+
with patch.object(self._get_django_postgis_dbwrapper(), "create_cursor") as mock_django_create_cursor:
|
|
187
|
+
mock_django_create_cursor.return_value = MagicMock()
|
|
188
|
+
wrapper = self._make_wrapper()
|
|
189
|
+
|
|
190
|
+
wrapper.create_cursor(name=None)
|
|
191
|
+
|
|
192
|
+
mock_django_create_cursor.assert_called_once_with(wrapper, name=None)
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12/django_prometheus.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: django-prometheus
|
|
3
|
-
Version: 2.5.0.
|
|
3
|
+
Version: 2.5.0.dev12
|
|
4
4
|
Summary: Django middlewares to monitor your application with Prometheus.io.
|
|
5
5
|
Home-page: http://github.com/korfuri/django-prometheus
|
|
6
6
|
Author: Uriel Corfa
|
|
@@ -26,11 +26,12 @@ Classifier: Programming Language :: Python :: Free Threading
|
|
|
26
26
|
Classifier: Framework :: Django :: 4.2
|
|
27
27
|
Classifier: Framework :: Django :: 5.1
|
|
28
28
|
Classifier: Framework :: Django :: 5.2
|
|
29
|
+
Classifier: Framework :: Django :: 6.0
|
|
29
30
|
Classifier: Topic :: System :: Monitoring
|
|
30
31
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
31
32
|
Description-Content-Type: text/markdown
|
|
32
33
|
License-File: LICENSE
|
|
33
|
-
Requires-Dist: Django!=5.0.*,<
|
|
34
|
+
Requires-Dist: Django!=5.0.*,<6.1,>=4.2
|
|
34
35
|
Requires-Dist: prometheus-client>=0.7
|
|
35
36
|
|
|
36
37
|
# django-prometheus
|
|
@@ -42,6 +42,7 @@ django_prometheus/db/backends/spatialite/base.py
|
|
|
42
42
|
django_prometheus/db/backends/sqlite3/__init__.py
|
|
43
43
|
django_prometheus/db/backends/sqlite3/base.py
|
|
44
44
|
django_prometheus/tests/__init__.py
|
|
45
|
+
django_prometheus/tests/test_db_wrapper.py
|
|
45
46
|
django_prometheus/tests/test_django_prometheus.py
|
|
46
47
|
django_prometheus/tests/test_exports.py
|
|
47
48
|
django_prometheus/tests/test_testutils.py
|
|
@@ -45,7 +45,7 @@ setup(
|
|
|
45
45
|
setup_requires=["pytest-runner"],
|
|
46
46
|
options={"bdist_wheel": {"universal": "1"}},
|
|
47
47
|
install_requires=[
|
|
48
|
-
"Django>=4.2,<
|
|
48
|
+
"Django>=4.2,<6.1,!=5.0.*",
|
|
49
49
|
"prometheus-client>=0.7",
|
|
50
50
|
],
|
|
51
51
|
classifiers=[
|
|
@@ -64,6 +64,7 @@ setup(
|
|
|
64
64
|
"Framework :: Django :: 4.2",
|
|
65
65
|
"Framework :: Django :: 5.1",
|
|
66
66
|
"Framework :: Django :: 5.2",
|
|
67
|
+
"Framework :: Django :: 6.0",
|
|
67
68
|
"Topic :: System :: Monitoring",
|
|
68
69
|
"License :: OSI Approved :: Apache Software License",
|
|
69
70
|
],
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from django.contrib.gis.db.backends.postgis import base
|
|
2
|
-
from django.db.backends.postgresql.base import Cursor
|
|
3
|
-
|
|
4
|
-
from django_prometheus.db.common import DatabaseWrapperMixin, ExportingCursorWrapper
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class DatabaseWrapper(DatabaseWrapperMixin, base.DatabaseWrapper):
|
|
8
|
-
def get_new_connection(self, *args, **kwargs):
|
|
9
|
-
conn = super().get_new_connection(*args, **kwargs)
|
|
10
|
-
conn.cursor_factory = ExportingCursorWrapper(
|
|
11
|
-
conn.cursor_factory or Cursor(),
|
|
12
|
-
"postgis",
|
|
13
|
-
self.vendor,
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
return conn
|
|
17
|
-
|
|
18
|
-
def create_cursor(self, name=None):
|
|
19
|
-
# cursor_factory is a kwarg to connect() so restore create_cursor()'s
|
|
20
|
-
# default behavior
|
|
21
|
-
return base.DatabaseWrapper.create_cursor(self, name=name)
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from django.db.backends.postgresql import base
|
|
2
|
-
from django.db.backends.postgresql.base import Cursor
|
|
3
|
-
|
|
4
|
-
from django_prometheus.db.common import DatabaseWrapperMixin, ExportingCursorWrapper
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class DatabaseWrapper(DatabaseWrapperMixin, base.DatabaseWrapper):
|
|
8
|
-
def get_new_connection(self, *args, **kwargs):
|
|
9
|
-
conn = super().get_new_connection(*args, **kwargs)
|
|
10
|
-
conn.cursor_factory = ExportingCursorWrapper(
|
|
11
|
-
conn.cursor_factory or Cursor(),
|
|
12
|
-
self.alias,
|
|
13
|
-
self.vendor,
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
return conn
|
|
17
|
-
|
|
18
|
-
def create_cursor(self, name=None):
|
|
19
|
-
# cursor_factory is a kwarg to connect() so restore create_cursor()'s
|
|
20
|
-
# default behavior
|
|
21
|
-
return base.DatabaseWrapper.create_cursor(self, name=name)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/cache/metrics.py
RENAMED
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/conf/__init__.py
RENAMED
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/common.py
RENAMED
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/db/metrics.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/middleware.py
RENAMED
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/migrations.py
RENAMED
|
File without changes
|
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/tests/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_prometheus-2.5.0.dev7 → django_prometheus-2.5.0.dev12}/django_prometheus/testutils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|