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:
parent
dc58910bb5
commit
dcd174f761
2 changed files with 5 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue