public static <K, V> TopicPartition extractTopicPartition(ProducerRecord<K, V> record) {
        return new TopicPartition(record.topic(), record.partition() == null ? RecordMetadata.UNKNOWN_PARTITION : record.partition());
    }
This method is called when sending the record fails in {@link ProducerInterceptor#onSend
(ProducerRecord)} method. This method calls {@link ProducerInterceptor#onAcknowledgement(RecordMetadata, Exception)}
method for each interceptor

@param record The record from client
@param interceptTopicPartition  The topic/partition for the record if an error occurred
       after partition gets assigned; the topic part of interceptTopicPartition is the same as in record.
@param exception The exception thrown during processing of this record.
clients/src/main/java/org/apache/kafka/clients/producer/internals/ProducerInterceptors.java