Added tracing to classification
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-07-30 15:24:57 +02:00
parent 0245cd7b6a
commit 1acdd6d21c
3 changed files with 44 additions and 30 deletions

View File

@@ -17,21 +17,25 @@ from magic_doer import MagicDoer
def message_callback(channel, method, properties, body):
try:
msg = json.loads(body.decode('utf-8'))
except (UnicodeDecodeError, json.JSONDecodeError) as e:
logging.warning(f"Invalid message recieved: {e}")
return
with opentracing.tracer.start_span('messageHandling') as span:
try:
msg = json.loads(body.decode('utf-8'))
except (UnicodeDecodeError, json.JSONDecodeError) as e:
logging.warning(f"Invalid message recieved: {e}")
return
results = MagicDoer.run_everything(msg) # <- This is where the magic happens
span.log_kv({'event': 'messageParsed', 'sampleTag': msg['tag']})
if results:
channel.basic_publish(
exchange=Config.PIKA_OUTPUT_EXCHANGE,
routing_key='classification-result',
body=json.dumps(results).encode("utf-8")
)
channel.basic_ack(delivery_tag=method.delivery_tag)
with opentracing.tracer.start_span('runAlgorithm', child_of=span) as child_span:
results = MagicDoer.run_everything(msg, child_span) # <- This is where the magic happens
if results:
channel.basic_publish(
exchange=Config.PIKA_OUTPUT_EXCHANGE,
routing_key='classification-result',
body=json.dumps(results).encode("utf-8")
)
channel.basic_ack(delivery_tag=method.delivery_tag)
def main():