目前,我正在使用 编写数据点client.write_points
,但我想批量编写数据点。我应该如何进行?这是我的代码。
def send_measurement_to_influx(influx_measurement_payload, client):
try:
client.write_points(influx_measurement_payload)
pass
except Exception as e:
logging.exception("Error while sending measurement {} to influx host", format(str(influx_measurement_payload)),
e, exc_info=True)
def timeit(**kwargs):
def timeit_helper(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if('metric_name' in kwargs):
metric_name = kwargs['metric_name']
client = get_influx_client()
if(client is not None):
influx_measurement_payload = [(generate_influx_payload(metric_name, method.__name__,
method.__module__, (te-ts) * 1000))]
send_measurement_to_influx(influx_measurement_payload, client)
if 'log_time' in kwargs:
name = kwargs.get('log_name', method.__name__.upper())
kwargs['log_time'][name] = int((te - ts) * 1000)
else:
logging.info('%r %2.2f ms' % \
(method.__name__, (te - ts) * 1000))
return result
return timed
return timeit_helper