opentelemetry-python-contrib
opentelemetry-python-contrib copied to clipboard
opentelemetry-instrumentation-aio-pika to support QueueIterator
trafficstars
Is your feature request related to a problem?
It was noticed that when using opentelemetry-instrumentation-aio-pika with QueueIterator (an example https://aio-pika.readthedocs.io/en/latest/apidoc.html#aio_pika.RobustQueue.iterator), trace context information carried by the message is ignored or not correctly parsed.
Describe the solution you'd like It would be great to make it work with QueueIterator and use trace context from the message.
Describe alternatives you've considered N/A
Additional context As a temporary solution, this could be solved with the following code:
from opentelemetry.instrumentation.aio_pika.callback_decorator import CallbackDecorator
...
decorated_callback = CallbackDecorator(tracer, queue).decorate(self.on_message)
while True:
async with queue.iterator() as queue_iter:
async for message in queue_iter:
await decorated_callback(message) # type: ignore
await asyncio.sleep(0.1)
+1