Skip to content

Commit fc4f6b8

Browse files
committed
Copy enduser.id key over and remove dependency.
Incubating keys are internalized to avoid a dependency on a moving target.
1 parent 4b6cd18 commit fc4f6b8

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

instrumentation/servlet/servlet-3.0/library/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins {
44

55
dependencies {
66
compileOnly("javax.servlet:javax.servlet-api:3.0.1")
7-
implementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
87

98
testLibrary("org.eclipse.jetty:jetty-server:8.0.0.v20110901")
109
testLibrary("org.eclipse.jetty:jetty-servlet:8.0.0.v20110901")

instrumentation/servlet/servlet-3.0/library/src/main/java/io/opentelemetry/instrumentation/servlet/v3_0/copied/BaseServletHelper.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
1515
import io.opentelemetry.instrumentation.api.instrumenter.LocalRootSpan;
1616
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRoute;
17-
import io.opentelemetry.semconv.incubating.EnduserIncubatingAttributes;
1817
import java.security.Principal;
1918
import java.util.function.Function;
2019

@@ -132,7 +131,7 @@ private void captureRequestParameters(Span serverSpan, REQUEST request) {
132131
}
133132

134133
/**
135-
* Capture {@link EnduserIncubatingAttributes#ENDUSER_ID} as span attributes when SERVER span is
134+
* Capture {@link ServletAdditionalAttributesExtractor#ENDUSER_ID} as span attributes when SERVER span is
136135
* not create by servlet instrumentation.
137136
*
138137
* <p>When SERVER span is created by servlet instrumentation we register {@link
@@ -148,7 +147,7 @@ private void captureEnduserId(Span serverSpan, REQUEST request) {
148147
if (principal != null) {
149148
String name = principal.getName();
150149
if (name != null) {
151-
serverSpan.setAttribute(EnduserIncubatingAttributes.ENDUSER_ID, name);
150+
serverSpan.setAttribute(ServletAdditionalAttributesExtractor.ENDUSER_ID, name);
152151
}
153152
}
154153
}

instrumentation/servlet/servlet-3.0/library/src/main/java/io/opentelemetry/instrumentation/servlet/v3_0/copied/ServletAdditionalAttributesExtractor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
package io.opentelemetry.instrumentation.servlet.v3_0.copied;
77

88
import static io.opentelemetry.api.common.AttributeKey.longKey;
9+
import static io.opentelemetry.api.common.AttributeKey.stringKey;
910

1011
import io.opentelemetry.api.common.AttributeKey;
1112
import io.opentelemetry.api.common.AttributesBuilder;
1213
import io.opentelemetry.context.Context;
1314
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
14-
import io.opentelemetry.semconv.incubating.EnduserIncubatingAttributes;
1515
import java.security.Principal;
1616
import javax.annotation.Nullable;
1717

@@ -23,6 +23,9 @@ public class ServletAdditionalAttributesExtractor<REQUEST, RESPONSE>
2323
.getBoolean("otel.instrumentation.servlet.experimental-span-attributes", false);
2424
private static final AttributeKey<Long> SERVLET_TIMEOUT = longKey("servlet.timeout");
2525

26+
// copied from EnduserIncubatingAttributes
27+
static final AttributeKey<String> ENDUSER_ID = stringKey("enduser.id");
28+
2629
private final ServletAccessor<REQUEST, RESPONSE> accessor;
2730

2831
public ServletAdditionalAttributesExtractor(ServletAccessor<REQUEST, RESPONSE> accessor) {
@@ -48,7 +51,7 @@ public void onEnd(
4851
if (principal != null) {
4952
String name = principal.getName();
5053
if (name != null) {
51-
attributes.put(EnduserIncubatingAttributes.ENDUSER_ID, name);
54+
attributes.put(ENDUSER_ID, name);
5255
}
5356
}
5457
}

0 commit comments

Comments
 (0)