mirror of https://github.com/zulip/zulip.git
memcached_exporter: Explicitly close memcached connection.
Fixes warnings like “ResourceWarning: unclosed <socket.socket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 39702), raddr=('127.0.0.1', 11211)>” with warnings enabled. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
c8eaceff21
commit
f3c67103cf
|
@ -382,12 +382,13 @@ class MemcachedCollector(Collector):
|
|||
|
||||
raw_stats = client.stats("sizes")
|
||||
sizes_stats = next(iter(raw_stats.values()))
|
||||
if sizes_stats.get("sizes_status") == b"disabled" or sizes_stats == {}:
|
||||
return
|
||||
sizes = sorted([int(x) for x in sizes_stats])
|
||||
yield gauge(
|
||||
"item_max_bytes", "Largest item (rounded to 32 bytes) in bytes.", value=sizes[-1]
|
||||
)
|
||||
if sizes_stats.get("sizes_status") != b"disabled" and sizes_stats != {}:
|
||||
sizes = sorted([int(x) for x in sizes_stats])
|
||||
yield gauge(
|
||||
"item_max_bytes", "Largest item (rounded to 32 bytes) in bytes.", value=sizes[-1]
|
||||
)
|
||||
|
||||
client.disconnect_all()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue