From 8e139046b9a8f52dccf60bd4325207f45e0190b5 Mon Sep 17 00:00:00 2001 From: Edward Oakes Date: Sun, 7 Mar 2021 20:06:02 -0600 Subject: [PATCH] [metrics] Remove unused unit field from cython classes (#14497) --- python/ray/includes/metric.pxi | 26 +++++++++----------------- python/ray/util/metrics.py | 10 +++------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/python/ray/includes/metric.pxi b/python/ray/includes/metric.pxi index ba89ba8405b5f..811870af19059 100644 --- a/python/ray/includes/metric.pxi +++ b/python/ray/includes/metric.pxi @@ -70,20 +70,18 @@ cdef class Gauge(Metric): >>> gauge = Gauge( "ray.worker.metric", "description", - "unit", ["tagk1", "tagk2"]). value = 5 key1= "key1" key2 = "key2" gauge.record(value, {"tagk1": key1, "tagk2": key2}) """ - def __init__(self, name, description, unit, tag_keys): + def __init__(self, name, description, tag_keys): """Create a gauge metric Args: name (string): metric name. description (string): description of this metric. - unit (string): measure unit of this metric. tag_keys (list): a list of tay keys in string format. """ super().__init__(tag_keys) @@ -92,7 +90,7 @@ cdef class Gauge(Metric): new CGauge( name.encode("ascii"), description.encode("ascii"), - unit.encode("ascii"), + b"", # Unit, unused. self.c_tag_keys ) ) @@ -106,7 +104,6 @@ cdef class Count(Metric): >>> count = Count( "ray.worker.metric", "description", - "unit", ["tagk1", "tagk2"]). value = 5 key1= "key1" @@ -116,13 +113,12 @@ cdef class Count(Metric): Count: The count of the number of metric points. """ - def __init__(self, name, description, unit, tag_keys): + def __init__(self, name, description, tag_keys): """Create a count metric Args: name (string): metric name. description (string): description of this metric. - unit (string): measure unit of this metric. tag_keys (list): a list of tay keys in string format. """ super().__init__(tag_keys) @@ -131,7 +127,7 @@ cdef class Count(Metric): new CCount( name.encode("ascii"), description.encode("ascii"), - unit.encode("ascii"), + b"", # Unit, unused. self.c_tag_keys ) ) @@ -145,7 +141,6 @@ cdef class Sum(Metric): >>> metric_sum = Sum( "ray.worker.metric", "description", - "unit", ["tagk1", "tagk2"]). value = 5 key1= "key1" @@ -155,13 +150,12 @@ cdef class Sum(Metric): Sum: A sum up of the metric points. """ - def __init__(self, name, description, unit, tag_keys): + def __init__(self, name, description, tag_keys): """Create a sum metric Args: name (string): metric name. description (string): description of this metric. - unit (string): measure unit of this metric. tag_keys (list): a list of tay keys in string format. """ @@ -171,7 +165,7 @@ cdef class Sum(Metric): new CSum( name.encode("ascii"), description.encode("ascii"), - unit.encode("ascii"), + b"", # Unit, unused. self.c_tag_keys ) ) @@ -184,8 +178,7 @@ cdef class Histogram(Metric): >>> histogram = Histogram( "ray.worker.histogram1", - "desciprtion", - "unit", + "description", [1.0, 2.0], # boundaries. ["tagk1"]) value = 5 @@ -195,13 +188,12 @@ cdef class Histogram(Metric): Histogram: Histogram distribution of metric points. """ - def __init__(self, name, description, unit, boundaries, tag_keys): + def __init__(self, name, description, boundaries, tag_keys): """Create a sum metric Args: name (string): metric name. description (string): description of this metric. - unit (string): measure unit of this metric. boundaries (list): a double type list boundaries of histogram. tag_keys (list): a list of tay key in string format. """ @@ -216,7 +208,7 @@ cdef class Histogram(Metric): new CHistogram( name.encode("ascii"), description.encode("ascii"), - unit.encode("ascii"), + b"", # Unit, unused. c_boundaries, self.c_tag_keys ) diff --git a/python/ray/util/metrics.py b/python/ray/util/metrics.py index 57a01cf7aa0b4..1edc9fd8ec9b6 100644 --- a/python/ray/util/metrics.py +++ b/python/ray/util/metrics.py @@ -27,9 +27,6 @@ def __init__(self, "Please provide a metric name.") self._name = name self._description = description - # We don't specify unit because it won't be - # exported to Prometheus anyway. - self._unit = "" # The default tags key-value pair. self._default_tags = {} # Keys of tags. @@ -144,7 +141,7 @@ def __init__(self, description: str = "", tag_keys: Optional[Tuple[str]] = None): super().__init__(name, description, tag_keys) - self._metric = CythonCount(self._name, self._description, self._unit, + self._metric = CythonCount(self._name, self._description, self._tag_keys) def __reduce__(self): @@ -179,8 +176,7 @@ def __init__(self, "Histogram class. e.g., Histogram(boundaries=[1.0, 2.0])") self.boundaries = boundaries self._metric = CythonHistogram(self._name, self._description, - self._unit, self.boundaries, - self._tag_keys) + self.boundaries, self._tag_keys) def __reduce__(self): deserializer = Histogram @@ -212,7 +208,7 @@ def __init__(self, description: str = "", tag_keys: Optional[Tuple[str]] = None): super().__init__(name, description, tag_keys) - self._metric = CythonGauge(self._name, self._description, self._unit, + self._metric = CythonGauge(self._name, self._description, self._tag_keys) def __reduce__(self):