[IOTDB-3158][metric] fix NPE exception (#5891)