mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-03-17 05:32:44 +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
|
### Improvements
|
||||||
- Switch from CssAbsoluteFilter to CssRelativeFilter (#822)
|
- Switch from CssAbsoluteFilter to CssRelativeFilter (#822)
|
||||||
|
- Add statsd metric collection in hc.lib.s3.get_object()
|
||||||
|
|
||||||
## v2.8.1 - 2023-04-11
|
## v2.8.1 - 2023-04-11
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ from io import BytesIO
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from statsd.defaults.env import statsd
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from minio import Minio, S3Error
|
from minio import Minio, S3Error
|
||||||
|
@ -63,6 +64,7 @@ def enc(n):
|
||||||
return len_inverted + inverted + "-" + s
|
return len_inverted + inverted + "-" + s
|
||||||
|
|
||||||
|
|
||||||
|
@statsd.timer("hc.lib.s3.getObjectTime")
|
||||||
def get_object(code, n):
|
def get_object(code, n):
|
||||||
if not settings.S3_BUCKET:
|
if not settings.S3_BUCKET:
|
||||||
return None
|
return None
|
||||||
|
@ -73,8 +75,10 @@ def get_object(code, n):
|
||||||
response = client().get_object(settings.S3_BUCKET, key)
|
response = client().get_object(settings.S3_BUCKET, key)
|
||||||
return response.read()
|
return response.read()
|
||||||
except S3Error:
|
except S3Error:
|
||||||
|
statsd.incr("hc.lib.s3.getObjectErrors")
|
||||||
return None
|
return None
|
||||||
except HTTPError:
|
except HTTPError:
|
||||||
|
statsd.incr("hc.lib.s3.getObjectErrors")
|
||||||
return None
|
return None
|
||||||
finally:
|
finally:
|
||||||
if response:
|
if response:
|
||||||
|
|
Loading…
Reference in a new issue