summaryrefslogtreecommitdiff
path: root/kafka/metrics/metric_config.py
diff options
context:
space:
mode:
authorZack Dever <zdever@pandora.com>2016-04-07 18:36:14 -0700
committerZack Dever <zdever@pandora.com>2016-04-13 17:26:38 -0700
commit64e9cebfa5e883464cfe76af0c3476ae542ac17b (patch)
tree0f011c36c12076df940f49d5b58fd16b46e9b5b6 /kafka/metrics/metric_config.py
parent0c94b83a2dff8113b5fd7c16df8a11ca03c4377b (diff)
downloadkafka-python-64e9cebfa5e883464cfe76af0c3476ae542ac17b.tar.gz
Kafka metrics java port. No reporters or instrumentation.
There is no straight translation for the JMX reporter into python, so I'll do something else in a separate commit.
Diffstat (limited to 'kafka/metrics/metric_config.py')
-rw-r--r--kafka/metrics/metric_config.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/kafka/metrics/metric_config.py b/kafka/metrics/metric_config.py
new file mode 100644
index 0000000..e30c477
--- /dev/null
+++ b/kafka/metrics/metric_config.py
@@ -0,0 +1,31 @@
+import sys
+
+
+class MetricConfig(object):
+ """Configuration values for metrics"""
+ def __init__(self, quota=None, samples=2, event_window=sys.maxsize,
+ time_window_ms=30 * 1000, tags=None):
+ """
+ Arguments:
+ quota (Quota, optional): Upper or lower bound of a value.
+ samples (int, optional): Max number of samples kept per metric.
+ event_window (int, optional): Max number of values per sample.
+ time_window_ms (int, optional): Max age of an individual sample.
+ tags (dict of {str: str}, optional): Tags for each metric.
+ """
+ self.quota = quota
+ self._samples = samples
+ self.event_window = event_window
+ self.time_window_ms = time_window_ms
+ # tags should be OrderedDict (not supported in py26)
+ self.tags = tags if tags else {}
+
+ @property
+ def samples(self):
+ return self._samples
+
+ @samples.setter
+ def samples(self, value):
+ if value < 1:
+ raise ValueError('The number of samples must be at least 1.')
+ self._samples = value