export_metrics.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:rca-evaluation 作者: sieve-microservices 项目源码 文件源码
def scroll(query, begin, until, prefix=None):
    diff = timedelta(minutes=4)
    while begin < until:
        to = min(begin + diff, until)
        res = DB.query(query % (pad(begin), pad(to)))
        for batch in res:
            for row in batch:
                # truncate longer ids to match with shorter host names
                if "container_id" in row:
                    row["container_id"] = row["container_id"][0:11]

                time_col = row["time"][0:min(26, len(row["time"]) - 1)]
                if len(time_col) == 19:
                    t = time.strptime(time_col, "%Y-%m-%dT%H:%M:%S")
                else:
                    t = time.strptime(time_col, "%Y-%m-%dT%H:%M:%S.%f")

                if prefix is not None:
                    for key in row.iterkeys():
                        if (key not in SKIP_PREFIX) and ((prefix + "|") not in key):
                            row[APP_METRIC_DELIMITER.join((prefix, key))] = row.pop(key)
                yield (time.mktime(t), row)
        begin = to
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号