Skip to content

Commit

Permalink
[metrics] Remove unused unit field from cython classes (#14497)
Browse files Browse the repository at this point in the history
  • Loading branch information
edoakes committed Mar 8, 2021
1 parent dec3aa3 commit 8e13904
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
26 changes: 9 additions & 17 deletions python/ray/includes/metric.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
)
)
Expand All @@ -106,7 +104,6 @@ cdef class Count(Metric):
>>> count = Count(
"ray.worker.metric",
"description",
"unit",
["tagk1", "tagk2"]).
value = 5
key1= "key1"
Expand All @@ -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)
Expand All @@ -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
)
)
Expand All @@ -145,7 +141,6 @@ cdef class Sum(Metric):
>>> metric_sum = Sum(
"ray.worker.metric",
"description",
"unit",
["tagk1", "tagk2"]).
value = 5
key1= "key1"
Expand All @@ -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.
"""

Expand All @@ -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
)
)
Expand All @@ -184,8 +178,7 @@ cdef class Histogram(Metric):
>>> histogram = Histogram(
"ray.worker.histogram1",
"desciprtion",
"unit",
"description",
[1.0, 2.0], # boundaries.
["tagk1"])
value = 5
Expand All @@ -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.
"""
Expand All @@ -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
)
Expand Down
10 changes: 3 additions & 7 deletions python/ray/util/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 8e13904

Please sign in to comment.