From 47a8560679a7237aa8efa156b726851c328f4655 Mon Sep 17 00:00:00 2001 From: Steve Waterworth Date: Mon, 11 Feb 2019 16:17:38 +0000 Subject: [PATCH] added logs to traces --- payment/payment.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/payment/payment.py b/payment/payment.py index 0304e8e..50ab141 100644 --- a/payment/payment.py +++ b/payment/payment.py @@ -44,6 +44,11 @@ def pay(id): anonymous_user = True + # add some log info to the active trace + span = ot.tracer.active_span + span.log_kv({'id': id}) + span.log_kv({'cart': cart}) + # check user exists try: req = requests.get('http://{user}:8080/check/{id}'.format(user=USER, id=id)) @@ -60,7 +65,7 @@ def pay(id): if item.get('sku') == 'SHIP': has_shipping = True - if not cart.get('total') or int(cart.get('total')) == 0 or has_shipping == False: + if cart.get('total', 0) == 0 or has_shipping == False: app.logger.warn('cart not valid') return 'cart not valid', 400 @@ -104,7 +109,7 @@ def pay(id): def queueOrder(order): app.logger.info('queue order') - # RabbitMQ is not currently traced automatically + # RabbitMQ pika is not currently traced automatically # opentracing tracer is automatically set to Instana tracer # start a span @@ -114,6 +119,7 @@ def queueOrder(order): 'exchange': Publisher.EXCHANGE, 'key': Publisher.ROUTING_KEY }) as tscope: + tscope.span.log_kv({'orderid': order.get('orderid')}) with ot.tracer.start_active_span('rabbitmq', child_of=tscope.span, tags={ 'exchange': Publisher.EXCHANGE,