Review semantic convention for Http Server spans (#1207)
* Review semantic convention for Http Server spans * Polish
This commit is contained in:
parent
4c54656f1e
commit
7e41b516ee
|
@ -0,0 +1,36 @@
|
|||
# Semantic conventions
|
||||
|
||||
This document describes which [OpenTelemetry Semantic Conventions](https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/trace/semantic_conventions)
|
||||
are implemented by Java autoinstrumentation and which ones are not.
|
||||
|
||||
## Http Server
|
||||
|
||||
| Attribute | Required | Implemented? |
|
||||
|---|:---:|:---:|
|
||||
| `http.method` | Y | + |
|
||||
| `http.url` | N | + |
|
||||
| `http.target` | N | - [1] |
|
||||
| `http.host` | N | - [1] |
|
||||
| `http.scheme` | N | - [1] |
|
||||
| `http.status_code` | Y | + |
|
||||
| `http.status_text` | N | - [2] |
|
||||
| `http.flavor` | N | + [3] |
|
||||
| `http.user_agent` | N | + |
|
||||
| `http.request_content_length` | N | - |
|
||||
| `http.request_content_length_uncompressed` | N | - |
|
||||
| `http.response_content_length` | N | - |
|
||||
| `http.response_content_length_uncompressed` | N | - |
|
||||
| `http.server_name` | N | - |
|
||||
| `http.route` | N | - |
|
||||
| `http.client_ip` | N | + |
|
||||
|
||||
**[1]:** As the majority of Java frameworks don't provide a standard way to obtain "The full request
|
||||
target as passed in a HTTP request line or equivalent.", we don't set `http.target` semantic
|
||||
attribute. As either it or `http.url` is required, we set the latter. This, in turn, makes setting
|
||||
`http.schema` and `http.host` unnecessary duplication. Therefore, we do not set them as well.
|
||||
|
||||
**[2]: TODO** After [this PR](https://github.com/open-telemetry/opentelemetry-specification/issues/950)
|
||||
is merged, remove this line. If it rejected, then implement this attribute.
|
||||
|
||||
**[3]:** In case of Armeria, return values are [SessionProtocol](https://github.com/line/armeria/blob/master/core/src/main/java/com/linecorp/armeria/common/SessionProtocol.java),
|
||||
not values defined by spec.
|
|
@ -25,10 +25,8 @@ import static io.opentelemetry.trace.TracingContextUtils.withSpan;
|
|||
import io.grpc.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.context.propagation.TextMapPropagator;
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes;
|
||||
import io.opentelemetry.instrumentation.api.config.Config;
|
||||
import io.opentelemetry.instrumentation.api.decorator.HttpStatusConverter;
|
||||
import io.opentelemetry.instrumentation.api.tracer.utils.HttpUrlUtils;
|
||||
import io.opentelemetry.trace.EndSpanOptions;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.SpanContext;
|
||||
|
@ -36,8 +34,6 @@ import io.opentelemetry.trace.Tracer;
|
|||
import io.opentelemetry.trace.TracingContextUtils;
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
@ -169,27 +165,30 @@ public abstract class HttpServerTracer<REQUEST, RESPONSE, CONNECTION, STORAGE> e
|
|||
}
|
||||
}
|
||||
|
||||
// TODO use semantic attributes
|
||||
protected void onRequest(Span span, REQUEST request) {
|
||||
SemanticAttributes.HTTP_METHOD.set(span, method(request));
|
||||
String userAgent = requestHeader(request, USER_AGENT);
|
||||
if (userAgent != null) {
|
||||
SemanticAttributes.HTTP_USER_AGENT.set(span, userAgent);
|
||||
}
|
||||
SemanticAttributes.HTTP_USER_AGENT.set(span, requestHeader(request, USER_AGENT));
|
||||
|
||||
setUrl(span, request);
|
||||
|
||||
try {
|
||||
URI url = url(request);
|
||||
HttpUrlUtils.setHttpUrl(span, url);
|
||||
if (Config.get().isHttpServerTagQueryString()) {
|
||||
span.setAttribute(MoreAttributes.HTTP_QUERY, url.getQuery());
|
||||
span.setAttribute(MoreAttributes.HTTP_FRAGMENT, url.getFragment());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.debug("Error tagging url", e);
|
||||
}
|
||||
// TODO set resource name from URL.
|
||||
}
|
||||
|
||||
/*
|
||||
https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md
|
||||
|
||||
HTTP semantic convention recommends setting http.scheme, http.host, http.target attributes
|
||||
instead of http.url because it "is usually not readily available on the server side but would have
|
||||
to be assembled in a cumbersome and sometimes lossy process from other information".
|
||||
|
||||
But in Java world there is no standard way to access "The full request target as passed in a HTTP request line or equivalent"
|
||||
which is the recommended value for http.target attribute. Therefore we cannot use any of the
|
||||
recommended combinations of attributes and are forced to use http.url.
|
||||
*/
|
||||
private void setUrl(Span span, REQUEST request) {
|
||||
SemanticAttributes.HTTP_URL.set(span, url(request));
|
||||
}
|
||||
|
||||
protected void onConnectionAndRequest(Span span, CONNECTION connection, REQUEST request) {
|
||||
String flavor = flavor(connection, request);
|
||||
if (flavor != null) {
|
||||
|
@ -198,7 +197,7 @@ public abstract class HttpServerTracer<REQUEST, RESPONSE, CONNECTION, STORAGE> e
|
|||
SemanticAttributes.HTTP_CLIENT_IP.set(span, clientIP(connection, request));
|
||||
}
|
||||
|
||||
protected String clientIP(CONNECTION connection, REQUEST request) {
|
||||
private String clientIP(CONNECTION connection, REQUEST request) {
|
||||
// try Forwarded
|
||||
String forwarded = requestHeader(request, "Forwarded");
|
||||
if (forwarded != null) {
|
||||
|
@ -293,6 +292,7 @@ public abstract class HttpServerTracer<REQUEST, RESPONSE, CONNECTION, STORAGE> e
|
|||
private static void setStatus(Span span, int status) {
|
||||
SemanticAttributes.HTTP_STATUS_CODE.set(span, status);
|
||||
// TODO status_message
|
||||
// See https://github.com/open-telemetry/opentelemetry-specification/issues/950
|
||||
span.setStatus(HttpStatusConverter.statusFromHttpStatus(status));
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ public abstract class HttpServerTracer<REQUEST, RESPONSE, CONNECTION, STORAGE> e
|
|||
|
||||
protected abstract TextMapPropagator.Getter<REQUEST> getGetter();
|
||||
|
||||
protected abstract URI url(REQUEST request) throws URISyntaxException;
|
||||
protected abstract String url(REQUEST request);
|
||||
|
||||
protected abstract String method(REQUEST request);
|
||||
|
||||
|
@ -327,4 +327,11 @@ public abstract class HttpServerTracer<REQUEST, RESPONSE, CONNECTION, STORAGE> e
|
|||
* Stores given context in the given request-response-loop storage in implementation specific way.
|
||||
*/
|
||||
protected abstract void attachServerContext(Context context, STORAGE storage);
|
||||
|
||||
/*
|
||||
We are making quite simple check by just verifying the presence of schema.
|
||||
*/
|
||||
protected boolean isRelativeUrl(String url) {
|
||||
return !(url.startsWith("http://") || url.startsWith("https://"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,21 +26,30 @@ import java.net.URISyntaxException;
|
|||
import java.security.Principal;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class ServletHttpServerTracer<RESPONSE>
|
||||
extends HttpServerTracer<HttpServletRequest, RESPONSE, HttpServletRequest, HttpServletRequest> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ServletHttpServerTracer.class);
|
||||
|
||||
@Override
|
||||
// TODO this violates convention
|
||||
protected URI url(HttpServletRequest httpServletRequest) throws URISyntaxException {
|
||||
return new URI(
|
||||
httpServletRequest.getScheme(),
|
||||
null,
|
||||
httpServletRequest.getServerName(),
|
||||
httpServletRequest.getServerPort(),
|
||||
httpServletRequest.getRequestURI(),
|
||||
httpServletRequest.getQueryString(),
|
||||
null);
|
||||
protected String url(HttpServletRequest httpServletRequest) {
|
||||
try {
|
||||
return new URI(
|
||||
httpServletRequest.getScheme(),
|
||||
null,
|
||||
httpServletRequest.getServerName(),
|
||||
httpServletRequest.getServerPort(),
|
||||
httpServletRequest.getRequestURI(),
|
||||
httpServletRequest.getQueryString(),
|
||||
null)
|
||||
.toString();
|
||||
} catch (URISyntaxException e) {
|
||||
log.debug("Failed to construct request URI", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,9 +85,6 @@ public abstract class ServletHttpServerTracer<RESPONSE>
|
|||
request.setAttribute("traceId", span.getContext().getTraceIdAsHexString());
|
||||
request.setAttribute("spanId", span.getContext().getSpanIdAsHexString());
|
||||
|
||||
// TODO why? they are not in semantic convention, right?
|
||||
span.setAttribute("servlet.path", request.getServletPath());
|
||||
span.setAttribute("servlet.context", request.getContextPath());
|
||||
super.onRequest(span, request);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ import akka.http.scaladsl.model.HttpResponse;
|
|||
import io.grpc.Context;
|
||||
import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
|
||||
import io.opentelemetry.instrumentation.api.tracer.HttpServerTracer;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class AkkaHttpServerTracer
|
||||
extends HttpServerTracer<HttpRequest, HttpResponse, HttpRequest, Void> {
|
||||
|
@ -53,8 +51,8 @@ public class AkkaHttpServerTracer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected URI url(HttpRequest httpRequest) throws URISyntaxException {
|
||||
return new URI(httpRequest.uri().toString());
|
||||
protected String url(HttpRequest httpRequest) {
|
||||
return httpRequest.uri().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@ import io.opentelemetry.instrumentation.api.tracer.HttpServerTracer;
|
|||
import io.opentelemetry.trace.Tracer;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ArmeriaServerTracer
|
||||
|
@ -81,8 +80,8 @@ public class ArmeriaServerTracer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected URI url(HttpRequest req) {
|
||||
return req.uri();
|
||||
protected String url(HttpRequest req) {
|
||||
return req.uri().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,6 @@ import io.dropwizard.testing.DropwizardTestSupport
|
|||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.auto.test.utils.PortUtils
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import javax.ws.rs.GET
|
||||
|
@ -121,11 +120,6 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
||||
"servlet.context" ""
|
||||
"servlet.path" ""
|
||||
if (endpoint.query) {
|
||||
"$MoreAttributes.HTTP_QUERY" endpoint.query
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import com.twitter.util.Closable
|
|||
import com.twitter.util.Duration
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import java.util.concurrent.TimeoutException
|
||||
|
@ -117,10 +116,6 @@ class FinatraServerTest extends HttpServerTest<HttpServer> {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
||||
// exception bodies are not yet recorded
|
||||
if (endpoint.query) {
|
||||
"$MoreAttributes.HTTP_QUERY" endpoint.query
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,11 +24,15 @@ import java.net.URISyntaxException;
|
|||
import org.glassfish.grizzly.filterchain.FilterChainContext;
|
||||
import org.glassfish.grizzly.http.HttpRequestPacket;
|
||||
import org.glassfish.grizzly.http.HttpResponsePacket;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class GrizzlyHttpServerTracer
|
||||
extends HttpServerTracer<
|
||||
HttpRequestPacket, HttpResponsePacket, HttpRequestPacket, FilterChainContext> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GrizzlyHttpServerTracer.class);
|
||||
|
||||
public static final GrizzlyHttpServerTracer TRACER = new GrizzlyHttpServerTracer();
|
||||
|
||||
@Override
|
||||
|
@ -58,14 +62,22 @@ public class GrizzlyHttpServerTracer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected URI url(HttpRequestPacket httpRequest) throws URISyntaxException {
|
||||
return new URI(
|
||||
(httpRequest.isSecure() ? "https://" : "http://")
|
||||
+ httpRequest.serverName()
|
||||
+ ":"
|
||||
+ httpRequest.getServerPort()
|
||||
+ httpRequest.getRequestURI()
|
||||
+ (httpRequest.getQueryString() != null ? "?" + httpRequest.getQueryString() : ""));
|
||||
protected String url(HttpRequestPacket httpRequest) {
|
||||
try {
|
||||
return new URI(
|
||||
(httpRequest.isSecure() ? "https://" : "http://")
|
||||
+ httpRequest.serverName()
|
||||
+ ":"
|
||||
+ httpRequest.getServerPort()
|
||||
+ httpRequest.getRequestURI()
|
||||
+ (httpRequest.getQueryString() != null
|
||||
? "?" + httpRequest.getQueryString()
|
||||
: ""))
|
||||
.toString();
|
||||
} catch (URISyntaxException e) {
|
||||
log.warn("Failed to construct request URI", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,6 @@ import static org.junit.Assume.assumeTrue
|
|||
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
@ -191,11 +190,6 @@ abstract class JaxRsHttpServerTest<S> extends HttpServerTest<S> {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
||||
"servlet.path" String
|
||||
"servlet.context" String
|
||||
if (query) {
|
||||
"$MoreAttributes.HTTP_QUERY" query
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.REDIRECT
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
||||
import static io.opentelemetry.trace.Span.Kind.SERVER
|
||||
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import javax.servlet.DispatcherType
|
||||
import javax.servlet.ServletException
|
||||
|
@ -29,14 +36,6 @@ import org.eclipse.jetty.server.handler.AbstractHandler
|
|||
import org.eclipse.jetty.server.handler.ErrorHandler
|
||||
import spock.lang.Shared
|
||||
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.REDIRECT
|
||||
import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
||||
import static io.opentelemetry.trace.Span.Kind.SERVER
|
||||
|
||||
class JettyHandlerTest extends HttpServerTest<Server> {
|
||||
|
||||
@Shared
|
||||
|
@ -145,10 +144,6 @@ class JettyHandlerTest extends HttpServerTest<Server> {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
||||
"servlet.path" ''
|
||||
if (endpoint.query) {
|
||||
"$MoreAttributes.HTTP_QUERY" endpoint.query
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,8 +117,6 @@ class JSPInstrumentationBasicTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/$jspFileName"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -180,8 +178,6 @@ class JSPInstrumentationBasicTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/getQuery.jsp"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -240,8 +236,6 @@ class JSPInstrumentationBasicTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/post.jsp"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -309,8 +303,6 @@ class JSPInstrumentationBasicTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/$jspFileName"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -383,8 +375,6 @@ class JSPInstrumentationBasicTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/includes/includeHtml.jsp"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -439,8 +429,6 @@ class JSPInstrumentationBasicTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/includes/includeMulti.jsp"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -534,8 +522,6 @@ class JSPInstrumentationBasicTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/$jspFileName"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -591,8 +577,6 @@ class JSPInstrumentationBasicTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/$staticFile"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,8 +115,6 @@ class JSPInstrumentationForwardTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/$forwardFromFileName"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -196,8 +194,6 @@ class JSPInstrumentationForwardTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/forwards/forwardToHtml.jsp"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -252,8 +248,6 @@ class JSPInstrumentationForwardTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/forwards/forwardToIncludeMulti.jsp"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -368,8 +362,6 @@ class JSPInstrumentationForwardTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/forwards/forwardToJspForward.jsp"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -465,8 +457,6 @@ class JSPInstrumentationForwardTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/forwards/forwardToCompileError.jsp"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
@ -533,8 +523,6 @@ class JSPInstrumentationForwardTests extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.context" "/$jspWebappContext"
|
||||
"servlet.path" "/forwards/forwardToNonExistent.jsp"
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
|
|
|
@ -24,8 +24,6 @@ import io.opentelemetry.instrumentation.api.tracer.HttpServerTracer;
|
|||
import io.opentelemetry.instrumentation.auto.netty.v3_8.ChannelTraceContext;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponse;
|
||||
|
@ -60,10 +58,10 @@ public class NettyHttpServerTracer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected URI url(HttpRequest request) throws URISyntaxException {
|
||||
URI uri = new URI(request.getUri());
|
||||
if ((uri.getHost() == null || uri.getHost().equals("")) && request.headers().contains(HOST)) {
|
||||
return new URI("http://" + request.headers().get(HOST) + request.getUri());
|
||||
protected String url(HttpRequest request) {
|
||||
String uri = request.getUri();
|
||||
if (isRelativeUrl(uri) && request.headers().contains(HOST)) {
|
||||
return "http://" + request.headers().get(HOST) + request.getUri();
|
||||
} else {
|
||||
return uri;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ import io.opentelemetry.instrumentation.api.tracer.HttpServerTracer;
|
|||
import io.opentelemetry.instrumentation.auto.netty.v4_0.AttributeKeys;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class NettyHttpServerTracer
|
||||
extends HttpServerTracer<HttpRequest, HttpResponse, Channel, Channel> {
|
||||
|
@ -70,10 +68,10 @@ public class NettyHttpServerTracer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected URI url(HttpRequest request) throws URISyntaxException {
|
||||
URI uri = new URI(request.getUri());
|
||||
if ((uri.getHost() == null || uri.getHost().equals("")) && request.headers().contains(HOST)) {
|
||||
return new URI("http://" + request.headers().get(HOST) + request.getUri());
|
||||
protected String url(HttpRequest request) {
|
||||
String uri = request.getUri();
|
||||
if (isRelativeUrl(uri) && request.headers().contains(HOST)) {
|
||||
return "http://" + request.headers().get(HOST) + request.getUri();
|
||||
} else {
|
||||
return uri;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ import io.opentelemetry.instrumentation.api.tracer.HttpServerTracer;
|
|||
import io.opentelemetry.instrumentation.auto.netty.v4_1.AttributeKeys;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public class NettyHttpServerTracer
|
||||
extends HttpServerTracer<HttpRequest, HttpResponse, Channel, Channel> {
|
||||
|
@ -70,10 +68,10 @@ public class NettyHttpServerTracer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected URI url(HttpRequest request) throws URISyntaxException {
|
||||
URI uri = new URI(request.uri());
|
||||
if ((uri.getHost() == null || uri.getHost().equals("")) && request.headers().contains(HOST)) {
|
||||
return new URI("http://" + request.headers().get(HOST) + request.uri());
|
||||
protected String url(HttpRequest request) {
|
||||
String uri = request.uri();
|
||||
if (isRelativeUrl(uri) && request.headers().contains(HOST)) {
|
||||
return "http://" + request.headers().get(HOST) + request.uri();
|
||||
} else {
|
||||
return uri;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import static io.opentelemetry.trace.Span.Kind.SERVER
|
|||
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import org.glassfish.embeddable.BootstrapProperties
|
||||
import org.glassfish.embeddable.Deployer
|
||||
|
@ -105,11 +104,6 @@ class GlassFishServerTest extends HttpServerTest<GlassFish> {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
||||
"servlet.context" "/$context"
|
||||
"servlet.path" endpoint.path
|
||||
if (endpoint.query) {
|
||||
"$MoreAttributes.HTTP_QUERY" endpoint.query
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import static io.opentelemetry.trace.Span.Kind.SERVER
|
|||
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
|
@ -120,11 +119,6 @@ class JettyServlet2Test extends HttpServerTest<Server> {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
||||
"servlet.context" "/$CONTEXT"
|
||||
"servlet.path" endpoint.path
|
||||
if (endpoint.query) {
|
||||
"$MoreAttributes.HTTP_QUERY" endpoint.query
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import static io.opentelemetry.auto.test.base.HttpServerTest.ServerEndpoint.SUCC
|
|||
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.trace.Span
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import javax.servlet.Servlet
|
||||
|
@ -93,14 +92,6 @@ abstract class AbstractServlet3Test<SERVER, CONTEXT> extends HttpServerTest<SERV
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
||||
// Optional
|
||||
if (context) {
|
||||
"servlet.context" "/$context"
|
||||
}
|
||||
"servlet.path" { it == endpoint.path || it == "/dispatch$endpoint.path" }
|
||||
if (endpoint.query) {
|
||||
"$MoreAttributes.HTTP_QUERY" endpoint.query
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ class SparkJavaBasedTest extends AgentTestRunner {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" String
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" "127.0.0.1"
|
||||
"servlet.path" ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import static io.opentelemetry.trace.Span.Kind.SERVER
|
|||
import com.google.common.collect.ImmutableMap
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import okhttp3.FormBody
|
||||
|
@ -196,11 +195,6 @@ class SpringBootBasedTest extends HttpServerTest<ConfigurableApplicationContext>
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
||||
"servlet.path" endpoint.path
|
||||
"servlet.context" ""
|
||||
if (endpoint.query) {
|
||||
"$MoreAttributes.HTTP_QUERY" endpoint.query
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import static io.opentelemetry.trace.Span.Kind.SERVER
|
|||
import com.google.common.collect.ImmutableMap
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
import org.springframework.boot.SpringApplication
|
||||
|
@ -112,11 +111,6 @@ class ServletFilterTest extends HttpServerTest<ConfigurableApplicationContext> {
|
|||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
||||
"servlet.path" endpoint.path
|
||||
"servlet.context" ""
|
||||
if (endpoint.query) {
|
||||
"$MoreAttributes.HTTP_QUERY" endpoint.query
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ import io.opentelemetry.context.propagation.TextMapPropagator.Getter;
|
|||
import io.opentelemetry.instrumentation.api.tracer.HttpServerTracer;
|
||||
import io.opentelemetry.instrumentation.servlet.HttpServletRequestGetter;
|
||||
import io.opentelemetry.trace.Tracer;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -50,8 +48,8 @@ class SpringWebMvcServerTracer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected URI url(HttpServletRequest request) throws URISyntaxException {
|
||||
return new URI(request.getRequestURI());
|
||||
protected String url(HttpServletRequest request) {
|
||||
return request.getRequestURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,7 +32,6 @@ import io.opentelemetry.auto.test.AgentTestRunner
|
|||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.utils.OkHttpUtils
|
||||
import io.opentelemetry.auto.test.utils.PortUtils
|
||||
import io.opentelemetry.instrumentation.api.MoreAttributes
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import io.opentelemetry.trace.Span
|
||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
||||
|
@ -479,20 +478,12 @@ abstract class HttpServerTest<SERVER> extends AgentTestRunner {
|
|||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_PORT.key()}" { it == null || it instanceof Long }
|
||||
"${SemanticAttributes.NET_PEER_IP.key()}" { it == null || it == "127.0.0.1" } // Optional
|
||||
// Optional
|
||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" { it == null || it == TEST_CLIENT_IP }
|
||||
"${SemanticAttributes.HTTP_URL.key()}" { it == "${endpoint.resolve(address)}" || it == "${endpoint.resolveWithoutFragment(address)}" }
|
||||
"${SemanticAttributes.HTTP_METHOD.key()}" method
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key()}" endpoint.status
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
||||
if (endpoint.query) {
|
||||
"$MoreAttributes.HTTP_QUERY" endpoint.query
|
||||
}
|
||||
// OkHttp never sends the fragment in the request.
|
||||
// if (endpoint.fragment) {
|
||||
// "$MoreAttributes.HTTP_FRAGMENT" endpoint.fragment
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue