confluentinc / confluent-kafka-go

Confluent's Apache Kafka Golang client
Apache License 2.0
4.66k stars 658 forks source link

Delivery report from events channel does not have timestamp and headers #425

Open jasimsulaiman opened 4 years ago

jasimsulaiman commented 4 years ago

Description

Delivery report of message from events channel, when using channel producer does not have timestamp or headers. This behavior is same for successfully delivered, as well as on timeout on failure to deliver to kafka.

Not having headers makes it very hard to identify which message failed.

How to reproduce

Send message with timestamp:

        TopicPartition: kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny},
        Value:          out,
        Headers:        mapToHeaders(headers),
        Timestamp:      time.Date(2018, 1, 1, 1, 1, 1, 1, time.UTC),
        TimestampType:  kafka.TimestampCreateTime,
    }

producer.ProduceChannel() <- msg

Checklist

Please provide the following information:

silencev commented 4 years ago

I also set metadata in headers and would like to know the delivery result from headers. for the timestamp, I'm using it to calculate the delivery latency.

@edenhill I saw here to get timestamp if event type is RD_KAFKA_EVENT_FETCH just curious is it possible to get message timestamp back by calling rd_kafka_message_timestamp() when receive event RD_KAFKA_EVENT_DR?

edenhill commented 4 years ago

@silencev Sorry, timestamps and headers are not available in the delivery report. You can pass a user object of your choice with each produced message which you can retrieve in the delivery report, you can use that to measure latency, et.al.

In librdkafka there's a rd_kafka_message_latency() which can be used in delivery reports to get the total time from produce() to delivery, it could easily be exposed in the Go client as well.

nandak522 commented 4 years ago

user object of your choice

@edenhill Can you explain what do you mean by "user object" ? Are you referring to Message.Opaque struct field ?

AdrielVelazquez commented 1 year ago

@nandak522 and @jasimsulaiman This is an old issue, but I added the producer latency into this PR.

https://github.com/confluentinc/confluent-kafka-go/pull/1076

Unless there's a better method of getting the ProducerLatency that can circumvent this.