add more transactions to sentry
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
dadb6508b3
commit
f6273afe7b
@ -4,11 +4,12 @@ from xeger import Xeger
|
|||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
from flask import request, current_app
|
from flask import request, current_app
|
||||||
import requests
|
import requests
|
||||||
|
from sentry_sdk import start_transaction
|
||||||
|
import pika
|
||||||
from db import db
|
from db import db
|
||||||
from models import SampleMetadata
|
from models import SampleMetadata
|
||||||
from schemas import SampleSchema, SampleMetadataSchema
|
from schemas import SampleSchema, SampleMetadataSchema
|
||||||
from config import *
|
from config import *
|
||||||
import pika
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Flask Restful endpoints
|
Flask Restful endpoints
|
||||||
@ -76,20 +77,21 @@ class SampleResource(Resource):
|
|||||||
soundfile,
|
soundfile,
|
||||||
soundfile.content_type,
|
soundfile.content_type,
|
||||||
{'Content-Length': soundfile.content_length})}).raise_for_status()
|
{'Content-Length': soundfile.content_length})}).raise_for_status()
|
||||||
credentials = pika.PlainCredentials(current_app.config['FLASK_PIKA_PARAMS']['username'],
|
with start_transaction(op="rabbitmq-send", name="rabbitmq-connect-and-publish"):
|
||||||
current_app.config['FLASK_PIKA_PARAMS']['password'])
|
credentials = pika.PlainCredentials(current_app.config['FLASK_PIKA_PARAMS']['username'],
|
||||||
connection = pika.BlockingConnection(
|
current_app.config['FLASK_PIKA_PARAMS']['password'])
|
||||||
pika.ConnectionParameters(host=current_app.config['FLASK_PIKA_PARAMS']['host'],
|
connection = pika.BlockingConnection(
|
||||||
credentials=credentials,
|
pika.ConnectionParameters(host=current_app.config['FLASK_PIKA_PARAMS']['host'],
|
||||||
heartbeat=0,
|
credentials=credentials,
|
||||||
socket_timeout=5))
|
heartbeat=0,
|
||||||
channel = connection.channel()
|
socket_timeout=5))
|
||||||
channel.exchange_declare(exchange=current_app.config['FLASK_PIKA_PARAMS']['EXCHANGE_NAME'],
|
channel = connection.channel()
|
||||||
exchange_type='fanout')
|
channel.exchange_declare(exchange=current_app.config['FLASK_PIKA_PARAMS']['EXCHANGE_NAME'],
|
||||||
channel.basic_publish(exchange=current_app.config['FLASK_PIKA_PARAMS']['EXCHANGE_NAME'],
|
exchange_type='fanout')
|
||||||
routing_key='feature',
|
channel.basic_publish(exchange=current_app.config['FLASK_PIKA_PARAMS']['EXCHANGE_NAME'],
|
||||||
body=json.dumps({'tag': generated_tag}).encode('UTF-8'))
|
routing_key='feature',
|
||||||
connection.close()
|
body=json.dumps({'tag': generated_tag}).encode('UTF-8'))
|
||||||
|
connection.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
current_app.logger.exception(e)
|
current_app.logger.exception(e)
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
|
Loading…
Reference in New Issue
Block a user