Skip to content

Add messaging.message.body.size in spans of producers writing to kafka #12415

@shivanshuraj1333

Description

@shivanshuraj1333

Is your feature request related to a problem? Please describe.

Java instrumenter (for kafka client instrumentation) uses the same attributesExtractor for both producer and consumer spans, yet messaging.message.body.size is not present for producers, the attribute list is here. (I've highlighted the diff)

The bytes attribute is extracted from for producers

But for producers, kafka client library is not instrumented and returns null from the request.

---producer attributes related with messaging queues---
  {Key: "messaging.kafka.message.offset", Value: 143375.0},
  {Key: "messaging.kafka.message.key", Value: "key1"},
  {Key: "messaging.destination.partition.id", Value: "2"},
  {Key: "messaging.client_id", Value: "producer-1"},
  {Key: "messaging.system", Value: "kafka"},
  {Key: "messaging.operation", Value: "publish"},
  {Key: "messaging.destination.name", Value: "topic2"},

---producer attributes related with messaging queues---
-> {Key: "messaging.message.body.size", Value: 14.0},
  {Key: "messaging.kafka.message.offset", Value: 85405.0},
  {Key: "messaging.destination.partition.id", Value: "2"},
  {Key: "messaging.operation", Value: "process"},
  {Key: "messaging.client_id", Value: "consumer-cg1-1"},
  {Key: "messaging.system", Value: "kafka"},
-> {Key: "messaging.kafka.consumer.group", Value: "cg1"},
  {Key: "messaging.destination.name", Value: "topic1"},
  {Key: "messaging.kafka.message.key", Value: "key1"},
---

Describe the solution you'd like

Add frame work support for kafka client >= 2.6 to get the bytes in producer spans as well.framework

Describe alternatives you've considered

The data is present in the MBean object but it should also be present in producer spans as well according to messaging semconv for spans

Additional context

Details in the Slack thread here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions