kinto 19.3.2__py3-none-any.whl → 19.4.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.

@@ -28,7 +28,7 @@ def get_registry():
28
28
 
29
29
 
30
30
  def _fix_metric_name(s):
31
- return s.replace("-", "_").replace(".", "_")
31
+ return s.replace("-", "_").replace(".", "_").replace(" ", "_")
32
32
 
33
33
 
34
34
  class Timer:
@@ -68,8 +68,20 @@ class Timer:
68
68
 
69
69
  @implementer(metrics.IMetricsService)
70
70
  class PrometheusService:
71
+ def __init__(self, prefix=""):
72
+ prefix_clean = ""
73
+ if prefix:
74
+ # In GCP Console, the metrics are grouped by the first
75
+ # word before the first underscore. Here we make sure the specified
76
+ # prefix is not mixed up with metrics names.
77
+ # (eg. `remote-settings` -> `remotesettings_`, `kinto_` -> `kinto_`)
78
+ prefix_clean = _fix_metric_name(prefix).replace("_", "") + "_"
79
+ self.prefix = prefix_clean.lower()
80
+
71
81
  def timer(self, key):
72
82
  global _METRICS
83
+ key = self.prefix + key
84
+
73
85
  if key not in _METRICS:
74
86
  _METRICS[key] = prometheus_module.Summary(
75
87
  _fix_metric_name(key), f"Summary of {key}", registry=get_registry()
@@ -84,6 +96,7 @@ class PrometheusService:
84
96
 
85
97
  def observe(self, key, value, labels=[]):
86
98
  global _METRICS
99
+ key = self.prefix + key
87
100
 
88
101
  if key not in _METRICS:
89
102
  _METRICS[key] = prometheus_module.Summary(
@@ -106,6 +119,7 @@ class PrometheusService:
106
119
 
107
120
  def count(self, key, count=1, unique=None):
108
121
  global _METRICS
122
+ key = self.prefix + key
109
123
 
110
124
  labels = []
111
125
 
@@ -183,4 +197,7 @@ def includeme(config):
183
197
  pass
184
198
  _METRICS.clear()
185
199
 
186
- config.registry.registerUtility(PrometheusService(), metrics.IMetricsService)
200
+ settings = config.get_settings()
201
+ prefix = settings.get("prometheus_prefix", settings["project_name"])
202
+
203
+ config.registry.registerUtility(PrometheusService(prefix=prefix), metrics.IMetricsService)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: kinto
3
- Version: 19.3.2
3
+ Version: 19.4.0
4
4
  Summary: Kinto Web Service - Store, Sync, Share, and Self-Host.
5
5
  Author-email: Mozilla Services <developers@kinto-storage.org>
6
6
  License: Copyright 2012 - Mozilla Foundation
@@ -78,7 +78,7 @@ kinto/core/views/openapi.py,sha256=YZ7akBoMqmiu0b4AOxlupHU01_kQEHtmzPxJq_iS79Y,9
78
78
  kinto/core/views/version.py,sha256=-m5G_o0oHTpCgrtfFrHFve6Zqw_gs_szT0Bd8jnNmD4,1419
79
79
  kinto/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
80
80
  kinto/plugins/flush.py,sha256=mG3J6KI9xP2ICYaxQEscEhUfdkDky-qN0klYap9YPMM,809
81
- kinto/plugins/prometheus.py,sha256=tLxb1VZOzZS-8PJgqXDfjHz773wHtwZjcFZuE10-hbA,5486
81
+ kinto/plugins/prometheus.py,sha256=oGpm1H4-CTVK4kd_GWDyn4nKBCSVq1fypdBoewDMRPk,6209
82
82
  kinto/plugins/statsd.py,sha256=-VasJZM1xkhTfFa6_0GgWwfPqKnYS2722bSMDLzZ3pI,2469
83
83
  kinto/plugins/accounts/__init__.py,sha256=KX3rTxHf520JNXfAa1RwCMZijSR6kPjOrMbTxMig8yk,4346
84
84
  kinto/plugins/accounts/authentication.py,sha256=h7l_KezC8os4sKN1bz3RKEwXwYTYAs21DRzzU9na_U0,3742
@@ -125,9 +125,9 @@ kinto/views/contribute.py,sha256=NEDr2g1HhVwcMBg0qHEZDmWVJ1V31WsM8cRs0Vm6hfc,118
125
125
  kinto/views/groups.py,sha256=jOq5fX0-4lwZE8k1q5HME2tU7x9052rtBPF7YqcJ-Qg,3181
126
126
  kinto/views/permissions.py,sha256=F0_eKx201WyLonXJ5vLdGKa9RcFKjvAihrEEhU1JuLw,9069
127
127
  kinto/views/records.py,sha256=lYfACW2L8qcQoyYBD5IX-fTPjFWmGp7GjHq_U4InlyE,5037
128
- kinto-19.3.2.dist-info/LICENSE,sha256=oNEIMTuTJzppR5ZEyi86yvvtSagveMYXTYFn56zF0Uk,561
129
- kinto-19.3.2.dist-info/METADATA,sha256=CnSTJCkQ75XHZgy7wSmXGswSlklTR5SZAj1HZipg1qI,8858
130
- kinto-19.3.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
131
- kinto-19.3.2.dist-info/entry_points.txt,sha256=3KlqBWPKY81mrCe_oX0I5s1cRO7Q53nCLbnVr5P9LH4,85
132
- kinto-19.3.2.dist-info/top_level.txt,sha256=EG_YmbZL6FAug9VwopG7JtF9SvH_r0DEnFp-3twPPys,6
133
- kinto-19.3.2.dist-info/RECORD,,
128
+ kinto-19.4.0.dist-info/LICENSE,sha256=oNEIMTuTJzppR5ZEyi86yvvtSagveMYXTYFn56zF0Uk,561
129
+ kinto-19.4.0.dist-info/METADATA,sha256=cUCZg_hSiek4uuNA6-syERFEIRgyXUAI5aUem_-5nxA,8858
130
+ kinto-19.4.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
131
+ kinto-19.4.0.dist-info/entry_points.txt,sha256=3KlqBWPKY81mrCe_oX0I5s1cRO7Q53nCLbnVr5P9LH4,85
132
+ kinto-19.4.0.dist-info/top_level.txt,sha256=EG_YmbZL6FAug9VwopG7JtF9SvH_r0DEnFp-3twPPys,6
133
+ kinto-19.4.0.dist-info/RECORD,,
File without changes