Beispiel #1
0
 def get(self, name, **query_props):
     resp = self._mexe("metrics/%s" % self.sanitize(name), method="GET", query_props=query_props)
     if resp['type'] == 'gauge':
         return Gauge.from_dict(self, resp)
     elif resp['type'] == 'counter':
         return Counter.from_dict(self, resp)
     else:
         raise Exception('The server sent me something that is not a Gauge nor a Counter.')
Beispiel #2
0
 def get(self, name, **query_props):
     resp = self._mexe("metrics/%s" % self.sanitize(name), method="GET", query_props=query_props)
     if resp['type'] == 'gauge':
         return Gauge.from_dict(self, resp)
     elif resp['type'] == 'counter':
         return Counter.from_dict(self, resp)
     else:
         raise Exception('The server sent me something that is not a Gauge nor a Counter.')
Beispiel #3
0
	def create_counter(self, name, description=None, **query_props):
		"""Create a new counter"""
		from librato.metrics import Counter
		if query_props is None:
			query_props = {}
		query_props['name'] = name
		if description:
			query_props['description'] = description
		resp = self._mexe("counters.json", method="POST", query_props=query_props)
		return Counter.from_dict(self, resp)
Beispiel #4
0
	def get_counter(self, name):
		"""Fetch a specific counter"""
		from librato.metrics import Counter
		resp = self._mexe("counters/%s.json" % name)
		return Counter.from_dict(self, resp)