예제 #1
0
파일: perf.py 프로젝트: jiankunking/snuba
def perf(
    *,
    events_file: Optional[str],
    repeat: int,
    profile_process: bool,
    profile_write: bool,
    dataset_name: str,
    log_level: Optional[str] = None,
) -> None:
    from snuba.perf import run, logger

    setup_logging(log_level)

    dataset = get_dataset(dataset_name)
    if not local_dataset_mode():
        logger.error(
            "The perf tool is only intended for local dataset environment.")
        sys.exit(1)

    run(
        events_file,
        dataset,
        repeat=repeat,
        profile_process=profile_process,
        profile_write=profile_write,
    )
예제 #2
0
파일: tables.py 프로젝트: forkkit/snuba
 def get_table_name(self) -> str:
     """
     This represents the table we interact with to send queries to Clickhouse.
     In distributed mode this will be a distributed table. In local mode it is a local table.
     """
     table_name = self.__local_table_name if local_dataset_mode(
     ) else self.__dist_table_name
     return self._make_test_table(table_name)
예제 #3
0
    def ensure_table_exists(dataset, force=False):
        if not force and _ensured.get(dataset, False):
            return

        assert local_dataset_mode(), "Cannot create table in distributed mode"

        from snuba import migrate

        # We cannot build distributed tables this way. So this only works in local
        # mode.
        for statement in dataset.get_dataset_schemas().get_create_statements():
            clickhouse_rw.execute(statement)

        migrate.run(clickhouse_rw, dataset)

        _ensured[dataset] = True
예제 #4
0
파일: migrate.py 프로젝트: forkkit/snuba
def migrate(log_level):
    from snuba.migrate import logger, run
    # TODO: this only supports one dataset so far. More work is needed for the others.
    dataset = get_dataset('events')
    logging.basicConfig(level=getattr(logging, log_level.upper()), format='%(asctime)s %(message)s')

    if not local_dataset_mode():
        logger.error("The migration tool can only work on local dataset mode.")
        sys.exit(1)

    clickhouse = Client(
        host=settings.CLICKHOUSE_HOST,
        port=settings.CLICKHOUSE_PORT,
    )

    run(clickhouse, dataset)
예제 #5
0
파일: perf.py 프로젝트: forkkit/snuba
def perf(events_file, repeat, profile_process, profile_write, dataset,
         log_level):
    from snuba.perf import run, logger

    logging.basicConfig(level=getattr(logging, log_level.upper()),
                        format='%(asctime)s %(message)s')

    dataset = get_dataset(dataset)
    if not local_dataset_mode():
        logger.error(
            "The perf tool is only intended for local dataset environment.")
        sys.exit(1)

    run(events_file,
        dataset,
        repeat=repeat,
        profile_process=profile_process,
        profile_write=profile_write)
예제 #6
0
def migrate(*,
            log_level: Optional[str] = None,
            dataset_name: Optional[str] = None) -> None:
    from snuba.migrate import logger, run

    setup_logging(log_level)

    if not local_dataset_mode():
        logger.error("The migration tool can only work on local dataset mode.")
        sys.exit(1)

    dataset_names = [dataset_name] if dataset_name else DATASET_NAMES
    for name in dataset_names:
        dataset = get_dataset(name)
        logger.info("Migrating dataset %s", name)

        clickhouse = Client(
            host=settings.CLICKHOUSE_HOST,
            port=settings.CLICKHOUSE_PORT,
        )

        run(clickhouse, dataset)