def get_root_logger(): logger = metricq.get_logger() logger.setLevel(logging.WARN) click_log.basic_config(logger) # logger.handlers[0].formatter = logging.Formatter( # fmt="%(asctime)s [%(levelname)-8s] [%(name)-20s] %(message)s" # ) return logger
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import asyncio import logging import pprint from datetime import timedelta import click import click_completion import click_log import metricq logger = metricq.get_logger() click_log.basic_config(logger) logger.setLevel("INFO") # Use this if we ever use threads # logger.handlers[0].formatter = logging.Formatter(fmt='%(asctime)s %(threadName)-16s %(levelname)-8s %(message)s') logger.handlers[0].formatter = logging.Formatter( fmt="%(asctime)s [%(levelname)-8s] [%(name)-20s] %(message)s") click_completion.init() async def aget_history(server, token, metric, list_metrics, list_metadata): client = metricq.HistoryClient(token=token, management_url=server, event_loop=asyncio.get_running_loop())
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with metricq-wizard. If not, see <http://www.gnu.org/licenses/>. import importlib from typing import Dict, Optional, Sequence from metricq import get_logger, Timestamp from metricq_wizard_backend.metricq.source_plugin import ( SourcePlugin, EntryPointType, PluginRPCFunctionType, ) logger = get_logger() class UserSession: def __init__( self, session_key: str, ): self.session_key: str = session_key self._source_plugins: Dict[str, SourcePlugin] = {} self._source_config_revision: Dict[str, str] = {} self._source_plugin_creation_time: Dict[str, Timestamp] = {} self._source_plugin_initial_configured_metrics: Dict[str, Sequence[str]] = {} self.creation_time = Timestamp.now() def create_source_plugin(
"""Module for view functions""" import time from asyncio import TimeoutError from aiohttp import web from metricq import get_logger from .amqp import ( get_counter_data, get_counter_list, get_history_data, get_metric_list, get_metadata, ) logger = get_logger(__name__) async def query(request): req_json = await request.json() logger.debug("Query request data: {}", req_json) try: perf_begin_ns = time.perf_counter_ns() perf_begin_process_ns = time.process_time_ns() resp = await get_history_data(request.app, req_json) perf_end_ns = time.perf_counter_ns() perf_end_process_ns = time.process_time_ns() headers = { "x-request-duration": str((perf_end_ns - perf_begin_ns) / 1e9), "x-request-duration-cpu":