Skip to content

Commit

Permalink
Update documentation for custom metrics API arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Naman Nandan committed Aug 11, 2023
1 parent 4db3328 commit f5bcf4e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions ts/metrics/caching_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _validate_and_get_dimensions(
values corresponding to the metrics dimension names
Returns
-------
list of dimension objects or ValueError
list of Dimension objects or ValueError
"""
if dimension_values is None or len(dimension_values) != len(
self.dimension_names
Expand Down Expand Up @@ -157,7 +157,7 @@ def update(
request_id : str
request id to be associated with the metric
dimensions : list
list of dimension objects
list of Dimension objects
"""
logger.warning("Overriding existing dimensions")
self.dimension_names = [dim.name for dim in dimensions]
Expand Down
12 changes: 8 additions & 4 deletions ts/metrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
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

MetricUnit = Units()
Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(
unit: str
unit can be one of ms, percent, count, MB, GB or a generic string
dimensions: list
list of dimension objects
list of Dimension objects
request_id: str
req_id of metric
metric_method: str
Expand Down Expand Up @@ -73,13 +73,17 @@ def update(self, value):
value : int, float
metric to be updated
"""
self._caching_metric.add_or_update(value, self.dimension_values, request_id=self.request_id)
self._caching_metric.add_or_update(
value, self.dimension_values, request_id=self.request_id
)

def reset(self):
"""
Reset Metric value to 0
"""
self._caching_metric.add_or_update(0, self.dimension_values, request_id=self.request_id)
self._caching_metric.add_or_update(
0, self.dimension_values, request_id=self.request_id
)

def __str__(self):
dims = ",".join([str(d) for d in self.dimensions])
Expand Down
12 changes: 6 additions & 6 deletions ts/metrics/metric_cache_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def add_metric(
idx: str
request id to be associated with the metric
dimensions: list
list of dimension objects for the metric
list of Dimension objects for the metric
metric_type MetricTypes
Type of metric Counter, Gauge, Histogram
"""
Expand Down Expand Up @@ -122,7 +122,7 @@ def add_counter(
idx: str
request id to be associated with the metric
dimensions: list
list of dimension objects for the metric
list of Dimension objects for the metric
"""
req_id = self._get_req(idx)
dimensions = self._add_default_dims(req_id, dimensions)
Expand Down Expand Up @@ -153,7 +153,7 @@ def add_time(
unit: str
unit of metric, default here is ms, s is also accepted
dimensions: list
list of dimension objects for the metric
list of Dimension objects for the metric
metric_type MetricTypes
Type of metric Counter, Gauge, Histogram
"""
Expand Down Expand Up @@ -190,7 +190,7 @@ def add_size(
unit: str
unit of metric, default here is 'MB', 'kB', 'GB' also supported
dimensions: list
list of dimension objects for the metric
list of Dimension objects for the metric
metric_type MetricTypes
Type of metric Counter, Gauge, Histogram
"""
Expand Down Expand Up @@ -224,7 +224,7 @@ def add_percent(
idx: str
request id to be associated with the metric
dimensions: list
list of dimension objects for the metric
list of Dimension objects for the metric
metric_type MetricTypes
Type of metric Counter, Gauge, Histogram
"""
Expand All @@ -250,7 +250,7 @@ def add_error(
value: int or float
value of the metric
dimensions: list
list of dimension objects for the metric
list of Dimension objects for the metric
"""
dimensions = self._add_default_dims(None, dimensions)
metric = self._get_or_add_metric(name, "", dimensions, MetricTypes.COUNTER)
Expand Down

0 comments on commit f5bcf4e

Please sign in to comment.