open-telemetry / open-telemetry/opentelemetry-python-contrib

pika: add opt-in `messaging.rabbitmq.cluster.name` / `messaging.rabbitmq.vhost.name` span attributes

Open
#4,963 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

What problem do you want to solve?

opentelemetry-instrumentation-pika has no way to surface which RabbitMQ vhost or cluster
a message was published to/consumed from. This matters for anyone running multiple vhosts
on a shared broker (multi-tenant) or multiple clusters — without it, traces from different
logical RabbitMQ environments are indistinguishable. These aren't official
semantic-conventions attributes yet (tracked upstream in open-telemetry/semantic-conventions#3997),
so nothing standard covers this today.

Describe the solution you'd like

Add two span attributes, populated from data pika already has on the Connection object:

  • messaging.rabbitmq.vhost.nameconnection.params.virtual_host
  • messaging.rabbitmq.cluster.nameconnection.server_properties.get("cluster_name")

Since neither is a stable spec attribute, and not every user wants the extra cardinality,
gate each independently behind its own boolean env var, off by default:

  • OTEL_PYTHON_PIKA_CAPTURE_VHOST_NAME
  • OTEL_PYTHON_PIKA_CAPTURE_CLUSTER_NAME

Parsed the same way as other OTEL_PYTHON_* boolean flags in this repo (e.g.
OTEL_PYTHON_LOG_CODE_ATTRIBUTES): "true" (case-insensitive, trimmed) = enabled,
anything else = disabled. Two independent flags rather than one combined flag, so a user
who only cares about one doesn't pay for the other.

Describe alternatives you've considered

There isn't much room for alternatives to the feature

Additional Context

No response

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the opentelemetry-instrumentation-pika span creation and the existing OTEL_PYTHON_* boolean flag parsing, then inspect how the pika Connection exposes virtual_host and cluster_name. Add independently gated attributes and verify spans with each flag enabled and disabled, including the requested true parsing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rabbitmq
Domain
distributed-systems, observability
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.