Apply standard tag name and update spring-web test deps version.
MODIFY
dd-java-agent/instrumentation/jetty-8/src/main/java/datadog/trace/instrumentation/jetty8/JettyHandlerAdvice.java
dd-java-agent/instrumentation/jetty-8/src/main/java/datadog/trace/instrumentation/jetty8/JettyHandlerAdvice.java
@@ -52,7 +52,7 @@ public class JettyHandlerAdvice {
Tags.HTTP_URL.set(span, req.getRequestURL().toString());
span.setTag(DDTags.RESOURCE_NAME, resourceName);
if (req.getUserPrincipal() != null) {
- span.setTag("user.principal", req.getUserPrincipal().getName());
+ span.setTag(DDTags.USER_NAME, req.getUserPrincipal().getName());
}
return scope;
}

MODIFY
dd-java-agent/instrumentation/servlet-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Advice.java
dd-java-agent/instrumentation/servlet-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Advice.java
@@ -64,7 +64,7 @@ public class Servlet2Advice {
if (req instanceof HttpServletRequest) {
final Principal principal = ((HttpServletRequest) req).getUserPrincipal();
if (principal != null) {
- currentSpan.setTag("user.principal", principal.getName());
+ currentSpan.setTag(DDTags.USER_NAME, principal.getName());
}
}
}

MODIFY
dd-java-agent/instrumentation/servlet-2/src/test/groovy/JettyServlet2Test.groovy
dd-java-agent/instrumentation/servlet-2/src/test/groovy/JettyServlet2Test.groovy
@@ -2,6 +2,7 @@ import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.agent.test.TestUtils
import datadog.trace.agent.test.utils.OkHttpUtils
import datadog.trace.api.DDSpanTypes
+import datadog.trace.api.DDTags
import okhttp3.Credentials
import okhttp3.Interceptor
import okhttp3.OkHttpClient
@@ -94,7 +95,7 @@ class JettyServlet2Test extends AgentTestRunner {
"span.type" DDSpanTypes.WEB_SERVLET
"servlet.context" "/ctx"
if (auth) {
- "user.principal" "user"
+ "$DDTags.USER_NAME" "user"
}
defaultTags(distributedTracing)
}

MODIFY
dd-java-agent/instrumentation/servlet-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Advice.java
dd-java-agent/instrumentation/servlet-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Advice.java
@@ -68,7 +68,7 @@ public class Servlet3Advice {
if (request instanceof HttpServletRequest) {
final Principal principal = ((HttpServletRequest) request).getUserPrincipal();
if (principal != null) {
- currentSpan.setTag("user.principal", principal.getName());
+ currentSpan.setTag(DDTags.USER_NAME, principal.getName());
}
}
}

MODIFY
dd-java-agent/instrumentation/servlet-3/src/test/groovy/JettyServlet3Test.groovy
dd-java-agent/instrumentation/servlet-3/src/test/groovy/JettyServlet3Test.groovy
@@ -2,6 +2,7 @@ import datadog.trace.agent.test.AgentTestRunner
import datadog.trace.agent.test.TestUtils
import datadog.trace.agent.test.utils.OkHttpUtils
import datadog.trace.api.DDSpanTypes
+import datadog.trace.api.DDTags
import okhttp3.Credentials
import okhttp3.Interceptor
import okhttp3.OkHttpClient
@@ -101,7 +102,7 @@ class JettyServlet3Test extends AgentTestRunner {
"span.type" DDSpanTypes.WEB_SERVLET
"http.status_code" 200
if (auth) {
- "user.principal" "user"
+ "$DDTags.USER_NAME" "user"
}
defaultTags(distributedTracing)
}

MODIFY
dd-java-agent/instrumentation/spring-web/spring-web.gradle
dd-java-agent/instrumentation/spring-web/spring-web.gradle
@@ -34,7 +34,7 @@ dependencies {
testCompile group: 'org.spockframework', name: 'spock-spring', version: '1.1-groovy-2.4'
- testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.5.+'
- testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.+'
- testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.5.+'
+ testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.5.17.RELEASE'
+ testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.17.RELEASE'
+ testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.5.17.RELEASE'
}

MODIFY
dd-java-agent/instrumentation/spring-web/src/test/groovy/test/SpringBootBasedTest.groovy
dd-java-agent/instrumentation/spring-web/src/test/groovy/test/SpringBootBasedTest.groovy
@@ -48,7 +48,7 @@ class SpringBootBasedTest extends AgentTestRunner {
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
"component" "java-web-servlet"
"http.status_code" 200
- "user.principal" USER
+ "$DDTags.USER_NAME" USER
defaultTags()
}
}
@@ -78,7 +78,7 @@ class SpringBootBasedTest extends AgentTestRunner {
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
"component" "java-web-servlet"
"http.status_code" 200
- "user.principal" USER
+ "$DDTags.USER_NAME" USER
defaultTags()
}
}
@@ -163,7 +163,7 @@ class SpringBootBasedTest extends AgentTestRunner {
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
"component" "java-web-servlet"
"http.status_code" 404
- "user.principal" USER
+ "$DDTags.USER_NAME" USER
defaultTags()
}
}
@@ -219,7 +219,7 @@ class SpringBootBasedTest extends AgentTestRunner {
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
"component" "java-web-servlet"
"http.status_code" 500
- "user.principal" USER
+ "$DDTags.USER_NAME" USER
errorTags NestedServletException, "Request processing failed; nested exception is java.lang.RuntimeException: qwerty"
defaultTags()
}
@@ -271,7 +271,7 @@ class SpringBootBasedTest extends AgentTestRunner {
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
"component" "java-web-servlet"
"http.status_code" 200
- "user.principal" USER
+ "$DDTags.USER_NAME" USER
defaultTags()
}
}
@@ -307,7 +307,7 @@ class SpringBootBasedTest extends AgentTestRunner {
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
"component" "java-web-servlet"
"http.status_code" 400
- "user.principal" USER
+ "$DDTags.USER_NAME" USER
"error" false
"error.msg" String
"error.type" MethodArgumentNotValidException.name

MODIFY
dd-trace-api/src/main/java/datadog/trace/api/DDTags.java
dd-trace-api/src/main/java/datadog/trace/api/DDTags.java
@@ -8,6 +8,8 @@ public class DDTags {
public static final String THREAD_ID = "thread.id";
public static final String DB_STATEMENT = "sql.query";
+ public static final String USER_NAME = "user.principal";
+
public static final String ERROR_MSG = "error.msg"; // string representing the error message
public static final String ERROR_TYPE = "error.type"; // string representing the type of the error
public static final String ERROR_STACK = "error.stack"; // human readable version of the stack

Apply standard tag name and update spring-web test deps version.