在服务治理项目中发现有个蹊跷的问题:
重现步骤:
1、参考Dapper论文,提供者会需要记录SR、SS信息
2、提供者包装SR、SS信息,记录到RpcResult的attachments中
private void setRpcResult(RpcResult result,Span span,String startTime){
Map<String, String> attachments = new HashMap<String, String>();
attachments.put(TraceConstants.TRACE_ID, span.getTraceId());
attachments.put(TraceConstants.SPAN_ID, span.getSpanId());
attachments.put(TraceConstants.SR_TIME, startTime);
attachments.put(TraceConstants.SS_TIME, String.valueOf(System.currentTimeMillis()));
attachments.put(TraceConstants.APP_NAME, String.valueOf(conf.getAppCode()));
attachments.put(TraceConstants.PROD_LINE, String.valueOf(conf.getProdline()));
attachments.put(TraceConstants.OWNER, String.valueOf(conf.getOwner()));
if(span.getAnnotations().size() == 2){
Annotation ssAnnotation = span.getAnnotations().get(0);
Annotation srAnnotation = span.getAnnotations().get(1);
attachments.put(TraceConstants.SR_ATTACHMENT, JSONObject.toJSONString(ssAnnotation));
attachments.put(TraceConstants.SS_ATTACHMENT, JSONObject.toJSONString(srAnnotation));
}
result.getAttachments().putAll(attachments);
}
3、消费者过滤器获取RpcResult获取不到SR、SS信息
rpcResult = (RpcResult) invoker.invoke(invocation);
快捷键
- 加粗
Ctrl + B
- 斜体
Ctrl + I
- 引用
Ctrl + Q
- 插入链接
Ctrl + L
- 插入代码
Ctrl + K
- 插入图片
Ctrl + G
- 提升标题
Ctrl + H
- 有序列表
Ctrl + O
- 无序列表
Ctrl + U
- 横线
Ctrl + R
- 撤销
Ctrl + Z
- 重做
Ctrl + Y