The Kafka documentation states that the producer's record-size-avg metric is "The average record size", but this does not seem to be the case. The client code calculates the average maximum record size across producer batches for record-size-avg. I am misinterpreting this metric? Should the documentation be updated to reflect this?
Here are code snippets from version 2.6 that show the creation of the sensor and how it is populated:
Sender.java:
811: this.maxRecordSizeSensor = metrics.sensor("record-size");
812: this.maxRecordSizeSensor.add(metrics.recordSizeMax, new Max());
813: this.maxRecordSizeSensor.add(metrics.recordSizeAvg, new Avg());
889: this.maxRecordSizeSensor.record(batch.maxRecordSize, now);
ProducerBatch.java:
108 & 134: this.maxRecordSize = Math.max(this.maxRecordSize, AbstractRecords.estimateSizeInBytesUpperBound(magic(), recordsBuilder.compressionType(), key, value, headers));