0
0
Fork 0
mirror of https://github.com/healthchecks/healthchecks.git synced 2025-03-15 20:54:53 +00:00

Add statsd metric collection in hc.lib.s3.get_object()

This commit is contained in:
Pēteris Caune 2023-04-14 13:23:16 +03:00
parent dc58910bb5
commit dcd174f761
No known key found for this signature in database
GPG key ID: E28D7679E9A9EDE2
2 changed files with 5 additions and 0 deletions

View file

@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
### Improvements
- Switch from CssAbsoluteFilter to CssRelativeFilter (#822)
- Add statsd metric collection in hc.lib.s3.get_object()
## v2.8.1 - 2023-04-11

View file

@ -5,6 +5,7 @@ from io import BytesIO
from threading import Thread
from django.conf import settings
from statsd.defaults.env import statsd
try:
from minio import Minio, S3Error
@ -63,6 +64,7 @@ def enc(n):
return len_inverted + inverted + "-" + s
@statsd.timer("hc.lib.s3.getObjectTime")
def get_object(code, n):
if not settings.S3_BUCKET:
return None
@ -73,8 +75,10 @@ def get_object(code, n):
response = client().get_object(settings.S3_BUCKET, key)
return response.read()
except S3Error:
statsd.incr("hc.lib.s3.getObjectErrors")
return None
except HTTPError:
statsd.incr("hc.lib.s3.getObjectErrors")
return None
finally:
if response: