zoukankan      html  css  js  c++  java
  • pinpoint-dubbo插件兼容泛化调用

    背景

    dubbo插件中需要记录当前调用的接口和方法,但是在泛化调用的场景下,记录的接口和方法都变成了

    com.alibaba.dubbo.rpc.service.GenericService:$invoke,需要把它转化为真实的API和方法

    @Override
        public void after(Object target, Object arg0, Object result, Throwable throwable) {
         //插件开关
    if(!traceContext.collectSwitch(traceContext.getApplicationName(),"dubbo",null)){ return ; } Trace trace = this.getTrace(target); if (trace == null) { return; } RpcInvocation invocation = (RpcInvocation) arg0; try { SpanEventRecorder recorder = trace.currentSpanEventRecorder(); String endPoint = RpcContext.getContext().getRemoteAddressString(); recorder.recordApi(descriptor,new Object[]{endPoint}); if (throwable == null) { // RPC client have to record end point (server address) recorder.recordEndPoint(endPoint); // Optionally, record the destination id (logical name of server. e.g. DB name) recorder.recordDestinationId(endPoint); URL url = invocation.getInvoker().getUrl(); // 2017/9/11 上午11:22 记录调用的接口 String interfaceName = ((Invoker)target).getInterface().getName(); String methodName = invocation.getMethodName(); //泛化调用兼容 if (GENERIC_SERVICE.equals(interfaceName) && INVOKE.equals(methodName)) { interfaceName = invocation.getAttachment("interface"); methodName = (String) invocation.getArguments()[0]; } //记录调用的api recorder.recordAttribute(DubboConstants.DUBBO_INTERFACE_ANNOTATION_KEY,interfaceName+":"+methodName); //记录dubbo调用分组 recorder.recordAttribute(DubboConstants.DUBBO_GROUP_ANNOTATION_KEY,url.getParameter("group")); //记录dubbo调用请求参数 recorder.recordAttribute(DubboConstants.DUBBO_ARGS_ANNOTATION_KEY, DubboUtils.getParam(invocation.getArguments(),traceContext)); if (result instanceof RpcResult && trace.isDebug()){ // if (result instanceof RpcResult ){ RpcResult rpcResult = (RpcResult)result; Object value = rpcResult.getValue(); recorder.recordAttribute(DubboConstants.DUBBO_RESULT_ANNOTATION_KEY, traceContext.toJsonString(value)); }else { // recorder.recordAttribute(DubboConstants.DUBBO_RESULT_ANNOTATION_KEY, result); } } else { recorder.recordException(throwable); } } finally { trace.traceBlockEnd(); } }
  • 相关阅读:
    【概率】Uva 10900
    【组合数的唯一分解定理】Uva1635
    【欧拉定理】计算(a^(b^c))%1000000007
    【小小的思路】坑死自己的数学水题
    【杨氏矩阵+勾长公式】POJ 2279 Mr. Young's Picture Permutations
    【dp入门题】【跟着14练dp吧...囧】
    【补】【FZU月赛】【20150515】【待续】
    【二分查找最优解】FZU 2056 最大正方形
    【二进制】FZU 2062 Suneast & Yayamao
    【阔别许久的博】【我要开始攻数学和几何啦】【高精度取模+同余模定理,*】POJ 2365 The Embarrassed Cryptographer
  • 原文地址:https://www.cnblogs.com/yissheng/p/7835156.html
Copyright © 2011-2022 走看看