class_docstr: Class for generating metrics and printing it to stdout of the worker
class_docstr_tok: ["Class","for","generating","metrics","and","printing","it","to","stdout","of","the","worker"]
docstr: Constructor for Metric class
  
     Metric class will spawn a thread and report collected metrics to stdout of worker
  
  Parameters
  ----------
  name: str
      Name of metric
  value : int, float
     Can be integer or float
  unit: str
      unit can be one of ms, percent, count, MB, GB or a generic string
  dimensions: list
      list of Dimension objects
  request_id: str
      req_id of metric
  metric_method: str
     useful for defining different operations, optional
docstr_tok: ["Constructor","for","Metric","class","Metric","class","will","spawn","a","thread","and","report","collected","metrics","to","stdout","of","worker","Parameters","--","--","--","--","--","name",":","str","Name","of","metric","value",":","int",",","float","Can","be","integer","or","float","unit",":","str","unit","can","be","one","of","ms",",","percent",",","count",",","MB",",","GB","or","a","generic","string","dimensions",":","list","list","of","Dimension","objects","request_id",":","str","req_id","of","metric","metric_method",":","str","useful","for","defining","different","operations",",","optional"]
code: def __init__(
      self,
      name,
      value,
      unit,
      dimensions,
      request_id=None,
      metric_method=None,
  ):
      """
      Constructor for Metric class
  
         Metric class will spawn a thread and report collected metrics to stdout of worker
  
      Parameters
      ----------
      name: str
          Name of metric
      value : int, float
         Can be integer or float
      unit: str
          unit can be one of ms, percent, count, MB, GB or a generic string
      dimensions: list
          list of Dimension objects
      request_id: str
          req_id of metric
      metric_method: str
         useful for defining different operations, optional
  
      """
      self.metric_type = MetricTypes.COUNTER
      self.dimensions = dimensions
      self.dimension_names = [dim.name for dim in dimensions]
      self.dimension_values = [dim.value for dim in dimensions]
      self._caching_metric = CachingMetric(
          metric_name=name,
          unit=unit,
          dimension_names=self.dimension_names,
          metric_type=self.metric_type,
      )
      self.name = self._caching_metric.metric_name
      self.unit = self._caching_metric.unit
      self.metric_method = metric_method
      self.value = value
      self.request_id = request_id
  
file_path: serve/ts/metrics/metric.py
imports: import socket
  import time
  from builtins import str
  from collections import OrderedDict
  from ts.metrics.caching_metric import CachingMetric
  from ts.metrics.metric_type_enum import MetricTypes
  from ts.metrics.unit import Units
label_desc: Use image node_id 1 to create a new Metric object from inherited base classes: object with example: obj = Metric(name, value, unit, dimensions, request_id, metric_method)