How to monitor transactions which pass through Rabbit MQ, producer & consumer are python clients

I haven't done anything in rabbitmq, so I can't help with that piece at this moment.

But something like this on the producer:

headers = {"traceparent": elasticapm.get_trace_parent_header()}
rabbitmq.queue(message, headers=headers)  # I'm making this line up

On the consumer:

def consume(message, headers, client):
    traceparent = ealsticapm.trace_parent_from_string(headers.get("traceparent", ""))
    if traceparent:
        client.begin_transaction(transaction_type="messaging", trace_parent=traceparent)
    else:
        client.begin_transaction(transaction_type="messaging")

Note that you can also use span links if you're already in an active transaction in your consumer. This is where you link a span to a parent transaction so that they're tied together in the trace view, even though it's not a direct parent/child relationship. There's a links argument in the capture_span context manager.

Hope that helps!