code: def record_topic_fetch_metrics(self, topic, num_bytes, num_records):
      # record bytes fetched
      name = ".".join(["topic", topic, "bytes-fetched"])
      bytes_fetched = self.metrics.get_sensor(name)
      if not bytes_fetched:
          metric_tags = {"topic": topic.replace(".", "_")}
  
          bytes_fetched = self.metrics.sensor(name)
          bytes_fetched.add(
              self.metrics.metric_name(
                  "fetch-size-avg",
                  self.group_name,
                  "The average number of bytes fetched per request for topic %s"
                  % (topic,),
                  metric_tags,
              ),
              Avg(),
          )
          bytes_fetched.add(
              self.metrics.metric_name(
                  "fetch-size-max",
                  self.group_name,
                  "The maximum number of bytes fetched per request for topic %s"
                  % (topic,),
                  metric_tags,
              ),
              Max(),
          )
          bytes_fetched.add(
              self.metrics.metric_name(
                  "bytes-consumed-rate",
                  self.group_name,
                  "The average number of bytes consumed per second for topic %s"
                  % (topic,),
                  metric_tags,
              ),
              Rate(),
          )
      bytes_fetched.record(num_bytes)
  
      # record records fetched
      name = ".".join(["topic", topic, "records-fetched"])
      records_fetched = self.metrics.get_sensor(name)
      if not records_fetched:
          metric_tags = {"topic": topic.replace(".", "_")}
  
          records_fetched = self.metrics.sensor(name)
          records_fetched.add(
              self.metrics.metric_name(
                  "records-per-request-avg",
                  self.group_name,
                  "The average number of records in each request for topic %s"
                  % (topic,),
                  metric_tags,
              ),
              Avg(),
          )
          records_fetched.add(
              self.metrics.metric_name(
                  "records-consumed-rate",
                  self.group_name,
                  "The average number of records consumed per second for topic %s"
                  % (topic,),
                  metric_tags,
              ),
              Rate(),
          )
      records_fetched.record(num_records)
  
imports: from __future__ import absolute_import
  import collections
  import copy
  import logging
  import random
  import sys
  import time
  from kafka.vendor import six
  import kafka.errors
  from kafka.future import Future
  from kafka.metrics.stats import Avg, Count, Max, Rate
  from kafka.protocol.fetch import FetchRequest
  from kafka.protocol.offset import OffsetRequest, OffsetResetStrategy, UNKNOWN_OFFSET
  from kafka.record import MemoryRecords
  from kafka.serializer import Deserializer
  from kafka.structs import TopicPartition, OffsetAndTimestamp
label_desc: Use image node_id 2 for calling the FetchManagerMetrics obj's underlying member method code with example usage: obj.record_topic_fetch_metrics(topic, num_bytes, num_records) without return types