Update to Python OT 2.0 call style

This commit is contained in:
Peter Giacomo Lombardo
2018-10-11 11:09:50 +02:00
parent ca6a0c6edb
commit e82e8c42a7

View File

@@ -55,28 +55,25 @@ def queueOrder(order):
# start a span # start a span
# context = ot.tracer.current_context() # context = ot.tracer.current_context()
sspan = ot.tracer.active_span parent_span = ot.tracer.active_span
span = ot.tracer.start_span(operation_name='queue-order', with ot.tracer.start_active_span('queue-order', child_of=parent_span,
child_of=sspan,
tags={ tags={
tags.SPAN_KIND: 'producer', tags.SPAN_KIND: 'producer',
tags.COMPONENT: 'payment', tags.COMPONENT: 'payment',
'message_bus.destination': 'orders' 'message_bus.destination': 'orders'
} }
) ) as scope:
# For screenshot demo requirements optionally add in a bit of delay # For screenshot demo requirements optionally add in a bit of delay
delay = int(os.getenv('PAYMENT_DELAY_MS', 0)) delay = int(os.getenv('PAYMENT_DELAY_MS', 0))
time.sleep(delay / 1000) time.sleep(delay / 1000)
headers = {} headers = {}
ot.tracer.inject(span.context, ot.Format.HTTP_HEADERS, headers) ot.tracer.inject(scope.span.context, ot.Format.HTTP_HEADERS, headers)
app.logger.info('msg headers {}'.format(headers)) app.logger.info('msg headers {}'.format(headers))
publisher.publish(order, headers) publisher.publish(order, headers)
span.finish()
# RabbitMQ # RabbitMQ
publisher = Publisher(app.logger) publisher = Publisher(app.logger)