Skip to content

Commit 62fcaf4

Browse files
authored
Fix CI - remove old versions (Django & python) - pin ubuntu in CI (#354)
1 parent 1733888 commit 62fcaf4

File tree

10 files changed

+31
-66
lines changed

10 files changed

+31
-66
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
16-
os: [ubuntu-latest]
15+
python-version: ["3.7", "3.8", "3.9", "3.10"]
16+
os: [ubuntu-20.04]
1717
runs-on: ${{ matrix.os }}
1818
name: "${{ matrix.os }} Python: ${{ matrix.python-version }}"
1919
services:
@@ -48,7 +48,7 @@ jobs:
4848
- name: Install dependencies
4949
run: |
5050
pip install -U "pip>=21.1"
51-
pip install -U setuptools "tox>=3.23.0,<4" codecov tox-gh-actions coverage
51+
pip install -U setuptools "tox-gh-actions==2.12.0" coverage
5252
sudo apt-get update
5353
sudo apt-get install binutils libproj-dev gdal-bin libmemcached-dev
5454
- name: Log versions

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ Export Django monitoring metrics for Prometheus.io
1515
This library provides Prometheus metrics for Django related operations:
1616

1717
* Requests & Responses
18-
* Database access done via [Django ORM](https://docs.djangoproject.com/en/3.0/topics/db/)
19-
* Cache access done via [Django Cache framework](https://docs.djangoproject.com/en/3.0/topics/cache/)
18+
* Database access done via [Django ORM](https://docs.djangoproject.com/en/3.2/topics/db/)
19+
* Cache access done via [Django Cache framework](https://docs.djangoproject.com/en/3.2/topics/cache/)
2020

2121
## Usage
2222

2323
### Requirements
2424

25-
* Django >= 2.2
25+
* Django >= 3.2
26+
* Python 3.7 and above.
2627

2728
### Installation
2829

@@ -73,12 +74,13 @@ urlpatterns = [
7374

7475
Prometheus uses Histogram based grouping for monitoring latencies. The default
7576
buckets are:
77+
7678
```python
7779
PROMETHEUS_LATENCY_BUCKETS = (0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0, 25.0, 50.0, 75.0, float("inf"),)
7880
```
7981

8082
You can define custom buckets for latency, adding more buckets decreases performance but
81-
increases accuracy: https://prometheus.io/docs/practices/histograms/
83+
increases accuracy: <https://prometheus.io/docs/practices/histograms/>
8284

8385
```python
8486
PROMETHEUS_LATENCY_BUCKETS = (.1, .2, .5, .6, .8, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.5, 9.0, 12.0, 15.0, 20.0, 30.0, float("inf"))

django_prometheus/cache/backends/memcached.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django import VERSION as DJANGO_VERSION
21
from django.core.cache.backends import memcached
32

43
from django_prometheus.cache.metrics import (
@@ -19,20 +18,13 @@ def get(self, key, default=None, version=None):
1918
return cached or default
2019

2120

22-
class MemcachedCache(MemcachedPrometheusCacheMixin, memcached.MemcachedCache):
21+
class PyLibMCCache(MemcachedPrometheusCacheMixin, memcached.PyLibMCCache):
2322
"""Inherit memcached to add metrics about hit/miss ratio"""
2423

2524
pass
2625

2726

28-
if DJANGO_VERSION >= (3, 2):
29-
30-
class PyLibMCCache(MemcachedPrometheusCacheMixin, memcached.PyLibMCCache):
31-
"""Inherit memcached to add metrics about hit/miss ratio"""
32-
33-
pass
34-
35-
class PyMemcacheCache(MemcachedPrometheusCacheMixin, memcached.PyMemcacheCache):
36-
"""Inherit memcached to add metrics about hit/miss ratio"""
27+
class PyMemcacheCache(MemcachedPrometheusCacheMixin, memcached.PyMemcacheCache):
28+
"""Inherit memcached to add metrics about hit/miss ratio"""
3729

38-
pass
30+
pass

django_prometheus/conf/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@
2424

2525
if settings.configured:
2626
NAMESPACE = getattr(settings, "PROMETHEUS_METRIC_NAMESPACE", NAMESPACE)
27-
PROMETHEUS_LATENCY_BUCKETS = getattr(settings, "PROMETHEUS_LATENCY_BUCKETS", PROMETHEUS_LATENCY_BUCKETS)
27+
PROMETHEUS_LATENCY_BUCKETS = getattr(
28+
settings, "PROMETHEUS_LATENCY_BUCKETS", PROMETHEUS_LATENCY_BUCKETS
29+
)

django_prometheus/middleware.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django.conf import settings
21
from django.utils.deprecation import MiddlewareMixin
32
from prometheus_client import Counter, Histogram
43

django_prometheus/tests/end2end/testapp/settings.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import tempfile
33

4-
from django import VERSION as DJANGO_VERSION
54
from testapp.helpers import get_middleware
65

76
# SECURITY WARNING: keep the secret key used in production secret!
@@ -97,11 +96,15 @@
9796

9897
CACHES = {
9998
"default": {
100-
"BACKEND": "django_prometheus.cache.backends.memcached.MemcachedCache",
99+
"BACKEND": "django_prometheus.cache.backends.memcached.PyLibMCCache",
100+
"LOCATION": "localhost:11211",
101+
},
102+
"memcached.PyLibMCCache": {
103+
"BACKEND": "django_prometheus.cache.backends.memcached.PyLibMCCache",
101104
"LOCATION": "localhost:11211",
102105
},
103-
"memcached.MemcachedCache": {
104-
"BACKEND": "django_prometheus.cache.backends.memcached.MemcachedCache",
106+
"memcached.PyMemcacheCache": {
107+
"BACKEND": "django_prometheus.cache.backends.memcached.PyMemcacheCache",
105108
"LOCATION": "localhost:11211",
106109
},
107110
"filebased": {
@@ -129,16 +132,6 @@
129132
}
130133

131134

132-
if DJANGO_VERSION >= (3, 2):
133-
CACHES["memcached.PyLibMCCache"] = {
134-
"BACKEND": "django_prometheus.cache.backends.memcached.PyLibMCCache",
135-
"LOCATION": "localhost:11211",
136-
}
137-
CACHES["memcached.PyMemcacheCache"] = {
138-
"BACKEND": "django_prometheus.cache.backends.memcached.PyMemcacheCache",
139-
"LOCATION": "localhost:11211",
140-
}
141-
142135
# Internationalization
143136
LANGUAGE_CODE = "en-us"
144137
TIME_ZONE = "UTC"

django_prometheus/tests/end2end/testapp/test_caches.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from django import VERSION as DJANGO_VERSION
21
from django.core.cache import caches
32
from django.test import TestCase
43
from redis import RedisError
@@ -11,20 +10,13 @@ class TestCachesMetrics(PrometheusTestCaseMixin, TestCase):
1110

1211
def testCounters(self):
1312
supported_caches = [
14-
"memcached.MemcachedCache",
13+
"memcached.PyLibMCCache",
14+
"memcached.PyMemcacheCache",
1515
"filebased",
1616
"locmem",
1717
"redis",
1818
]
1919

20-
if DJANGO_VERSION >= (3, 2):
21-
supported_caches.extend(
22-
[
23-
"memcached.PyLibMCCache",
24-
"memcached.PyMemcacheCache",
25-
]
26-
)
27-
2820
# Note: those tests require a memcached server running
2921
for supported_cache in supported_caches:
3022
tested_cache = caches[supported_cache]
@@ -115,20 +107,13 @@ def test_redis_cache_fail(self):
115107

116108
def test_cache_version_support(self):
117109
supported_caches = [
118-
"memcached.MemcachedCache",
110+
"memcached.PyLibMCCache",
111+
"memcached.PyMemcacheCache",
119112
"filebased",
120113
"locmem",
121114
"redis",
122115
]
123116

124-
if DJANGO_VERSION >= (3, 2):
125-
supported_caches.extend(
126-
[
127-
"memcached.PyLibMCCache",
128-
"memcached.PyMemcacheCache",
129-
]
130-
)
131-
132117
# Note: those tests require a memcached server running
133118
for supported_cache in supported_caches:
134119
tested_cache = caches[supported_cache]

django_prometheus/tests/end2end/testapp/test_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_exception_latency_histograms(self):
138138
registry,
139139
2,
140140
M("requests_latency_seconds_by_view_method_bucket"),
141-
le="2.0",
141+
le="2.5",
142142
view="testapp.views.objection",
143143
method="GET",
144144
)

pyproject.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,19 @@ include_trailing_comma = true
1515
[tool.tox]
1616
legacy_tox_ini = """
1717
[tox]
18-
envlist = {py36,py37,py38,py39,py310}-django{220,300,310,320}-{end2end,unittests},{py38,py39,py310}-django-400-{end2end,unittests},py38-lint
18+
envlist = {py37,py38,py39,py310}-django{320}-{end2end,unittests},{py38,py39,py310}-django{400}-{end2end,unittests},py38-lint
1919
2020
[gh-actions]
2121
python =
22-
3.6: py36
2322
3.7: py37
2423
3.8: py38, py38-lint
2524
3.9: py39
2625
3.10: py310
2726
2827
[testenv]
2928
deps =
30-
django220: Django>=2.2,<2.3
31-
django300: Django>=3.0,<3.1
32-
django310: Django>=3.1,<3.2
3329
django320: Django>=3.2,<3.3
34-
django4: Django==4.0
30+
django400: Django>=4.0,<4.1
3531
coverage
3632
-rrequirements.txt
3733
skip_missing_interpreters=true
@@ -48,7 +44,7 @@ commands =
4844
4945
[testenv:py38-lint]
5046
deps =
51-
black
47+
black==22.6.0
5248
flake8
5349
isort>=5.5.4,<6
5450
flake8-debugger

setup.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,10 @@ def get_version():
5151
"Intended Audience :: Information Technology",
5252
"Intended Audience :: System Administrators",
5353
"Programming Language :: Python :: 3",
54-
"Programming Language :: Python :: 3.6",
5554
"Programming Language :: Python :: 3.7",
5655
"Programming Language :: Python :: 3.8",
5756
"Programming Language :: Python :: 3.9",
5857
"Programming Language :: Python :: 3.10",
59-
"Framework :: Django :: 2.2",
60-
"Framework :: Django :: 3.0",
61-
"Framework :: Django :: 3.1",
6258
"Framework :: Django :: 3.2",
6359
"Framework :: Django :: 4.0",
6460
"Topic :: System :: Monitoring",

0 commit comments

Comments
 (0)