Creating lock while code metrics running