mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Merge branch 'rav/fix_expiring_cache_len' into erikj/destination_retry_cache
This commit is contained in:
commit
5b4028fa78
1
changelog.d/3911.misc
Normal file
1
changelog.d/3911.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix the docker image building on python 3
|
1
changelog.d/3956.bugfix
Normal file
1
changelog.d/3956.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix exceptions from metrics handler
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
|||||||
FROM docker.io/python:2-alpine3.8
|
ARG PYTHON_VERSION=2
|
||||||
|
FROM docker.io/python:${PYTHON_VERSION}-alpine3.8
|
||||||
|
|
||||||
COPY . /synapse
|
COPY . /synapse
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import glob
|
import glob
|
||||||
|
import codecs
|
||||||
|
|
||||||
# Utility functions
|
# Utility functions
|
||||||
convert = lambda src, dst, environ: open(dst, "w").write(jinja2.Template(open(src).read()).render(**environ))
|
convert = lambda src, dst, environ: open(dst, "w").write(jinja2.Template(open(src).read()).render(**environ))
|
||||||
@ -23,7 +24,7 @@ def generate_secrets(environ, secrets):
|
|||||||
with open(filename) as handle: value = handle.read()
|
with open(filename) as handle: value = handle.read()
|
||||||
else:
|
else:
|
||||||
print("Generating a random secret for {}".format(name))
|
print("Generating a random secret for {}".format(name))
|
||||||
value = os.urandom(32).encode("hex")
|
value = codecs.encode(os.urandom(32), "hex").decode()
|
||||||
with open(filename, "w") as handle: handle.write(value)
|
with open(filename, "w") as handle: handle.write(value)
|
||||||
environ[secret] = value
|
environ[secret] = value
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import six
|
import six
|
||||||
@ -20,6 +21,8 @@ from six.moves import intern
|
|||||||
|
|
||||||
from prometheus_client.core import REGISTRY, Gauge, GaugeMetricFamily
|
from prometheus_client.core import REGISTRY, Gauge, GaugeMetricFamily
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.5))
|
CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.5))
|
||||||
|
|
||||||
|
|
||||||
@ -76,6 +79,7 @@ def register_cache(cache_type, cache_name, cache):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
def collect(self):
|
def collect(self):
|
||||||
|
try:
|
||||||
if cache_type == "response_cache":
|
if cache_type == "response_cache":
|
||||||
response_cache_size.labels(cache_name).set(len(cache))
|
response_cache_size.labels(cache_name).set(len(cache))
|
||||||
response_cache_hits.labels(cache_name).set(self.hits)
|
response_cache_hits.labels(cache_name).set(self.hits)
|
||||||
@ -86,6 +90,9 @@ def register_cache(cache_type, cache_name, cache):
|
|||||||
cache_hits.labels(cache_name).set(self.hits)
|
cache_hits.labels(cache_name).set(self.hits)
|
||||||
cache_evicted.labels(cache_name).set(self.evicted_size)
|
cache_evicted.labels(cache_name).set(self.evicted_size)
|
||||||
cache_total.labels(cache_name).set(self.hits + self.misses)
|
cache_total.labels(cache_name).set(self.hits + self.misses)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn("Error calculating metrics for %s: %s", cache_name, e)
|
||||||
|
raise
|
||||||
|
|
||||||
yield GaugeMetricFamily("__unused", "")
|
yield GaugeMetricFamily("__unused", "")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user