mirror of
https://github.com/valitydev/yandex-tank.git
synced 2024-11-06 02:15:22 +00:00
phantom instances
This commit is contained in:
parent
acae0631ef
commit
73cd2b9228
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,3 +18,4 @@ dist/
|
||||
yandextank.egg-info/
|
||||
setuptools-*
|
||||
.idea/
|
||||
yandex-tank.iml
|
||||
|
@ -6,16 +6,18 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PandoraStatsReader(object):
|
||||
# TODO: maybe make stats collection asyncronous
|
||||
def next(self):
|
||||
try:
|
||||
pandora_response = requests.get("http://localhost:1234/debug/vars")
|
||||
pandora_stat = pandora_response.json()
|
||||
|
||||
return {'ts': int(time.time() - 1),
|
||||
'metrics': {
|
||||
'instances': pandora_stat.get("engine_ActiveRequests"),
|
||||
'reqps': pandora_stat.get("engine_ReqPS"),
|
||||
}}
|
||||
return [{'ts': int(time.time() - 1),
|
||||
'metrics': {
|
||||
'instances':
|
||||
pandora_stat.get("engine_ActiveRequests"),
|
||||
'reqps': pandora_stat.get("engine_ReqPS"),
|
||||
}}]
|
||||
except requests.ConnectionError:
|
||||
logger.info("Pandora expvar http interface is unavailable")
|
||||
except requests.HTTPError:
|
||||
@ -26,9 +28,9 @@ class PandoraStatsReader(object):
|
||||
pandora_response.text,
|
||||
exc_info=True)
|
||||
|
||||
return {'ts': int(time.time() - 1),
|
||||
'metrics': {'instances': 0,
|
||||
'reqps': 0}}
|
||||
return [{'ts': int(time.time() - 1),
|
||||
'metrics': {'instances': 0,
|
||||
'reqps': 0}}]
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
@ -1,5 +1,6 @@
|
||||
""" Contains Phantom Plugin, Console widgets, result reader classes """
|
||||
# FIXME: 3 there is no graceful way to interrupt the process of phout import
|
||||
# TODO: phout import
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
@ -133,7 +134,9 @@ class PhantomPlugin(AbstractPlugin):
|
||||
" Reading samples from %s", self.predefined_phout)
|
||||
if aggregator:
|
||||
aggregator.reader = reader
|
||||
aggregator.stats_reader = PhantomStatsReader(self.phantom.stat_log)
|
||||
info = self.phantom.get_info()
|
||||
aggregator.stats_reader = PhantomStatsReader(self.phantom.stat_log,
|
||||
info)
|
||||
try:
|
||||
console = self.core.get_plugin_of_type(ConsolePlugin)
|
||||
except Exception, ex:
|
||||
|
@ -59,11 +59,13 @@ class PhantomReader(object):
|
||||
|
||||
|
||||
class PhantomStatsReader(object):
|
||||
def __init__(self, filename):
|
||||
def __init__(self, filename, phantom_info):
|
||||
self.phantom_info = phantom_info
|
||||
self.buffer = ""
|
||||
self.stat_buffer = ""
|
||||
self.stat_filename = filename
|
||||
self.closed = False
|
||||
self.start_time = 0
|
||||
|
||||
def __decode_stat_data(self, chunk):
|
||||
for date_str, statistics in chunk.iteritems():
|
||||
@ -77,15 +79,22 @@ class PhantomStatsReader(object):
|
||||
for method, meth_obj in benchmark.iteritems():
|
||||
if "mmtasks" in meth_obj:
|
||||
instances += meth_obj["mmtasks"][2]
|
||||
|
||||
offset = chunk_date - 1 - self.start_time
|
||||
reqps = 0
|
||||
if offset >= 0 and offset < len(self.phantom_info.steps):
|
||||
reqps = self.phantom_info.steps[offset][0]
|
||||
yield {'ts': chunk_date - 1,
|
||||
'metrics': {'instances': instances,
|
||||
'reqps': 0}}
|
||||
'reqps': reqps}}
|
||||
|
||||
def __iter__(self):
|
||||
"""
|
||||
Union buffer and chunk, split using '\n},',
|
||||
return splitted parts
|
||||
"""
|
||||
self.start_time = int(time.time())
|
||||
logger.info("Phantom steps:\n%s", self.phantom_info.steps)
|
||||
with open(self.stat_filename, 'r') as stat_file:
|
||||
while not self.closed:
|
||||
chunk = stat_file.read(1024 * 1024 * 10)
|
||||
|
Loading…
Reference in New Issue
Block a user