<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add(self, metric_name, stat, config=None):
 """ Register a metric with this sensor Arguments: metric_name (MetricName):
 The name of the metric stat (AbstractMeasurableStat):
 The statistic to keep config (MetricConfig):
 A special configuration for this metric. If None use the sensor default configuration. """

        with self._lock:
            metric = KafkaMetric(metric_name, stat, config or self._config)
            self._registry.register_metric(metric)
            self._metrics.append(metric)
            self._stats.append(stat)