您好,登录后才能下订单哦!
本篇内容主要讲解“怎么解决java的sleuth TraceFeignClient SpanName问题”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么解决java的sleuth TraceFeignClient SpanName问题”吧!
@Override public Response execute(Request request, Request.Options options) throws IOException { String spanName = getSpanName(request); Span span = getTracer().createSpan(spanName); if (log.isDebugEnabled()) { log.debug("Created new Feign span " + span); } try { AtomicReference<Request> feignRequest = new AtomicReference<>(request); this.spanInjector.inject(span, feignRequest); span.logEvent(Span.CLIENT_SEND); addRequestTags(request); Request modifiedRequest = feignRequest.get(); if (log.isDebugEnabled()) { log.debug("The modified request equals " + modifiedRequest); } Response response = this.delegate.execute(modifiedRequest, options); logCr(); return response; } catch (RuntimeException | IOException e) { logError(e); throw e; } finally { closeSpan(span); } } private String getSpanName(Request request) { URI uri = URI.create(request.url()); return uriScheme(uri) + ":" + uri.getPath(); }
默认是根据uri生成spanName.如果是restful风格的话,/getuser/1 /getuser/2 就是2个span.
span一般是一个操作。比如getuser. 参数啊1. tag应该1.
如果要修改默认uri为span。
方案1:
@Headers({"Content-Type: application/json","Accept: application/json",Accept {contentType}}) @PostMapping(value = "/card-blank/batch-create") Response batchCreateCard(@RequestBody CreateCardBlankDTO condition,@Param("contentType") String type);
2.重写getspan方法,从请求头获取spanName
方案二:
能够得知当前feign调用的feignclient java方法,获取方法名称为spanName
重写getspan方法,从请求头获取spanName
到此,相信大家对“怎么解决java的sleuth TraceFeignClient SpanName问题”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。