code: void updateInstance(T instance) {
          T oldInstance = this.instance.getAndSet(Preconditions.checkNotNull(instance, "instance"));
          if (oldInstance != null && oldInstance != instance) {
              oldInstance.close();
          }
      }
docs: Updates the underlying Metric instance with the given one, and closes out the previous one.
  
  @param instance The instance to update to.