code: def new_metric(name, class_, *args, **kwargs):
      
  
      with LOCK:
          try:
              item = REGISTRY[name]
          except KeyError:
              item = REGISTRY[name] = class_(*args, **kwargs)
              return item
  
      raise DuplicateMetricError("Metric {} already exists of type {}".format(name, type(item).__name__))
docs: Create a new metric of the given class.
  
      Raise DuplicateMetricError if the given name has been already registered before
  
      Internal function - use "new_<type> instead"