Remove unnecessary overrides (#1477)
This commit is contained in:
parent
3565775b00
commit
7244dbf188
|
@ -24,7 +24,7 @@ abstract class AkkaHttpServerInstrumentationTest extends HttpServerTest<Object>
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "akka.request"
|
return "akka.request"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this override is needed because dropwizard reports peer ip as the client ip
|
||||||
@Override
|
@Override
|
||||||
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
||||||
trace.span(index) {
|
trace.span(index) {
|
||||||
|
|
|
@ -3,10 +3,8 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
||||||
import static io.opentelemetry.trace.Span.Kind.INTERNAL
|
import static io.opentelemetry.trace.Span.Kind.INTERNAL
|
||||||
import static io.opentelemetry.trace.Span.Kind.SERVER
|
|
||||||
|
|
||||||
import com.twitter.finatra.http.HttpServer
|
import com.twitter.finatra.http.HttpServer
|
||||||
import com.twitter.util.Await
|
import com.twitter.util.Await
|
||||||
|
@ -15,7 +13,6 @@ import com.twitter.util.Duration
|
||||||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
||||||
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
||||||
import io.opentelemetry.sdk.trace.data.SpanData
|
import io.opentelemetry.sdk.trace.data.SpanData
|
||||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
|
||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
|
|
||||||
class FinatraServerTest extends HttpServerTest<HttpServer> {
|
class FinatraServerTest extends HttpServerTest<HttpServer> {
|
||||||
|
@ -83,29 +80,4 @@ class FinatraServerTest extends HttpServerTest<HttpServer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
|
||||||
trace.span(index) {
|
|
||||||
name endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.resolvePath(address).path
|
|
||||||
kind SERVER
|
|
||||||
errored endpoint.errored
|
|
||||||
if (parentID != null) {
|
|
||||||
traceId traceID
|
|
||||||
parentSpanId parentID
|
|
||||||
} else {
|
|
||||||
hasNoParent()
|
|
||||||
}
|
|
||||||
attributes {
|
|
||||||
"${SemanticAttributes.NET_PEER_PORT.key()}" Long
|
|
||||||
"${SemanticAttributes.NET_PEER_IP.key()}" { it == null || it == "127.0.0.1" } // Optional
|
|
||||||
"${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
|
|
||||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ class GrizzlyFilterchainServerTest extends HttpServerTest<HttpServer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "HttpCodecFilter.handleRead"
|
return "HttpCodecFilter.handleRead"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ class GrizzlyTest extends HttpServerTest<HttpServer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "HttpCodecFilter.handleRead"
|
return "HttpCodecFilter.handleRead"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,8 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
||||||
import static io.opentelemetry.trace.Span.Kind.SERVER
|
|
||||||
|
|
||||||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
|
||||||
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
||||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
|
||||||
import javax.servlet.DispatcherType
|
import javax.servlet.DispatcherType
|
||||||
import javax.servlet.ServletException
|
import javax.servlet.ServletException
|
||||||
import javax.servlet.http.HttpServletRequest
|
import javax.servlet.http.HttpServletRequest
|
||||||
|
@ -110,30 +107,7 @@ class JettyHandlerTest extends HttpServerTest<Server> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
trace.span(index) {
|
"TestHandler.handle"
|
||||||
name "TestHandler.handle"
|
|
||||||
kind SERVER
|
|
||||||
errored endpoint.errored
|
|
||||||
if (endpoint == EXCEPTION) {
|
|
||||||
errorEvent(Exception, EXCEPTION.body)
|
|
||||||
}
|
|
||||||
if (parentID != null) {
|
|
||||||
traceId traceID
|
|
||||||
parentSpanId parentID
|
|
||||||
} else {
|
|
||||||
hasNoParent()
|
|
||||||
}
|
|
||||||
attributes {
|
|
||||||
"${SemanticAttributes.NET_PEER_IP.key()}" "127.0.0.1"
|
|
||||||
"${SemanticAttributes.NET_PEER_PORT.key()}" Long
|
|
||||||
"${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
|
|
||||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ class Netty38ServerTest extends HttpServerTest<ServerBootstrap> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "netty.request"
|
return "netty.request"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ class Netty38ServerTest extends HttpServerTest<ServerBootstrap> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "netty.request"
|
return "netty.request"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ class Netty40ServerTest extends HttpServerTest<EventLoopGroup> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "netty.request"
|
return "netty.request"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ class Netty41ServerTest extends HttpServerTest<EventLoopGroup> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "netty.request"
|
return "netty.request"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class PlayServerTest extends HttpServerTest<TestServer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "netty.request"
|
return "netty.request"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ class PlayServerTest extends HttpServerTest<Server> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "netty.request"
|
return "netty.request"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ class PlayServerTest extends HttpServerTest<Server> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return "akka.request"
|
return "akka.request"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ class RatpackHttpServerTest extends HttpServerTest<EmbeddedApp> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return endpoint.status == 404 ? "/" : endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.path
|
return endpoint.status == 404 ? "/" : endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,7 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
|
||||||
import static io.opentelemetry.trace.Span.Kind.SERVER
|
|
||||||
|
|
||||||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
|
||||||
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
||||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
|
||||||
import org.glassfish.embeddable.BootstrapProperties
|
import org.glassfish.embeddable.BootstrapProperties
|
||||||
import org.glassfish.embeddable.Deployer
|
import org.glassfish.embeddable.Deployer
|
||||||
import org.glassfish.embeddable.GlassFish
|
import org.glassfish.embeddable.GlassFish
|
||||||
|
@ -69,39 +63,11 @@ class GlassFishServerTest extends HttpServerTest<GlassFish> {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
|
||||||
trace.span(index) {
|
|
||||||
name entryPointName()
|
|
||||||
kind SERVER
|
|
||||||
errored endpoint.errored
|
|
||||||
if (parentID != null) {
|
|
||||||
traceId traceID
|
|
||||||
parentSpanId parentID
|
|
||||||
} else {
|
|
||||||
hasNoParent()
|
|
||||||
}
|
|
||||||
if (endpoint == EXCEPTION) {
|
|
||||||
errorEvent(Exception, EXCEPTION.body)
|
|
||||||
}
|
|
||||||
attributes {
|
|
||||||
"${SemanticAttributes.NET_PEER_IP.key()}" "127.0.0.1"
|
|
||||||
"${SemanticAttributes.NET_PEER_PORT.key()}" Long
|
|
||||||
"${SemanticAttributes.HTTP_STATUS_CODE.key()}" endpoint.status
|
|
||||||
"${SemanticAttributes.HTTP_METHOD.key()}" method
|
|
||||||
"${SemanticAttributes.HTTP_URL.key()}" { it == "${endpoint.resolve(address)}" || it == "${endpoint.resolveWithoutFragment(address)}" }
|
|
||||||
"${SemanticAttributes.HTTP_FLAVOR.key()}" "HTTP/1.1"
|
|
||||||
"${SemanticAttributes.HTTP_USER_AGENT.key()}" TEST_USER_AGENT
|
|
||||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simple class name plus method name of the entry point of the given servlet container.
|
// Simple class name plus method name of the entry point of the given servlet container.
|
||||||
// "Entry point" here means the first filter or servlet that accepts incoming requests.
|
// "Entry point" here means the first filter or servlet that accepts incoming requests.
|
||||||
// This will serve as a default name of the SERVER span created for this request.
|
// This will serve as a default name of the SERVER span created for this request.
|
||||||
protected String entryPointName() {
|
@Override
|
||||||
'HttpServlet.service'
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
|
"HttpServlet.service"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,10 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
||||||
import static io.opentelemetry.trace.Span.Kind.INTERNAL
|
import static io.opentelemetry.trace.Span.Kind.INTERNAL
|
||||||
import static io.opentelemetry.trace.Span.Kind.SERVER
|
|
||||||
|
|
||||||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
||||||
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
||||||
import io.opentelemetry.sdk.trace.data.SpanData
|
import io.opentelemetry.sdk.trace.data.SpanData
|
||||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
|
||||||
import javax.servlet.http.HttpServletRequest
|
import javax.servlet.http.HttpServletRequest
|
||||||
import org.eclipse.jetty.server.Server
|
import org.eclipse.jetty.server.Server
|
||||||
import org.eclipse.jetty.server.handler.ErrorHandler
|
import org.eclipse.jetty.server.handler.ErrorHandler
|
||||||
|
@ -84,32 +82,9 @@ class JettyServlet2Test extends HttpServerTest<Server> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// parent span must be cast otherwise it breaks debugging classloading (junit loads it early)
|
@Override
|
||||||
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
trace.span(index) {
|
"HttpServlet.service"
|
||||||
name 'HttpServlet.service'
|
|
||||||
kind SERVER
|
|
||||||
errored endpoint.errored
|
|
||||||
if (parentID != null) {
|
|
||||||
traceId traceID
|
|
||||||
parentSpanId parentID
|
|
||||||
} else {
|
|
||||||
hasNoParent()
|
|
||||||
}
|
|
||||||
if (endpoint == EXCEPTION) {
|
|
||||||
errorEvent(Exception, EXCEPTION.body)
|
|
||||||
}
|
|
||||||
attributes {
|
|
||||||
"${SemanticAttributes.NET_PEER_IP.key()}" "127.0.0.1"
|
|
||||||
// No peer port
|
|
||||||
"${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
|
|
||||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,10 +10,7 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.REDIRECT
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
||||||
|
|
||||||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
|
||||||
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
||||||
import io.opentelemetry.trace.Span
|
|
||||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
|
||||||
import javax.servlet.Servlet
|
import javax.servlet.Servlet
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.RequestBody
|
import okhttp3.RequestBody
|
||||||
|
@ -57,38 +54,11 @@ abstract class AbstractServlet3Test<SERVER, CONTEXT> extends HttpServerTest<SERV
|
||||||
super.request(uri, method, body)
|
super.request(uri, method, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
|
||||||
trace.span(index) {
|
|
||||||
name entryPointName()
|
|
||||||
kind Span.Kind.SERVER // can't use static import because of SERVER type parameter
|
|
||||||
errored endpoint.errored
|
|
||||||
if (parentID != null) {
|
|
||||||
traceId traceID
|
|
||||||
parentSpanId parentID
|
|
||||||
} else {
|
|
||||||
hasNoParent()
|
|
||||||
}
|
|
||||||
if (endpoint == EXCEPTION) {
|
|
||||||
errorEvent(Exception, EXCEPTION.body)
|
|
||||||
}
|
|
||||||
attributes {
|
|
||||||
"${SemanticAttributes.NET_PEER_IP.key()}" "127.0.0.1"
|
|
||||||
"${SemanticAttributes.NET_PEER_PORT.key()}" Long
|
|
||||||
"${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
|
|
||||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simple class name plus method name of the entry point of the given servlet container.
|
// Simple class name plus method name of the entry point of the given servlet container.
|
||||||
// "Entry point" here means the first filter or servlet that accepts incoming requests.
|
// "Entry point" here means the first filter or servlet that accepts incoming requests.
|
||||||
// This will serve as a default name of the SERVER span created for this request.
|
// This will serve as a default name of the SERVER span created for this request.
|
||||||
protected String entryPointName() {
|
@Override
|
||||||
'HttpServlet.service'
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
|
"HttpServlet.service"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ abstract class TomcatServlet3Test extends AbstractServlet3Test<Tomcat, Context>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String entryPointName() {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return 'ApplicationFilterChain.doFilter'
|
return 'ApplicationFilterChain.doFilter'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,8 @@ class SpringBootBasedTest extends HttpServerTest<ConfigurableApplicationContext>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this override is needed because the exception is propagated up from the handler span
|
||||||
|
// to the server span, which is different from the the expectation of the super method
|
||||||
@Override
|
@Override
|
||||||
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,11 @@ import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEn
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.SUCCESS
|
||||||
import static io.opentelemetry.trace.Span.Kind.INTERNAL
|
import static io.opentelemetry.trace.Span.Kind.INTERNAL
|
||||||
import static io.opentelemetry.trace.Span.Kind.SERVER
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap
|
import com.google.common.collect.ImmutableMap
|
||||||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
||||||
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
||||||
import io.opentelemetry.sdk.trace.data.SpanData
|
import io.opentelemetry.sdk.trace.data.SpanData
|
||||||
import io.opentelemetry.trace.attributes.SemanticAttributes
|
|
||||||
import org.springframework.boot.SpringApplication
|
import org.springframework.boot.SpringApplication
|
||||||
import org.springframework.context.ConfigurableApplicationContext
|
import org.springframework.context.ConfigurableApplicationContext
|
||||||
import test.boot.SecurityConfig
|
import test.boot.SecurityConfig
|
||||||
|
@ -77,31 +75,8 @@ class ServletFilterTest extends HttpServerTest<ConfigurableApplicationContext> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
trace.span(index) {
|
return endpoint == PATH_PARAM ? "/path/{id}/param" : endpoint.resolvePath(address).path
|
||||||
name endpoint == PATH_PARAM ? "/path/{id}/param" : endpoint.resolvePath(address).path
|
|
||||||
kind SERVER
|
|
||||||
errored endpoint.errored
|
|
||||||
if (parentID != null) {
|
|
||||||
traceId traceID
|
|
||||||
parentSpanId parentID
|
|
||||||
} else {
|
|
||||||
hasNoParent()
|
|
||||||
}
|
|
||||||
if (endpoint == EXCEPTION) {
|
|
||||||
errorEvent(Exception, EXCEPTION.body)
|
|
||||||
}
|
|
||||||
attributes {
|
|
||||||
"${SemanticAttributes.NET_PEER_IP.key()}" { it == null || it == "127.0.0.1" } // Optional
|
|
||||||
"${SemanticAttributes.NET_PEER_PORT.key()}" Long
|
|
||||||
"${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
|
|
||||||
"${SemanticAttributes.HTTP_CLIENT_IP.key()}" TEST_CLIENT_IP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -71,7 +71,7 @@ class VertxHttpServerTest extends HttpServerTest<Vertx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.getPath()
|
return endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.getPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ class VertxRxHttpServerTest extends HttpServerTest<Vertx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.getPath()
|
return endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.getPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ abstract class HttpServerTest<SERVER> extends AgentTestRunner {
|
||||||
|
|
||||||
abstract void stopServer(SERVER server)
|
abstract void stopServer(SERVER server)
|
||||||
|
|
||||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
return endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.resolvePath(address).path
|
return endpoint == PATH_PARAM ? "/path/:id/param" : endpoint.resolvePath(address).path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ abstract class HttpServerTest<SERVER> extends AgentTestRunner {
|
||||||
// parent span must be cast otherwise it breaks debugging classloading (junit loads it early)
|
// parent span must be cast otherwise it breaks debugging classloading (junit loads it early)
|
||||||
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
void serverSpan(TraceAssert trace, int index, String traceID = null, String parentID = null, String method = "GET", Long responseContentLength = null, ServerEndpoint endpoint = SUCCESS) {
|
||||||
trace.span(index) {
|
trace.span(index) {
|
||||||
name expectedServerSpanName(method, endpoint)
|
name expectedServerSpanName(endpoint)
|
||||||
kind Span.Kind.SERVER // can't use static import because of SERVER type parameter
|
kind Span.Kind.SERVER // can't use static import because of SERVER type parameter
|
||||||
errored endpoint.errored
|
errored endpoint.errored
|
||||||
if (parentID != null) {
|
if (parentID != null) {
|
||||||
|
|
Loading…
Reference in New Issue