Skip to content

Commit 1064e35

Browse files
committed
Apply standard tag name and update spring-web test deps version.
1 parent 0bb20ab commit 1064e35

8 files changed

Lines changed: 18 additions & 14 deletions

File tree

dd-java-agent/instrumentation/jetty-8/src/main/java/datadog/trace/instrumentation/jetty8/JettyHandlerAdvice.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static Scope startSpan(
5252
Tags.HTTP_URL.set(span, req.getRequestURL().toString());
5353
span.setTag(DDTags.RESOURCE_NAME, resourceName);
5454
if (req.getUserPrincipal() != null) {
55-
span.setTag("user.principal", req.getUserPrincipal().getName());
55+
span.setTag(DDTags.USER_NAME, req.getUserPrincipal().getName());
5656
}
5757
return scope;
5858
}

dd-java-agent/instrumentation/servlet-2/src/main/java/datadog/trace/instrumentation/servlet2/Servlet2Advice.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static void stopSpan(
6464
if (req instanceof HttpServletRequest) {
6565
final Principal principal = ((HttpServletRequest) req).getUserPrincipal();
6666
if (principal != null) {
67-
currentSpan.setTag("user.principal", principal.getName());
67+
currentSpan.setTag(DDTags.USER_NAME, principal.getName());
6868
}
6969
}
7070
}

dd-java-agent/instrumentation/servlet-2/src/test/groovy/JettyServlet2Test.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import datadog.trace.agent.test.AgentTestRunner
22
import datadog.trace.agent.test.TestUtils
33
import datadog.trace.agent.test.utils.OkHttpUtils
44
import datadog.trace.api.DDSpanTypes
5+
import datadog.trace.api.DDTags
56
import okhttp3.Credentials
67
import okhttp3.Interceptor
78
import okhttp3.OkHttpClient
@@ -94,7 +95,7 @@ class JettyServlet2Test extends AgentTestRunner {
9495
"span.type" DDSpanTypes.WEB_SERVLET
9596
"servlet.context" "/ctx"
9697
if (auth) {
97-
"user.principal" "user"
98+
"$DDTags.USER_NAME" "user"
9899
}
99100
defaultTags(distributedTracing)
100101
}

dd-java-agent/instrumentation/servlet-3/src/main/java/datadog/trace/instrumentation/servlet3/Servlet3Advice.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static void stopSpan(
6868
if (request instanceof HttpServletRequest) {
6969
final Principal principal = ((HttpServletRequest) request).getUserPrincipal();
7070
if (principal != null) {
71-
currentSpan.setTag("user.principal", principal.getName());
71+
currentSpan.setTag(DDTags.USER_NAME, principal.getName());
7272
}
7373
}
7474
}

dd-java-agent/instrumentation/servlet-3/src/test/groovy/JettyServlet3Test.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import datadog.trace.agent.test.AgentTestRunner
22
import datadog.trace.agent.test.TestUtils
33
import datadog.trace.agent.test.utils.OkHttpUtils
44
import datadog.trace.api.DDSpanTypes
5+
import datadog.trace.api.DDTags
56
import okhttp3.Credentials
67
import okhttp3.Interceptor
78
import okhttp3.OkHttpClient
@@ -101,7 +102,7 @@ class JettyServlet3Test extends AgentTestRunner {
101102
"span.type" DDSpanTypes.WEB_SERVLET
102103
"http.status_code" 200
103104
if (auth) {
104-
"user.principal" "user"
105+
"$DDTags.USER_NAME" "user"
105106
}
106107
defaultTags(distributedTracing)
107108
}

dd-java-agent/instrumentation/spring-web/spring-web.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies {
3434

3535
testCompile group: 'org.spockframework', name: 'spock-spring', version: '1.1-groovy-2.4'
3636

37-
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.5.+'
38-
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.+'
39-
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.5.+'
37+
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.5.17.RELEASE'
38+
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.17.RELEASE'
39+
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.5.17.RELEASE'
4040
}

dd-java-agent/instrumentation/spring-web/src/test/groovy/test/SpringBootBasedTest.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class SpringBootBasedTest extends AgentTestRunner {
4848
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
4949
"component" "java-web-servlet"
5050
"http.status_code" 200
51-
"user.principal" USER
51+
"$DDTags.USER_NAME" USER
5252
defaultTags()
5353
}
5454
}
@@ -78,7 +78,7 @@ class SpringBootBasedTest extends AgentTestRunner {
7878
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
7979
"component" "java-web-servlet"
8080
"http.status_code" 200
81-
"user.principal" USER
81+
"$DDTags.USER_NAME" USER
8282
defaultTags()
8383
}
8484
}
@@ -163,7 +163,7 @@ class SpringBootBasedTest extends AgentTestRunner {
163163
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
164164
"component" "java-web-servlet"
165165
"http.status_code" 404
166-
"user.principal" USER
166+
"$DDTags.USER_NAME" USER
167167
defaultTags()
168168
}
169169
}
@@ -219,7 +219,7 @@ class SpringBootBasedTest extends AgentTestRunner {
219219
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
220220
"component" "java-web-servlet"
221221
"http.status_code" 500
222-
"user.principal" USER
222+
"$DDTags.USER_NAME" USER
223223
errorTags NestedServletException, "Request processing failed; nested exception is java.lang.RuntimeException: qwerty"
224224
defaultTags()
225225
}
@@ -271,7 +271,7 @@ class SpringBootBasedTest extends AgentTestRunner {
271271
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
272272
"component" "java-web-servlet"
273273
"http.status_code" 200
274-
"user.principal" USER
274+
"$DDTags.USER_NAME" USER
275275
defaultTags()
276276
}
277277
}
@@ -307,7 +307,7 @@ class SpringBootBasedTest extends AgentTestRunner {
307307
"span.origin.type" "org.apache.catalina.core.ApplicationFilterChain"
308308
"component" "java-web-servlet"
309309
"http.status_code" 400
310-
"user.principal" USER
310+
"$DDTags.USER_NAME" USER
311311
"error" false
312312
"error.msg" String
313313
"error.type" MethodArgumentNotValidException.name

dd-trace-api/src/main/java/datadog/trace/api/DDTags.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public class DDTags {
88
public static final String THREAD_ID = "thread.id";
99
public static final String DB_STATEMENT = "sql.query";
1010

11+
public static final String USER_NAME = "user.principal";
12+
1113
public static final String ERROR_MSG = "error.msg"; // string representing the error message
1214
public static final String ERROR_TYPE = "error.type"; // string representing the type of the error
1315
public static final String ERROR_STACK = "error.stack"; // human readable version of the stack

0 commit comments

Comments
 (0)