private void registerMetrics(Metrics metrics, String metricGrpName) {
        metrics.addMetric(
            metrics.metricName("waiting-threads", metricGrpName,
                "The number of user threads blocked waiting for buffer memory to enqueue their records"),
            (config, now) -> free.queued());

        metrics.addMetric(
            metrics.metricName("buffer-total-bytes", metricGrpName,
                "The maximum amount of buffer memory the client can use (whether or not it is currently used)."),
            (config, now) -> free.totalMemory());

        metrics.addMetric(
            metrics.metricName("buffer-available-bytes", metricGrpName,
                "The total amount of buffer memory that is not being used (either unallocated or in the free list)."),
            (config, now) -> free.availableMemory());
    }
Create a new record accumulator with default partitioner config

@param logContext The log context used for logging
@param batchSize The size to use when allocating {@link MemoryRecords} instances
@param compression The compression codec for the records
@param lingerMs An artificial delay time to add before declaring a records instance that isn't full ready for
       sending. This allows time for more records to arrive. Setting a non-zero lingerMs will trade off some
       latency for potentially better throughput due to more batching (and hence fewer, larger requests).
@param retryBackoffMs An artificial delay time to retry the produce request upon receiving an error. This avoids
       exhausting all retries in a short period of time.
@param retryBackoffMaxMs The upper bound of the retry backoff time.
@param deliveryTimeoutMs An upper bound on the time to report success or failure on record delivery
@param metrics The metrics
@param metricGrpName The metric group name
@param time The time instance to use
@param apiVersions Request API versions for current connected brokers
@param transactionManager The shared transaction state object which tracks producer IDs, epochs, and sequence
                          numbers per partition.
@param bufferPool The buffer pool
clients/src/main/java/org/apache/kafka/clients/producer/internals/RecordAccumulator.java