public void unregister(MetricKey key) {
    Metric exists = registeredMetrics.remove(key);
    if (exists != null) {
      callListener(listener -> listener.onMetricUnregistered(key));
    }
    definedMetrics.computeIfPresent(
        key.getDefine().getName(),
        (name, pair) -> {
          int count = pair.getRight() - 1;
          if (count <= 0) {
            return null;
          } else {
            return Pair.of(pair.getLeft(), count);
          }
        });
  }
Remove a metric

@param key registered metric key
amoro-ams/src/main/java/org/apache/amoro/server/metrics/MetricRegistry.java