fix rabbit api and add better sentry intergation
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Torma Kristóf 2020-07-30 15:33:28 +02:00
parent c8c96f3007
commit 46169a54bd
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
1 changed files with 18 additions and 7 deletions

View File

@ -1,9 +1,14 @@
#!/usr/bin/env python3
import json
import logging
import sentry_sdk
import pika
import requests
from sentry_sdk.integrations.logging import LoggingIntegration
import config
import uuid
from mqtt_helper import MQTT
"""
@ -16,9 +21,14 @@ __module_name__ = "app"
__version__text__ = "1"
if config.SENTRY_DSN:
sentry_logging = LoggingIntegration(
level=logging.DEBUG, # Capture info and above as breadcrumbs
event_level=logging.ERROR # Send errors as events
)
sentry_sdk.init(
dsn=config.SENTRY_DSN,
send_default_pii=True,
integrations=[sentry_logging],
release=config.RELEASE_ID,
environment=config.RELEASEMODE
)
@ -31,13 +41,14 @@ def setup_rabbit() -> None:
heartbeat=0,
socket_timeout=5))
channel = connection.channel()
exchange = channel.exchange_declare(exchange=config.RABBIT_EXCHANGE,
exchange_type='fanout',
durable=True,
auto_delete=False)
queue = channel.queue_declare(durable=True, auto_delete=False)
queue.bind(exchange)
queue.basic_consume(on_message, no_ack=True)
channel.exchange_declare(exchange=config.RABBIT_EXCHANGE,
exchange_type='fanout',
durable=True,
auto_delete=False)
queue = channel.queue_declare(durable=True, auto_delete=False, queue=uuid.uuid4().urn.split(':')[2],
exclusive=True).method.queue
channel.queue_bind(exchange=config.RABBIT_EXCHANGE, queue=queue)
channel.basic_consume(queue=queue, on_message_callback=on_message, auto_ack=True)
def on_message(channel, method_frame, header_frame, body):