Dubbo RpcResult 提供者返回消费者数据

在服务治理项目中发现有个蹊跷的问题:

重现步骤:
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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值