kinto 20.4.0__py3-none-any.whl → 20.5.0__py3-none-any.whl
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.
Potentially problematic release.
This version of kinto might be problematic. Click here for more details.
- kinto/plugins/prometheus.py +25 -1
- {kinto-20.4.0.dist-info → kinto-20.5.0.dist-info}/METADATA +1 -1
- {kinto-20.4.0.dist-info → kinto-20.5.0.dist-info}/RECORD +7 -7
- {kinto-20.4.0.dist-info → kinto-20.5.0.dist-info}/WHEEL +0 -0
- {kinto-20.4.0.dist-info → kinto-20.5.0.dist-info}/entry_points.txt +0 -0
- {kinto-20.4.0.dist-info → kinto-20.5.0.dist-info}/licenses/LICENSE +0 -0
- {kinto-20.4.0.dist-info → kinto-20.5.0.dist-info}/top_level.txt +0 -0
kinto/plugins/prometheus.py
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import shutil
|
|
1
4
|
import warnings
|
|
2
5
|
from time import perf_counter as time_now
|
|
3
6
|
|
|
@@ -15,15 +18,29 @@ except ImportError: # pragma: no cover
|
|
|
15
18
|
prometheus_module = None
|
|
16
19
|
|
|
17
20
|
|
|
21
|
+
logger = logging.getLogger(__name__)
|
|
22
|
+
|
|
18
23
|
_METRICS = {}
|
|
19
24
|
_REGISTRY = None
|
|
20
25
|
|
|
21
26
|
|
|
27
|
+
PROMETHEUS_MULTIPROC_DIR = os.getenv("PROMETHEUS_MULTIPROC_DIR")
|
|
28
|
+
|
|
29
|
+
|
|
22
30
|
def get_registry():
|
|
23
31
|
global _REGISTRY
|
|
24
32
|
|
|
25
33
|
if _REGISTRY is None:
|
|
26
|
-
|
|
34
|
+
if PROMETHEUS_MULTIPROC_DIR: # pragma: no cover
|
|
35
|
+
from prometheus_client import multiprocess
|
|
36
|
+
|
|
37
|
+
_reset_multiproc_folder_content()
|
|
38
|
+
# Ref: https://prometheus.github.io/client_python/multiprocess/
|
|
39
|
+
_REGISTRY = prometheus_module.CollectorRegistry()
|
|
40
|
+
multiprocess.MultiProcessCollector(_REGISTRY)
|
|
41
|
+
else:
|
|
42
|
+
_REGISTRY = prometheus_module.REGISTRY
|
|
43
|
+
logger.warning("Prometheus metrics will run in single-process mode only.")
|
|
27
44
|
return _REGISTRY
|
|
28
45
|
|
|
29
46
|
|
|
@@ -170,6 +187,12 @@ def metrics_view(request):
|
|
|
170
187
|
return resp
|
|
171
188
|
|
|
172
189
|
|
|
190
|
+
def _reset_multiproc_folder_content(): # pragma: no cover
|
|
191
|
+
if os.path.exists(PROMETHEUS_MULTIPROC_DIR):
|
|
192
|
+
shutil.rmtree(PROMETHEUS_MULTIPROC_DIR)
|
|
193
|
+
os.mkdir(PROMETHEUS_MULTIPROC_DIR)
|
|
194
|
+
|
|
195
|
+
|
|
173
196
|
def includeme(config):
|
|
174
197
|
if prometheus_module is None:
|
|
175
198
|
error_msg = (
|
|
@@ -190,6 +213,7 @@ def includeme(config):
|
|
|
190
213
|
# This is mainly useful in tests, where the plugin is included
|
|
191
214
|
# several times with different settings.
|
|
192
215
|
registry = get_registry()
|
|
216
|
+
|
|
193
217
|
for collector in _METRICS.values():
|
|
194
218
|
try:
|
|
195
219
|
registry.unregister(collector)
|
|
@@ -100,7 +100,7 @@ kinto/core/views/openapi.py,sha256=PgxplQX1D0zqzlvRxBvd5SzrNMJmsaLfDta_fh-Pr-A,9
|
|
|
100
100
|
kinto/core/views/version.py,sha256=-m5G_o0oHTpCgrtfFrHFve6Zqw_gs_szT0Bd8jnNmD4,1419
|
|
101
101
|
kinto/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
102
102
|
kinto/plugins/flush.py,sha256=poiBOLGXjml0xXHjqDMRdbXJSd6N3SL0mfeGK2vxeHY,812
|
|
103
|
-
kinto/plugins/prometheus.py,sha256=
|
|
103
|
+
kinto/plugins/prometheus.py,sha256=qSXsNf9TqqMUIzseFtjAkvqjjYxoItoiVvtzwH2FMqc,7000
|
|
104
104
|
kinto/plugins/statsd.py,sha256=-VasJZM1xkhTfFa6_0GgWwfPqKnYS2722bSMDLzZ3pI,2469
|
|
105
105
|
kinto/plugins/accounts/__init__.py,sha256=2DeIaXJmMqRca3xVHeJ6xBWmeXAfrCdyg3EvK5jzIak,3670
|
|
106
106
|
kinto/plugins/accounts/authentication.py,sha256=pCb269FquKGFd6DH8AVTjFnBFlfxcDEYVyxhQp5Y08o,2117
|
|
@@ -141,9 +141,9 @@ kinto/views/contribute.py,sha256=PJoIMLj9_IszSjgZkaCd_TUjekDgNqjpmVTmRN9ztaA,983
|
|
|
141
141
|
kinto/views/groups.py,sha256=jOq5fX0-4lwZE8k1q5HME2tU7x9052rtBPF7YqcJ-Qg,3181
|
|
142
142
|
kinto/views/permissions.py,sha256=F0_eKx201WyLonXJ5vLdGKa9RcFKjvAihrEEhU1JuLw,9069
|
|
143
143
|
kinto/views/records.py,sha256=lYfACW2L8qcQoyYBD5IX-fTPjFWmGp7GjHq_U4InlyE,5037
|
|
144
|
-
kinto-20.
|
|
145
|
-
kinto-20.
|
|
146
|
-
kinto-20.
|
|
147
|
-
kinto-20.
|
|
148
|
-
kinto-20.
|
|
149
|
-
kinto-20.
|
|
144
|
+
kinto-20.5.0.dist-info/licenses/LICENSE,sha256=oNEIMTuTJzppR5ZEyi86yvvtSagveMYXTYFn56zF0Uk,561
|
|
145
|
+
kinto-20.5.0.dist-info/METADATA,sha256=8hgp9glzPTbNRIWX6r2RXIy5xX_-V72uFHyjo27XlxQ,8731
|
|
146
|
+
kinto-20.5.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
147
|
+
kinto-20.5.0.dist-info/entry_points.txt,sha256=3KlqBWPKY81mrCe_oX0I5s1cRO7Q53nCLbnVr5P9LH4,85
|
|
148
|
+
kinto-20.5.0.dist-info/top_level.txt,sha256=EG_YmbZL6FAug9VwopG7JtF9SvH_r0DEnFp-3twPPys,6
|
|
149
|
+
kinto-20.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|