class_docstr: DEPRECATED
  Class for creating, modifying different metrics. And keep them in a dictionary
class_docstr_tok: ["DEPRECATED","Class","for","creating",",","modifying","different","metrics",".","And","keep","them","in","a","dictionary"]
docstr: Add a metric key value pair
  
  Parameters
  ----------
  name : str
      metric name
  value: int, float
      value of metric
  req_id: str
      request id
  unit: str
      unit of metric
  value: int, float , str
      value of metric
  metrics_method: str, optional
      indicates type of metric operation if it is defined
docstr_tok: ["Add","a","metric","key","value","pair","Parameters","--","--","--","--","--","name",":","str","metric","name","value",":","int",",","float","value","of","metric","req_id",":","str","request","id","unit",":","str","unit","of","metric","value",":","int",",","float",",","str","value","of","metric","metrics_method",":","str",",","optional","indicates","type","of","metric","operation","if","it","is","defined"]
code: def _add_or_update(
      self,
      name,
      value,
      req_id,
      unit,
      metrics_method=None,
      dimensions=None,
  ):
      """
      Add a metric key value pair
  
      Parameters
      ----------
      name : str
          metric name
      value: int, float
          value of metric
      req_id: str
          request id
      unit: str
          unit of metric
      value: int, float , str
          value of metric
      metrics_method: str, optional
          indicates type of metric operation if it is defined
      """
      # IF req_id is none error Metric
      if dimensions is None:
          dimensions = list()
      elif not isinstance(dimensions, list):
          raise ValueError("Please provide a list of dimensions")
      if req_id is None:
          dimensions.append(Dimension("Level", "Error"))
      else:
          dimensions.append(Dimension("ModelName", self.model_name))
          dimensions.append(Dimension("Level", "Model"))
  
      # Cache the metric with an unique key for update
      dim_str = [name, unit, str(req_id)] + [str(d) for d in dimensions]
      dim_str = "-".join(dim_str)
      if dim_str not in self.cache:
          metric = Metric(
              name, value, unit, dimensions, req_id, metrics_method
          )
          self.store.append(metric)
          self.cache[dim_str] = metric
      else:
          self.cache[dim_str].update(value)
  
file_path: serve/ts/metrics/metrics_store.py
imports: from builtins import str
  from ts.metrics.dimension import Dimension
  from ts.metrics.metric import Metric
label_desc: Use image node_id 2 for calling the MetricsStore obj's underlying member method code with example usage: obj._add_or_update(name, value, req_id, unit, metrics_method, dimensions) without return types