Unified tag names
with this change the tags related to method and class name will not be hyphen delimited. fixes #359
This commit is contained in:
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.sleuth.instrument.web;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -87,8 +87,7 @@ public class TraceHandlerInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
private void addClassMethodTag(Object handler, Span span) {
|
||||
if (handler instanceof HandlerMethod) {
|
||||
String methodName = SpanNameUtil.toLowerHyphen(
|
||||
((HandlerMethod) handler).getMethod().getName());
|
||||
String methodName = ((HandlerMethod) handler).getMethod().getName();
|
||||
getTracer().addTag(getTraceKeys().getMvc().getControllerMethod(), methodName);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Adding a method tag with value [" + methodName + "] to a span " + span);
|
||||
@@ -99,10 +98,9 @@ public class TraceHandlerInterceptor extends HandlerInterceptorAdapter {
|
||||
private void addClassNameTag(Object handler, Span span) {
|
||||
String className;
|
||||
if (handler instanceof HandlerMethod) {
|
||||
className = SpanNameUtil.toLowerHyphen(
|
||||
((HandlerMethod) handler).getBeanType().getSimpleName());
|
||||
className = ((HandlerMethod) handler).getBeanType().getSimpleName();
|
||||
} else {
|
||||
className = SpanNameUtil.toLowerHyphen(handler.getClass().getSimpleName());
|
||||
className = handler.getClass().getSimpleName();
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Adding a class tag with value [" + className + "] to a span " + span);
|
||||
|
||||
@@ -105,7 +105,7 @@ public class TraceFilterIntegrationTests extends AbstractMvcIntegrationTest {
|
||||
Long expectedTraceId = new Random().nextLong();
|
||||
|
||||
MvcResult mvcResult = whenSentFutureWithTraceId(expectedTraceId);
|
||||
mvcResult = this.mockMvc.perform(asyncDispatch(mvcResult))
|
||||
this.mockMvc.perform(asyncDispatch(mvcResult))
|
||||
.andExpect(status().isOk()).andReturn();
|
||||
|
||||
then(tracingHeaderFrom(mvcResult)).isEqualTo(expectedTraceId);
|
||||
@@ -118,7 +118,7 @@ public class TraceFilterIntegrationTests extends AbstractMvcIntegrationTest {
|
||||
Long expectedTraceId = new Random().nextLong();
|
||||
|
||||
MvcResult mvcResult = whenSentDeferredWithTraceId(expectedTraceId);
|
||||
mvcResult = this.mockMvc.perform(asyncDispatch(mvcResult))
|
||||
this.mockMvc.perform(asyncDispatch(mvcResult))
|
||||
.andExpect(status().isOk()).andReturn();
|
||||
|
||||
then(tracingHeaderFrom(mvcResult)).isEqualTo(expectedTraceId);
|
||||
@@ -126,8 +126,8 @@ public class TraceFilterIntegrationTests extends AbstractMvcIntegrationTest {
|
||||
.filter(span -> span.tags().containsKey("tag")).findFirst();
|
||||
then(taggedSpan.isPresent()).isTrue();
|
||||
then(taggedSpan.get()).hasATag("tag", "value");
|
||||
then(taggedSpan.get()).hasATag("mvc.controller.method", "deferred");
|
||||
then(taggedSpan.get()).hasATag("mvc.controller.class", "test-controller");
|
||||
then(taggedSpan.get()).hasATag("mvc.controller.method", "deferredMethod");
|
||||
then(taggedSpan.get()).hasATag("mvc.controller.class", "TestController");
|
||||
then(ExceptionUtils.getLastException()).isNull();
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public class TraceFilterIntegrationTests extends AbstractMvcIntegrationTest {
|
||||
}
|
||||
|
||||
@RequestMapping("/deferred")
|
||||
public DeferredResult<String> deferred() {
|
||||
public DeferredResult<String> deferredMethod() {
|
||||
logger.info("deferred");
|
||||
this.tracer.addTag("tag", "value");
|
||||
span = this.tracer.getCurrentSpan();
|
||||
|
||||
Reference in New Issue
Block a user