Add 'commit' parameter to put_meter for immediate data sending
Change-Id: I17295f73e1485f0c213a1d656347725228e1c014
This commit is contained in:
parent
cb0575cafc
commit
56cbed64cf
@ -24,7 +24,7 @@ class BaseOpenTSDBClient(object):
|
|||||||
"""Get info about what metrics are registered and with what stats."""
|
"""Get info about what metrics are registered and with what stats."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def put_meter(self, meters):
|
def put_meter(self, meters, **kwargs):
|
||||||
"""Post new meter(s) to the database.
|
"""Post new meter(s) to the database.
|
||||||
|
|
||||||
Meter dictionary *should* contain the following four required fields:
|
Meter dictionary *should* contain the following four required fields:
|
||||||
|
@ -160,17 +160,22 @@ class SocketOpenTSDBClient(base.BaseOpenTSDBClient):
|
|||||||
LOG.error('Failed to connect to %s:%d', self.host, self.port)
|
LOG.error('Failed to connect to %s:%d', self.host, self.port)
|
||||||
self.blacklist_tsd_host()
|
self.blacklist_tsd_host()
|
||||||
|
|
||||||
def put_meter(self, meters):
|
def put_meter(self, meters, commit=False):
|
||||||
"""Post new meter(s) to the database.
|
"""Post new meter(s) to the database.
|
||||||
|
|
||||||
Meter dictionary *should* contain the following four required fields:
|
:param meters: dictionary containing only four required fields:
|
||||||
- metric: the name of the metric you are storing
|
- metric: the name of the metric you are storing
|
||||||
- timestamp: a Unix epoch style timestamp in seconds or milliseconds.
|
- timestamp: a Unix epoch style timestamp in seconds or
|
||||||
The timestamp must not contain non-numeric characters.
|
milliseconds. The timestamp must not contain
|
||||||
- value: the value to record for this data point. It may be quoted or
|
non-numeric characters.
|
||||||
not quoted and must conform to the OpenTSDB value rules.
|
- value: the value to record for this data point.
|
||||||
- tags: a map of tag name/tag value pairs. At least one pair must be
|
It may be quoted or not quoted and must conform to the
|
||||||
supplied.
|
OpenTSDB value rules.
|
||||||
|
- tags: a map of tag name/tag value pairs. At least one
|
||||||
|
pair must be supplied.
|
||||||
|
:param commit: bool variable defining if data sending *should* be
|
||||||
|
processed immediately (no matter if queue is full or
|
||||||
|
not)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# put meter to the send_queue and check if it's time to send it to the
|
# put meter to the send_queue and check if it's time to send it to the
|
||||||
@ -178,7 +183,7 @@ class SocketOpenTSDBClient(base.BaseOpenTSDBClient):
|
|||||||
meters = self._check_meters(meters)
|
meters = self._check_meters(meters)
|
||||||
self.send_queue = list(itertools.chain(self.send_queue, meters))
|
self.send_queue = list(itertools.chain(self.send_queue, meters))
|
||||||
|
|
||||||
if len(self.send_queue) <= self.send_queue_max_size:
|
if len(self.send_queue) <= self.send_queue_max_size and not commit:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.maintain_connection()
|
self.maintain_connection()
|
||||||
|
Loading…
Reference in New Issue
Block a user