博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pinpoint的id的生成
阅读量:6984 次
发布时间:2019-06-27

本文共 1641 字,大约阅读时间需要 5 分钟。

traceId的生成

public String getTransactionId() {        return TransactionIdUtils.formatString(agentId, agentStartTime, transactionSequence);    }    public static final String TRANSACTION_ID_DELIMITER = "^";    public static String formatString(String agentId, long agentStartTime, long transactionSequence) {        if (agentId == null) {            throw new NullPointerException("agentId must not be null");        }        StringBuilder sb = new StringBuilder(64);        sb.append(agentId);        sb.append(TRANSACTION_ID_DELIMITER);        sb.append(agentStartTime);        sb.append(TRANSACTION_ID_DELIMITER);        sb.append(transactionSequence);        return sb.toString();    }

spanId的生成

public class SpanId {    public static final long NULL = -1;//    private static final Random seed = new Random();    public static long newSpanId() {        final Random random = getRandom();        return createSpanId(random);    }    // Changed to ThreadLocalRandom because unique value per thread will be enough.    // If you need to change Random implementation, modify this method.    private static Random getRandom() {        return ThreadLocalRandomUtils.current();    }    private static long createSpanId(Random seed) {        long id = seed.nextLong();        while (id == NULL) {            id = seed.nextLong();        }        return id;    }    public static long nextSpanID(long spanId, long parentSpanId) {        final Random seed = getRandom();        long newId = createSpanId(seed);        while (newId == spanId || newId == parentSpanId) {            newId = createSpanId(seed);        }        return newId;    }}

docs

转载地址:http://fgjpl.baihongyu.com/

你可能感兴趣的文章
Android开发-各种各样好看漂亮的进度条,指示器,加载提示汇总
查看>>
ajax传JSON时设置的contenttype导致JAVA中request.getParameter("")怎么也接收不到数据
查看>>
visual studio 中将选中代码相同的代码的颜色设置,修改高亮颜色
查看>>
Tomcat 配置详解/优化方案(转)
查看>>
2018年目标计划
查看>>
888. 公平的糖果交换
查看>>
使用Python登录Github网站
查看>>
Android wifi powersave
查看>>
Linux安装telnet
查看>>
Access restriction 问题解决
查看>>
virtualenv 运行python 解决依赖冲突问题 尤其是django那种蛋疼的版本问题
查看>>
多核加速处理图像
查看>>
『原创』用C++开发WM应用系列(3)——发送SMS
查看>>
Spring 的优秀工具类盘点,第 2 部分: 特殊字符转义和方法入参检测工具类
查看>>
一个奇怪的编码 big5-hkscs
查看>>
不同情况下的高地址与低地址
查看>>
tcp/ip --IP:网际协议
查看>>
深入理解JavaScript系列(6):S.O.L.I.D五大原则之单一职责SRP
查看>>
onSaveInstanceState和onRestoreInstanceState触发的时机
查看>>
设计模式学习02—工厂模式
查看>>