Skip to content

Add Kafka Consumer Group to Kafka Instrumentation #4593

@mznet

Description

@mznet

What problem do you want to solve?

When a Kafka topic is shared among multiple consumer groups, the current Kafka consumer span doesn't include consumer group information. As a result, it is impossible to distinguish which consumer group a given span belongs to.

The attribute of consumer group is defined as messaging.consumer.group.name in semconv

Describe the solution you'd like

Extract the group id from the instance config as shown below:

consumer_group = (KafkaPropertiesExtractor.extract_consumer_group(instance))

def extract_consumer_group(instance) -> Optional[str]:
    try:
        return instance.config.get("group_id")
    except AttributeError:
        return None

Describe alternatives you've considered

No response

Additional Context

No response

Would you like to implement a fix?

None

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions