def test_get(self): """ Tests get function. """ sample_arango_db_dict_conf = { 'GRAPH_DB_NAME': 'graph_db', 'GRAPH_DIFF_DB_NAME': 'graph_diff_db' } self.assertIsInstance(my_config.get('GRAPHY'), dict) self.assertEqual(my_config.get('TEST_12345'), dict()) self.assertEqual( my_config.get('ARANGODB').get('GRAPH_DB_NAME'), sample_arango_db_dict_conf.get('GRAPH_DB_NAME')) self.assertEqual( my_config.get('ARANGODB').get('GRAPH_DIFF_DB_NAME'), sample_arango_db_dict_conf.get('GRAPH_DIFF_DB_NAME'))
def setUp(self) -> None: super().setUp() arango_db_config = config.get('ARANGODB') self.__graph_db = arango_db_config.get('GRAPH_DB_NAME') self.__graph_diff_db = arango_db_config.get('GRAPH_DIFF_DB_NAME') self.__arango = arangodb.ArangoDB()
def run(): graphy_config = config.get('GRAPHY') trace_files = graphy_config.get('TRACE_FILES') view = ConsoleView() controller = Controller(view) processes = [] for trace_file in trace_files: p = multiprocessing.Process(target=controller.setup_zipkin, args=(trace_file, )) processes.append(p) p.start() for process in processes: process.join() controller.start()
import sys import potsdb import requests from graphy.utils import config from graphy.utils import logger as my_logger try: import simplejson as json except ImportError: import json logger = my_logger.setup_logging(__name__) opentsdb_config = config.get('OPENTSDB') opentsdb_address = '{}://{}:{}/'.format(opentsdb_config['PROTOCOL'], opentsdb_config['HOST'], opentsdb_config['PORT']) api_query = 'api/query' def format_metric_name(naming_list): """ Format the metric name. :param naming_list: List of names to append to the metric_name. :return: The metric name. """ metric_name = '{}'.format(opentsdb_config['STORE_NAME']) for name in naming_list: metric_name += '.{}'.format(name)
""" Author: André Bento Date last modified: 08-03-2019 """ from arango import ArangoClient from graphy.utils import config arango_db_config = config.get('ARANGODB') class ArangoDB(object): def __init__(self, purge_database=False): """ Initializes the ArangoDB entity. :param purge_database: True to purge all existing database, False otherwise. """ self.__ip = arango_db_config.get('HOST') self.__port = arango_db_config.get('PORT') self.__username = arango_db_config.get('USERNAME') self.__password = arango_db_config.get('PASSWORD') self.__graph_db = arango_db_config.get('GRAPH_DB_NAME') self.__graph_diff_db = arango_db_config.get('GRAPH_DIFF_DB_NAME') self.__client = ArangoClient(host=self.__ip, port=self.__port) self.__db = self.__sys_db()
import os import sys import time from graphy.controller import controller_logic as cl from graphy.models import trace as my_trace from graphy.utils import config, files from graphy.utils import json as my_json from graphy.utils import list as my_list from graphy.utils import logger as my_logger from graphy.utils import time as my_time from graphy.utils import zipkin logger = my_logger.setup_logging(__name__) graphy_config = config.get('GRAPHY') class Controller(object): def __init__(self, view, model=None): self.model = model self.view = view self.__start_date_time_str = graphy_config.get('DEFAULT_START_TIME') self.__end_date_time_str = graphy_config.get('DEFAULT_END_TIME') self.__is_zipkin = graphy_config.get('ACTIVATE_ZIPKIN') def start(self): """ Starts the controller. """ self.view.start_view()
import time import requests from graphy.utils import config from graphy.utils import files as my_files from graphy.utils import logger as my_logger try: import simplejson as json except ImportError: import json logger = my_logger.setup_logging(__name__) zipkin_config = config.get('ZIPKIN') zipkin_protocol = zipkin_config['PROTOCOL'] zipkin_address = zipkin_config['ADDRESS'] base_address = '{}://{}'.format(zipkin_protocol, zipkin_address) api_v1_endpoint = zipkin_config['API_V1'] api_v2_endpoint = zipkin_config['API_V2'] address_v1 = base_address + api_v1_endpoint address_v2 = base_address + api_v2_endpoint headers = {'content-type': 'application/json'} class ZipkinTraceLimit(Exception): """ Exception for Zipkin request trace limit. # """
def test_format_metric_name(self): """ Tests format_metric_name function. """ naming_list = ['test', 'name'] expected_result = '{}.{}.{}'.format(my_config.get('OPENTSDB').get('STORE_NAME'), naming_list[0], naming_list[1]) self.assertEqual(opentsdb.format_metric_name(naming_list), expected_result)