From 1b2d3795aacd9c4694dcfb69a13d3a6af508f2af Mon Sep 17 00:00:00 2001 From: Pieter Cailliau Date: Mon, 1 Sep 2014 14:16:18 +0200 Subject: [PATCH] bugfix aligning service names --- .../resteasy/BravePreProcessInterceptor.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/brave-resteasy-spring/src/main/java/com/github/kristofa/brave/resteasy/BravePreProcessInterceptor.java b/brave-resteasy-spring/src/main/java/com/github/kristofa/brave/resteasy/BravePreProcessInterceptor.java index 8aac0343bf..be9d526714 100755 --- a/brave-resteasy-spring/src/main/java/com/github/kristofa/brave/resteasy/BravePreProcessInterceptor.java +++ b/brave-resteasy-spring/src/main/java/com/github/kristofa/brave/resteasy/BravePreProcessInterceptor.java @@ -37,7 +37,7 @@ *
  • If no trace information is submitted we will start a new span. In that case it means client does not support tracing * and should be adapted.
  • * - * + * * @author kristof */ @Component @@ -55,7 +55,7 @@ public class BravePreProcessInterceptor implements PreProcessInterceptor { /** * Creates a new instance. - * + * * @param endPointSubmitter {@link EndPointSubmitter}. Should not be null. * @param serverTracer {@link ServerTracer}. Should not be null. * @param randomGenerator Random generator. @@ -111,12 +111,21 @@ private void submitEndpoint() { if (!endPointSubmitter.endPointSubmitted()) { final String localAddr = servletRequest.getLocalAddr(); final int localPort = servletRequest.getLocalPort(); - final String contextPath = servletRequest.getContextPath(); + final String contextPath = getContextPathWithoutFirstSlash(); LOGGER.debug("Setting endpoint: addr: {}, port: {}, contextpath: {}", localAddr, localPort, contextPath); endPointSubmitter.submit(localAddr, localPort, contextPath); } } + private String getContextPathWithoutFirstSlash() { + final String contextPath = servletRequest.getContextPath(); + if (contextPath.startsWith("/")) { + return contextPath.substring(1); + } else { + return contextPath; + } + } + private TraceData getTraceData(final HttpRequest request) { final HttpHeaders httpHeaders = request.getHttpHeaders(); final MultivaluedMap requestHeaders = httpHeaders.getRequestHeaders();