code: def metrics(self, raw=False):
          
          if raw:
              return self._metrics.metrics.copy()
  
          metrics = {}
          for k, v in six.iteritems(self._metrics.metrics.copy()):
              if k.group not in metrics:
                  metrics[k.group] = {}
              if k.name not in metrics[k.group]:
                  metrics[k.group][k.name] = {}
              metrics[k.group][k.name] = v.value()
          return metrics
docs: Get metrics on producer performance.
  
          This is ported from the Java Producer, for details see:
          https://kafka.apache.org/documentation/#producer_monitoring
  
          Warning:
              This is an unstable interface. It may change in future
              releases without warning.