added logs to traces
This commit is contained in:
@@ -44,6 +44,11 @@ def pay(id):
|
|||||||
|
|
||||||
anonymous_user = True
|
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
|
# check user exists
|
||||||
try:
|
try:
|
||||||
req = requests.get('http://{user}:8080/check/{id}'.format(user=USER, id=id))
|
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':
|
if item.get('sku') == 'SHIP':
|
||||||
has_shipping = True
|
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')
|
app.logger.warn('cart not valid')
|
||||||
return 'cart not valid', 400
|
return 'cart not valid', 400
|
||||||
|
|
||||||
@@ -104,7 +109,7 @@ def pay(id):
|
|||||||
|
|
||||||
def queueOrder(order):
|
def queueOrder(order):
|
||||||
app.logger.info('queue 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
|
# opentracing tracer is automatically set to Instana tracer
|
||||||
# start a span
|
# start a span
|
||||||
|
|
||||||
@@ -114,6 +119,7 @@ def queueOrder(order):
|
|||||||
'exchange': Publisher.EXCHANGE,
|
'exchange': Publisher.EXCHANGE,
|
||||||
'key': Publisher.ROUTING_KEY
|
'key': Publisher.ROUTING_KEY
|
||||||
}) as tscope:
|
}) as tscope:
|
||||||
|
tscope.span.log_kv({'orderid': order.get('orderid')})
|
||||||
with ot.tracer.start_active_span('rabbitmq', child_of=tscope.span,
|
with ot.tracer.start_active_span('rabbitmq', child_of=tscope.span,
|
||||||
tags={
|
tags={
|
||||||
'exchange': Publisher.EXCHANGE,
|
'exchange': Publisher.EXCHANGE,
|
||||||
|
Reference in New Issue
Block a user