Search in sources :

Example 1 with LoadTestAwareAppender

use of com.alipay.common.tracer.core.appender.file.LoadTestAwareAppender in project sofa-rpc by sofastack.

the class AbstractRpcStatJsonReporter method print.

@Override
public void print(StatKey statKey, long[] values) {
    if (this.isClosePrint.get()) {
        // 关闭统计日志输出
        return;
    }
    StatMapKey statMapKey = (StatMapKey) statKey;
    buffer.reset();
    buffer.appendBegin("time", Timestamp.currentTime());
    buffer.append("stat.key", this.statKeySplit(statMapKey));
    buffer.append("count", values[0]);
    buffer.append("total.cost.milliseconds", values[1]);
    buffer.append("success", statMapKey.getResult());
    buffer.appendEnd();
    try {
        if (appender instanceof LoadTestAwareAppender) {
            ((LoadTestAwareAppender) appender).append(buffer.toString(), statKey.isLoadTest());
        } else {
            appender.append(buffer.toString());
        }
        // 这里强制刷一次
        appender.flush();
    } catch (Throwable t) {
        SelfLog.error("统计日志<" + statTracerName + ">输出异常", t);
    }
}
Also used : StatMapKey(com.alipay.common.tracer.core.reporter.stat.model.StatMapKey) LoadTestAwareAppender(com.alipay.common.tracer.core.appender.file.LoadTestAwareAppender)

Aggregations

LoadTestAwareAppender (com.alipay.common.tracer.core.appender.file.LoadTestAwareAppender)1 StatMapKey (com.alipay.common.tracer.core.reporter.stat.model.StatMapKey)1