elastic / elastic/apm-agent-python

Add instrumentation and distributed tracing for RabbitMQ (pika)

Open
#678 12 comments 14 reactions 0 assignees View on GitHub
agent-python enhancement instrumentation
Dominant language
Python
Stars
431
Forks
239
Avg merge
5d 10h
Merged PRs (30d)
7

Description

**Context**
One common way to integrate services is using RabbitMQ as a message broker. Currently, the Elastic APM agent only supports distributed tracing for HTTP calls. It would be of high value to add instrumentation and distributed tracing for message brokers and, in particular, [RabbitMQ](
https://www.rabbitmq.com/) - one of the most deployed open source message brokers. Not having this integration could be a show-stopper for users of competitor solutions ([New Relic already sports this integration](https://docs.newrelic.com/docs/agents/python-agent/getting-started/instrumented-python-packages#message-broker-clients)) when considering migrating to Elastic APM.

**Solution**
The ideal solution would be to instrument message publishing and include tracing data in message headers, interpreting those headers when consuming messages to continue the tracing.

To support the maximum number of projects using RabbitMQ, I would recommend to start by adding support for [Pika](https://pypi.org/project/pika/) - a widely-used AMQP client library having support for both Python 2.7 and +3.4.

**Alternatives**
A flexible alternative to a library-specific integration could be to provide APIs to create and interpret a distributed tracing payload for use in custom instrumentation of any type of communication between services. New Relic, for example, does offer these APIs in [`create_distributed_trace_payload()`](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/createdistributedtracepayload-python-agent-api) and [`accept_distributed_trace_payload()`](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/acceptdistributedtracepayload-python-agent-api)

I'm willing to contribute with code if this is of general interest.

/ Hampus

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.