Added some traces
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2021-08-09 16:06:09 +02:00
parent dfa848b1d8
commit 7ef991912c

View File

@ -5,6 +5,7 @@ from minio.error import BucketAlreadyExists, BucketAlreadyOwnedByYou, ResponseEr
from marshmallow import ValidationError
from utils import storage
from schemas import DescriptionSchema
import opentracing
class ObjectView(FlaskView):
@ -23,6 +24,7 @@ class ObjectView(FlaskView):
def post(self):
# get important data from the request
with opentracing.tracer.start_active_span('parseAndValidate'):
try:
description = self.description_schema.loads(request.form.get('description'))
except ValidationError as e:
@ -37,6 +39,7 @@ class ObjectView(FlaskView):
if file.content_length <= 0:
return abort(411, f"Content length for soundFile is not a positive integer or missing.")
with opentracing.tracer.start_active_span('ensureBuckets'):
# create bucket if necessary
try:
storage.connection.make_bucket(current_app.config['MINIO_BUCKET_NAME'])
@ -47,10 +50,19 @@ class ObjectView(FlaskView):
pass
# Everything else should be raised
with opentracing.tracer.start_active_span('checkExistence'):
# check for conflict
if self._check_existance(description['tag']):
return abort(409)
with opentracing.tracer.start_active_span(
'minio.putObject',
tags={
"bucket": current_app.config['MINIO_BUCKET_NAME'],
"object_name": description['tag'],
"length": file.content_length
}
):
# poot file into bucket
try:
storage.connection.put_object(current_app.config['MINIO_BUCKET_NAME'], description['tag'], file,