Test captured HTTP headers - HTTP server tests, part 2 (#4328)
* Test captured HTTP headers - HTTP server tests, part 2 * Turn off captured HTTP headers testing for grizzly Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
This commit is contained in:
parent
b371361bb9
commit
354699647a
|
@ -24,6 +24,11 @@ abstract class AkkaHttpServerInstrumentationTest extends HttpServerTest<Object>
|
||||||
return "akka.request"
|
return "akka.request"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testConcurrency() {
|
boolean testConcurrency() {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -11,6 +11,9 @@ import io.opentelemetry.instrumentation.test.LibraryTestTrait
|
||||||
class ArmeriaHttpServerTest extends AbstractArmeriaHttpServerTest implements LibraryTestTrait {
|
class ArmeriaHttpServerTest extends AbstractArmeriaHttpServerTest implements LibraryTestTrait {
|
||||||
@Override
|
@Override
|
||||||
ServerBuilder configureServer(ServerBuilder sb) {
|
ServerBuilder configureServer(ServerBuilder sb) {
|
||||||
return sb.decorator(ArmeriaTracing.create(getOpenTelemetry()).newServiceDecorator())
|
return sb.decorator(ArmeriaTracing.newBuilder(getOpenTelemetry())
|
||||||
|
.captureHttpServerHeaders(capturedHttpHeadersForTesting())
|
||||||
|
.build()
|
||||||
|
.newServiceDecorator())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
package io.opentelemetry.instrumentation.armeria.v1_3
|
package io.opentelemetry.instrumentation.armeria.v1_3
|
||||||
|
|
||||||
|
import com.linecorp.armeria.common.HttpData
|
||||||
import com.linecorp.armeria.common.HttpHeaderNames
|
import com.linecorp.armeria.common.HttpHeaderNames
|
||||||
import com.linecorp.armeria.common.HttpRequest
|
import com.linecorp.armeria.common.HttpRequest
|
||||||
import com.linecorp.armeria.common.HttpResponse
|
import com.linecorp.armeria.common.HttpResponse
|
||||||
|
@ -24,6 +25,7 @@ import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||||
|
|
||||||
import java.util.function.Function
|
import java.util.function.Function
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
||||||
|
@ -95,6 +97,16 @@ abstract class AbstractArmeriaHttpServerTest extends HttpServerTest<Server> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sb.service("/captureHeaders") { ctx, req ->
|
||||||
|
controller(CAPTURE_HEADERS) {
|
||||||
|
HttpResponse.of(
|
||||||
|
ResponseHeaders.of(HttpStatus.valueOf(CAPTURE_HEADERS.status),
|
||||||
|
"X-Test-Response", req.headers().get("X-Test-Request"),
|
||||||
|
HttpHeaderNames.CONTENT_TYPE, MediaType.PLAIN_TEXT_UTF_8),
|
||||||
|
HttpData.ofUtf8(CAPTURE_HEADERS.body))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure user decorators see spans.
|
// Make sure user decorators see spans.
|
||||||
sb.decorator(new DecoratingHttpServiceFunction() {
|
sb.decorator(new DecoratingHttpServiceFunction() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,6 +9,7 @@ import io.dropwizard.setup.Bootstrap
|
||||||
import io.dropwizard.setup.Environment
|
import io.dropwizard.setup.Environment
|
||||||
|
|
||||||
import javax.ws.rs.GET
|
import javax.ws.rs.GET
|
||||||
|
import javax.ws.rs.HeaderParam
|
||||||
import javax.ws.rs.Path
|
import javax.ws.rs.Path
|
||||||
import javax.ws.rs.PathParam
|
import javax.ws.rs.PathParam
|
||||||
import javax.ws.rs.QueryParam
|
import javax.ws.rs.QueryParam
|
||||||
|
@ -17,6 +18,7 @@ import javax.ws.rs.container.Suspended
|
||||||
import javax.ws.rs.core.Response
|
import javax.ws.rs.core.Response
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
||||||
|
@ -110,5 +112,17 @@ class DropwizardAsyncTest extends DropwizardTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("captureHeaders")
|
||||||
|
void capture_headers(@HeaderParam("X-Test-Request") String header,
|
||||||
|
@Suspended final AsyncResponse asyncResponse) {
|
||||||
|
controller(CAPTURE_HEADERS) {
|
||||||
|
asyncResponse.resume(Response.status(CAPTURE_HEADERS.status)
|
||||||
|
.header("X-Test-Response", header)
|
||||||
|
.entity(CAPTURE_HEADERS.body)
|
||||||
|
.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import io.opentelemetry.sdk.trace.data.SpanData
|
||||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||||
|
|
||||||
import javax.ws.rs.GET
|
import javax.ws.rs.GET
|
||||||
|
import javax.ws.rs.HeaderParam
|
||||||
import javax.ws.rs.Path
|
import javax.ws.rs.Path
|
||||||
import javax.ws.rs.PathParam
|
import javax.ws.rs.PathParam
|
||||||
import javax.ws.rs.QueryParam
|
import javax.ws.rs.QueryParam
|
||||||
|
@ -25,6 +26,7 @@ import javax.ws.rs.core.Response
|
||||||
|
|
||||||
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
|
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
|
||||||
import static io.opentelemetry.api.trace.SpanKind.SERVER
|
import static io.opentelemetry.api.trace.SpanKind.SERVER
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
||||||
|
@ -121,6 +123,10 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> implements Ag
|
||||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||||
"${SemanticAttributes.HTTP_USER_AGENT.key}" TEST_USER_AGENT
|
"${SemanticAttributes.HTTP_USER_AGENT.key}" TEST_USER_AGENT
|
||||||
"${SemanticAttributes.HTTP_CLIENT_IP.key}" TEST_CLIENT_IP
|
"${SemanticAttributes.HTTP_CLIENT_IP.key}" TEST_CLIENT_IP
|
||||||
|
if (endpoint == ServerEndpoint.CAPTURE_HEADERS) {
|
||||||
|
"http.request.header.x_test_request" { it == ["test"] }
|
||||||
|
"http.response.header.x_test_response" { it == ["test"] }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,6 +200,17 @@ class DropwizardTest extends HttpServerTest<DropwizardTestSupport> implements Ag
|
||||||
Response.status(PATH_PARAM.status).entity(param.toString()).build()
|
Response.status(PATH_PARAM.status).entity(param.toString()).build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("captureHeaders")
|
||||||
|
Response capture_headers(@HeaderParam("X-Test-Request") String header) {
|
||||||
|
controller(CAPTURE_HEADERS) {
|
||||||
|
Response.status(CAPTURE_HEADERS.status)
|
||||||
|
.header("X-Test-Response", header)
|
||||||
|
.entity(CAPTURE_HEADERS.body)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Path("/")
|
@Path("/")
|
||||||
|
|
|
@ -103,4 +103,8 @@ class FinatraServerLatestTest extends HttpServerTest<HttpServer> implements Agen
|
||||||
SemanticAttributes.HTTP_URL
|
SemanticAttributes.HTTP_URL
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,4 +87,8 @@ class FinatraServerTest extends HttpServerTest<HttpServer> implements AgentTestT
|
||||||
SemanticAttributes.HTTP_URL
|
SemanticAttributes.HTTP_URL
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.springframework.boot.autoconfigure.web.ServerProperties
|
||||||
import org.springframework.context.ConfigurableApplicationContext
|
import org.springframework.context.ConfigurableApplicationContext
|
||||||
|
|
||||||
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
|
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
||||||
|
@ -141,6 +142,8 @@ class GrailsTest extends HttpServerTest<ConfigurableApplicationContext> implemen
|
||||||
name "TestController.query"
|
name "TestController.query"
|
||||||
} else if (endpoint == PATH_PARAM) {
|
} else if (endpoint == PATH_PARAM) {
|
||||||
name "TestController.path"
|
name "TestController.path"
|
||||||
|
} else if (endpoint == CAPTURE_HEADERS) {
|
||||||
|
name "TestController.captureHeaders"
|
||||||
} else if (endpoint == NOT_FOUND) {
|
} else if (endpoint == NOT_FOUND) {
|
||||||
name "ResourceHttpRequestHandler.handleRequest"
|
name "ResourceHttpRequestHandler.handleRequest"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import grails.artefact.Controller
|
||||||
import grails.web.Action
|
import grails.web.Action
|
||||||
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
||||||
|
@ -64,4 +65,12 @@ class TestController implements Controller {
|
||||||
render params.id
|
render params.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Action
|
||||||
|
def captureHeaders() {
|
||||||
|
HttpServerTest.controller(CAPTURE_HEADERS) {
|
||||||
|
response.setHeader("X-Test-Response", request.getHeader("X-Test-Request"))
|
||||||
|
render CAPTURE_HEADERS.body
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ class UrlMappings {
|
||||||
"/error-status"(controller: 'test', action: 'error')
|
"/error-status"(controller: 'test', action: 'error')
|
||||||
"/exception"(controller: 'test', action: 'exception')
|
"/exception"(controller: 'test', action: 'exception')
|
||||||
"/path/$id/param"(controller: 'test', action: 'path')
|
"/path/$id/param"(controller: 'test', action: 'path')
|
||||||
|
"/captureHeaders"(controller: 'test', action: 'captureHeaders')
|
||||||
|
|
||||||
"500"(controller: 'error')
|
"500"(controller: 'error')
|
||||||
"404"(controller: 'error', action: 'notFound')
|
"404"(controller: 'error', action: 'notFound')
|
||||||
|
|
|
@ -65,6 +65,11 @@ class GrizzlyFilterchainServerTest extends HttpServerTest<HttpServer> implements
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
void setUpTransport(FilterChain filterChain) {
|
void setUpTransport(FilterChain filterChain) {
|
||||||
TCPNIOTransportBuilder transportBuilder = TCPNIOTransportBuilder.newInstance()
|
TCPNIOTransportBuilder transportBuilder = TCPNIOTransportBuilder.newInstance()
|
||||||
.setOptimizedForMultiplexing(true)
|
.setOptimizedForMultiplexing(true)
|
||||||
|
|
|
@ -46,6 +46,11 @@ class GrizzlyTest extends HttpServerTest<HttpServer> implements AgentTestTrait {
|
||||||
server.stop()
|
server.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
static class SimpleExceptionMapper implements ExceptionMapper<Throwable> {
|
static class SimpleExceptionMapper implements ExceptionMapper<Throwable> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -281,6 +281,10 @@ abstract class JaxRsHttpServerTest<S> extends HttpServerTest<S> implements Agent
|
||||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||||
"${SemanticAttributes.HTTP_USER_AGENT.key}" TEST_USER_AGENT
|
"${SemanticAttributes.HTTP_USER_AGENT.key}" TEST_USER_AGENT
|
||||||
"${SemanticAttributes.HTTP_CLIENT_IP.key}" TEST_CLIENT_IP
|
"${SemanticAttributes.HTTP_CLIENT_IP.key}" TEST_CLIENT_IP
|
||||||
|
if (fullUrl.getPath().endsWith(ServerEndpoint.CAPTURE_HEADERS.getPath())) {
|
||||||
|
"http.request.header.x_test_request" { it == ["test"] }
|
||||||
|
"http.response.header.x_test_response" { it == ["test"] }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import io.opentelemetry.instrumentation.test.base.HttpServerTest
|
||||||
|
|
||||||
import javax.ws.rs.ApplicationPath
|
import javax.ws.rs.ApplicationPath
|
||||||
import javax.ws.rs.GET
|
import javax.ws.rs.GET
|
||||||
|
import javax.ws.rs.HeaderParam
|
||||||
import javax.ws.rs.Path
|
import javax.ws.rs.Path
|
||||||
import javax.ws.rs.PathParam
|
import javax.ws.rs.PathParam
|
||||||
import javax.ws.rs.QueryParam
|
import javax.ws.rs.QueryParam
|
||||||
|
@ -23,6 +24,7 @@ import java.util.concurrent.CompletableFuture
|
||||||
import java.util.concurrent.CompletionStage
|
import java.util.concurrent.CompletionStage
|
||||||
import java.util.concurrent.CyclicBarrier
|
import java.util.concurrent.CyclicBarrier
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -86,6 +88,17 @@ class JaxRsTestResource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("captureHeaders")
|
||||||
|
Response capture_headers(@HeaderParam("X-Test-Request") String header) {
|
||||||
|
HttpServerTest.controller(CAPTURE_HEADERS) {
|
||||||
|
Response.status(CAPTURE_HEADERS.status)
|
||||||
|
.header("X-Test-Response", header)
|
||||||
|
.entity(CAPTURE_HEADERS.body)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Path("/child")
|
@Path("/child")
|
||||||
@GET
|
@GET
|
||||||
void indexed_child(@Context UriInfo uriInfo, @Suspended AsyncResponse response) {
|
void indexed_child(@Context UriInfo uriInfo, @Suspended AsyncResponse response) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler
|
||||||
import org.eclipse.jetty.server.handler.ErrorHandler
|
import org.eclipse.jetty.server.handler.ErrorHandler
|
||||||
import spock.lang.Shared
|
import spock.lang.Shared
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
||||||
|
@ -95,6 +96,11 @@ class JettyHandlerTest extends HttpServerTest<Server> implements AgentTestTrait
|
||||||
case ERROR:
|
case ERROR:
|
||||||
response.sendError(endpoint.status, endpoint.body)
|
response.sendError(endpoint.status, endpoint.body)
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
response.setHeader("X-Test-Response", request.getHeader("X-Test-Request"))
|
||||||
|
response.status = endpoint.status
|
||||||
|
response.writer.print(endpoint.body)
|
||||||
|
break
|
||||||
case EXCEPTION:
|
case EXCEPTION:
|
||||||
throw new Exception(endpoint.body)
|
throw new Exception(endpoint.body)
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -18,6 +18,7 @@ import javax.servlet.ServletException
|
||||||
import javax.servlet.http.HttpServletRequest
|
import javax.servlet.http.HttpServletRequest
|
||||||
import javax.servlet.http.HttpServletResponse
|
import javax.servlet.http.HttpServletResponse
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
||||||
|
@ -96,6 +97,11 @@ class JettyHandlerTest extends HttpServerTest<Server> implements AgentTestTrait
|
||||||
case ERROR:
|
case ERROR:
|
||||||
response.sendError(endpoint.status, endpoint.body)
|
response.sendError(endpoint.status, endpoint.body)
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
response.setHeader("X-Test-Response", request.getHeader("X-Test-Request"))
|
||||||
|
response.status = endpoint.status
|
||||||
|
response.writer.print(endpoint.body)
|
||||||
|
break
|
||||||
case EXCEPTION:
|
case EXCEPTION:
|
||||||
throw new Exception(endpoint.body)
|
throw new Exception(endpoint.body)
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -158,6 +158,11 @@ class Netty38ServerTest extends HttpServerTest<ServerBootstrap> implements Agent
|
||||||
return "HTTP GET"
|
return "HTTP GET"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testConcurrency() {
|
boolean testConcurrency() {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -128,6 +128,11 @@ class Netty40ServerTest extends HttpServerTest<EventLoopGroup> implements AgentT
|
||||||
return "HTTP GET"
|
return "HTTP GET"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testConcurrency() {
|
boolean testConcurrency() {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -127,6 +127,11 @@ class Netty41ServerTest extends HttpServerTest<EventLoopGroup> implements AgentT
|
||||||
return "HTTP GET"
|
return "HTTP GET"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testConcurrency() {
|
boolean testConcurrency() {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -77,6 +77,11 @@ class PlayServerTest extends HttpServerTest<Server> implements AgentTestTrait {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testConcurrency() {
|
boolean testConcurrency() {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -64,6 +64,11 @@ class PlayServerTest extends HttpServerTest<Server> implements AgentTestTrait {
|
||||||
server.stop()
|
server.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean hasHandlerSpan(ServerEndpoint endpoint) {
|
boolean hasHandlerSpan(ServerEndpoint endpoint) {
|
||||||
true
|
true
|
||||||
|
|
|
@ -13,4 +13,9 @@ class RatpackAsyncHttpServerTest extends AbstractRatpackAsyncHttpServerTest impl
|
||||||
@Override
|
@Override
|
||||||
void configure(RatpackServerSpec serverSpec) {
|
void configure(RatpackServerSpec serverSpec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,4 +13,9 @@ class RatpackForkedHttpServerTest extends AbstractRatpackForkedHttpServerTest im
|
||||||
@Override
|
@Override
|
||||||
void configure(RatpackServerSpec serverSpec) {
|
void configure(RatpackServerSpec serverSpec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,9 @@ class RatpackHttpServerTest extends AbstractRatpackHttpServerTest implements Age
|
||||||
@Override
|
@Override
|
||||||
void configure(RatpackServerSpec serverSpec) {
|
void configure(RatpackServerSpec serverSpec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,9 @@ import ratpack.server.RatpackServerSpec
|
||||||
class RatpackAsyncHttpServerTest extends AbstractRatpackAsyncHttpServerTest implements LibraryTestTrait {
|
class RatpackAsyncHttpServerTest extends AbstractRatpackAsyncHttpServerTest implements LibraryTestTrait {
|
||||||
@Override
|
@Override
|
||||||
void configure(RatpackServerSpec serverSpec) {
|
void configure(RatpackServerSpec serverSpec) {
|
||||||
RatpackTracing tracing = RatpackTracing.create(openTelemetry)
|
RatpackTracing tracing = RatpackTracing.newBuilder(openTelemetry)
|
||||||
|
.captureHttpHeaders(capturedHttpHeadersForTesting())
|
||||||
|
.build()
|
||||||
serverSpec.registryOf {
|
serverSpec.registryOf {
|
||||||
tracing.configureServerRegistry(it)
|
tracing.configureServerRegistry(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,9 @@ import ratpack.server.RatpackServerSpec
|
||||||
class RatpackForkedHttpServerTest extends AbstractRatpackForkedHttpServerTest implements LibraryTestTrait {
|
class RatpackForkedHttpServerTest extends AbstractRatpackForkedHttpServerTest implements LibraryTestTrait {
|
||||||
@Override
|
@Override
|
||||||
void configure(RatpackServerSpec serverSpec) {
|
void configure(RatpackServerSpec serverSpec) {
|
||||||
RatpackTracing tracing = RatpackTracing.create(openTelemetry)
|
RatpackTracing tracing = RatpackTracing.newBuilder(openTelemetry)
|
||||||
|
.captureHttpHeaders(capturedHttpHeadersForTesting())
|
||||||
|
.build()
|
||||||
serverSpec.registryOf {
|
serverSpec.registryOf {
|
||||||
tracing.configureServerRegistry(it)
|
tracing.configureServerRegistry(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,9 @@ import ratpack.server.RatpackServerSpec
|
||||||
class RatpackHttpServerTest extends AbstractRatpackHttpServerTest implements LibraryTestTrait {
|
class RatpackHttpServerTest extends AbstractRatpackHttpServerTest implements LibraryTestTrait {
|
||||||
@Override
|
@Override
|
||||||
void configure(RatpackServerSpec serverSpec) {
|
void configure(RatpackServerSpec serverSpec) {
|
||||||
RatpackTracing tracing = RatpackTracing.create(openTelemetry)
|
RatpackTracing tracing = RatpackTracing.newBuilder(openTelemetry)
|
||||||
|
.captureHttpHeaders(capturedHttpHeadersForTesting())
|
||||||
|
.build()
|
||||||
serverSpec.registryOf {
|
serverSpec.registryOf {
|
||||||
tracing.configureServerRegistry(it)
|
tracing.configureServerRegistry(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import ratpack.error.ServerErrorHandler
|
||||||
import ratpack.exec.Promise
|
import ratpack.exec.Promise
|
||||||
import ratpack.server.RatpackServer
|
import ratpack.server.RatpackServer
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -108,6 +109,19 @@ abstract class AbstractRatpackAsyncHttpServerTest extends AbstractRatpackHttpSer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
it.prefix(CAPTURE_HEADERS.rawPath()) {
|
||||||
|
it.all { context ->
|
||||||
|
Promise.sync {
|
||||||
|
CAPTURE_HEADERS
|
||||||
|
} then { endpoint ->
|
||||||
|
controller(endpoint) {
|
||||||
|
context.response.status(endpoint.status)
|
||||||
|
context.response.headers.set("X-Test-Response", context.request.headers.get("X-Test-Request"))
|
||||||
|
context.response.send(endpoint.body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
configure(it)
|
configure(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import ratpack.exec.Result
|
||||||
import ratpack.exec.util.ParallelBatch
|
import ratpack.exec.util.ParallelBatch
|
||||||
import ratpack.server.RatpackServer
|
import ratpack.server.RatpackServer
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -116,6 +117,19 @@ abstract class AbstractRatpackForkedHttpServerTest extends AbstractRatpackHttpSe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
it.prefix(CAPTURE_HEADERS.rawPath()) {
|
||||||
|
it.all { context ->
|
||||||
|
Promise.sync {
|
||||||
|
CAPTURE_HEADERS
|
||||||
|
}.fork().then { endpoint ->
|
||||||
|
controller(endpoint) {
|
||||||
|
context.response.status(endpoint.status)
|
||||||
|
context.response.headers.set("X-Test-Response", context.request.headers.get("X-Test-Request"))
|
||||||
|
context.response.send(endpoint.body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
it.prefix("fork_and_yieldAll") {
|
it.prefix("fork_and_yieldAll") {
|
||||||
it.all { context ->
|
it.all { context ->
|
||||||
def promise = Promise.async { upstream ->
|
def promise = Promise.async { upstream ->
|
||||||
|
|
|
@ -17,6 +17,7 @@ import ratpack.server.RatpackServer
|
||||||
import ratpack.server.RatpackServerSpec
|
import ratpack.server.RatpackServerSpec
|
||||||
|
|
||||||
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
|
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -90,6 +91,15 @@ abstract class AbstractRatpackHttpServerTest extends HttpServerTest<RatpackServe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
it.prefix(CAPTURE_HEADERS.rawPath()) {
|
||||||
|
it.all { context ->
|
||||||
|
controller(CAPTURE_HEADERS) {
|
||||||
|
context.response.status(CAPTURE_HEADERS.status)
|
||||||
|
context.response.headers.set("X-Test-Response", context.request.headers.get("X-Test-Request"))
|
||||||
|
context.response.send(CAPTURE_HEADERS.body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
configure(it)
|
configure(it)
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,11 +166,6 @@ abstract class AbstractRestletServerTest extends HttpServerTest<Server> {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean testCapturedHttpHeaders() {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
switch (endpoint) {
|
switch (endpoint) {
|
||||||
|
|
|
@ -72,6 +72,12 @@ class JettyServlet2Test extends HttpServerTest<Server> implements AgentTestTrait
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// servlet 2 does not expose a way to retrieve response headers
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean hasResponseSpan(ServerEndpoint endpoint) {
|
boolean hasResponseSpan(ServerEndpoint endpoint) {
|
||||||
endpoint == REDIRECT || endpoint == ERROR
|
endpoint == REDIRECT || endpoint == ERROR
|
||||||
|
|
|
@ -11,6 +11,7 @@ import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpRequest
|
||||||
import javax.servlet.Servlet
|
import javax.servlet.Servlet
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -44,6 +45,7 @@ abstract class AbstractServlet3Test<SERVER, CONTEXT> extends HttpServerTest<SERV
|
||||||
addServlet(context, REDIRECT.path, servlet)
|
addServlet(context, REDIRECT.path, servlet)
|
||||||
addServlet(context, AUTH_REQUIRED.path, servlet)
|
addServlet(context, AUTH_REQUIRED.path, servlet)
|
||||||
addServlet(context, INDEXED_CHILD.path, servlet)
|
addServlet(context, INDEXED_CHILD.path, servlet)
|
||||||
|
addServlet(context, CAPTURE_HEADERS.path, servlet)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServerEndpoint lastRequest
|
protected ServerEndpoint lastRequest
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javax.servlet.ServletException
|
||||||
import javax.servlet.http.HttpServletRequest
|
import javax.servlet.http.HttpServletRequest
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
||||||
|
@ -189,6 +190,7 @@ class JettyServlet3TestForward extends JettyDispatchTest {
|
||||||
addServlet(context, "/dispatch" + ERROR.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + ERROR.path, RequestDispatcherServlet.Forward)
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + EXCEPTION.path, RequestDispatcherServlet.Forward)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, RequestDispatcherServlet.Forward)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, RequestDispatcherServlet.Forward)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,6 +205,11 @@ class JettyServlet3TestInclude extends JettyDispatchTest {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testError() {
|
boolean testError() {
|
||||||
false
|
false
|
||||||
|
@ -238,6 +245,7 @@ class JettyServlet3TestDispatchImmediate extends JettyDispatchTest {
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet3.DispatchImmediate)
|
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet3.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet3.DispatchImmediate)
|
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet3.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet3.DispatchImmediate)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet3.DispatchImmediate)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, TestServlet3.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch/recursive", TestServlet3.DispatchRecursive)
|
addServlet(context, "/dispatch/recursive", TestServlet3.DispatchRecursive)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +272,7 @@ class JettyServlet3TestDispatchAsync extends JettyDispatchTest {
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet3.DispatchAsync)
|
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet3.DispatchAsync)
|
||||||
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet3.DispatchAsync)
|
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet3.DispatchAsync)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet3.DispatchAsync)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet3.DispatchAsync)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, TestServlet3.DispatchAsync)
|
||||||
addServlet(context, "/dispatch/recursive", TestServlet3.DispatchRecursive)
|
addServlet(context, "/dispatch/recursive", TestServlet3.DispatchRecursive)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletRequest
|
||||||
import javax.servlet.http.HttpServletResponse
|
import javax.servlet.http.HttpServletResponse
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -49,6 +50,11 @@ class TestServlet3 {
|
||||||
case REDIRECT:
|
case REDIRECT:
|
||||||
resp.sendRedirect(endpoint.body)
|
resp.sendRedirect(endpoint.body)
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"))
|
||||||
|
resp.status = endpoint.status
|
||||||
|
resp.writer.print(endpoint.body)
|
||||||
|
break
|
||||||
case ERROR:
|
case ERROR:
|
||||||
resp.sendError(endpoint.status, endpoint.body)
|
resp.sendError(endpoint.status, endpoint.body)
|
||||||
break
|
break
|
||||||
|
@ -90,6 +96,12 @@ class TestServlet3 {
|
||||||
resp.sendRedirect(endpoint.body)
|
resp.sendRedirect(endpoint.body)
|
||||||
context.complete()
|
context.complete()
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"))
|
||||||
|
resp.status = endpoint.status
|
||||||
|
resp.writer.print(endpoint.body)
|
||||||
|
context.complete()
|
||||||
|
break
|
||||||
case ERROR:
|
case ERROR:
|
||||||
resp.status = endpoint.status
|
resp.status = endpoint.status
|
||||||
resp.writer.print(endpoint.body)
|
resp.writer.print(endpoint.body)
|
||||||
|
@ -136,6 +148,11 @@ class TestServlet3 {
|
||||||
case REDIRECT:
|
case REDIRECT:
|
||||||
resp.sendRedirect(endpoint.body)
|
resp.sendRedirect(endpoint.body)
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"))
|
||||||
|
resp.status = endpoint.status
|
||||||
|
resp.writer.print(endpoint.body)
|
||||||
|
break
|
||||||
case ERROR:
|
case ERROR:
|
||||||
resp.sendError(endpoint.status, endpoint.body)
|
resp.sendError(endpoint.status, endpoint.body)
|
||||||
break
|
break
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit
|
||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
||||||
|
@ -358,6 +359,7 @@ class TomcatServlet3TestForward extends TomcatDispatchTest {
|
||||||
addServlet(context, "/dispatch" + ERROR.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + ERROR.path, RequestDispatcherServlet.Forward)
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + EXCEPTION.path, RequestDispatcherServlet.Forward)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, RequestDispatcherServlet.Forward)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, RequestDispatcherServlet.Forward)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,6 +379,11 @@ class TomcatServlet3TestInclude extends TomcatDispatchTest {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testError() {
|
boolean testError() {
|
||||||
false
|
false
|
||||||
|
@ -416,6 +423,7 @@ class TomcatServlet3TestDispatchImmediate extends TomcatDispatchTest {
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet3.DispatchImmediate)
|
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet3.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet3.DispatchImmediate)
|
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet3.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet3.DispatchImmediate)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet3.DispatchImmediate)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, TestServlet3.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch/recursive", TestServlet3.DispatchRecursive)
|
addServlet(context, "/dispatch/recursive", TestServlet3.DispatchRecursive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,6 +444,7 @@ class TomcatServlet3TestDispatchAsync extends TomcatDispatchTest {
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet3.DispatchAsync)
|
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet3.DispatchAsync)
|
||||||
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet3.DispatchAsync)
|
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet3.DispatchAsync)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet3.DispatchAsync)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet3.DispatchAsync)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, TestServlet3.DispatchAsync)
|
||||||
addServlet(context, "/dispatch/recursive", TestServlet3.DispatchRecursive)
|
addServlet(context, "/dispatch/recursive", TestServlet3.DispatchRecursive)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpRequest
|
||||||
import jakarta.servlet.Servlet
|
import jakarta.servlet.Servlet
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -43,6 +44,7 @@ abstract class AbstractServlet5Test<SERVER, CONTEXT> extends HttpServerTest<SERV
|
||||||
addServlet(context, REDIRECT.path, servlet)
|
addServlet(context, REDIRECT.path, servlet)
|
||||||
addServlet(context, AUTH_REQUIRED.path, servlet)
|
addServlet(context, AUTH_REQUIRED.path, servlet)
|
||||||
addServlet(context, INDEXED_CHILD.path, servlet)
|
addServlet(context, INDEXED_CHILD.path, servlet)
|
||||||
|
addServlet(context, CAPTURE_HEADERS.path, servlet)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServerEndpoint lastRequest
|
protected ServerEndpoint lastRequest
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler
|
||||||
import spock.lang.IgnoreIf
|
import spock.lang.IgnoreIf
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
||||||
|
@ -172,6 +173,7 @@ class JettyServlet5TestForward extends JettyDispatchTest {
|
||||||
addServlet(context, "/dispatch" + ERROR.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + ERROR.path, RequestDispatcherServlet.Forward)
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + EXCEPTION.path, RequestDispatcherServlet.Forward)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, RequestDispatcherServlet.Forward)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, RequestDispatcherServlet.Forward)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +189,11 @@ class JettyServlet5TestInclude extends JettyDispatchTest {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testError() {
|
boolean testError() {
|
||||||
false
|
false
|
||||||
|
@ -223,6 +230,7 @@ class JettyServlet5TestDispatchImmediate extends JettyDispatchTest {
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet5.DispatchImmediate)
|
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet5.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet5.DispatchImmediate)
|
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet5.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet5.DispatchImmediate)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet5.DispatchImmediate)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, TestServlet5.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch/recursive", TestServlet5.DispatchRecursive)
|
addServlet(context, "/dispatch/recursive", TestServlet5.DispatchRecursive)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +258,7 @@ class JettyServlet5TestDispatchAsync extends JettyDispatchTest {
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet5.DispatchAsync)
|
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet5.DispatchAsync)
|
||||||
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet5.DispatchAsync)
|
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet5.DispatchAsync)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet5.DispatchAsync)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet5.DispatchAsync)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, TestServlet5.DispatchAsync)
|
||||||
addServlet(context, "/dispatch/recursive", TestServlet5.DispatchRecursive)
|
addServlet(context, "/dispatch/recursive", TestServlet5.DispatchRecursive)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import jakarta.servlet.http.HttpServletResponse
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -49,6 +50,11 @@ class TestServlet5 {
|
||||||
case REDIRECT:
|
case REDIRECT:
|
||||||
resp.sendRedirect(endpoint.body)
|
resp.sendRedirect(endpoint.body)
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"))
|
||||||
|
resp.status = endpoint.status
|
||||||
|
resp.writer.print(endpoint.body)
|
||||||
|
break
|
||||||
case ERROR:
|
case ERROR:
|
||||||
resp.sendError(endpoint.status, endpoint.body)
|
resp.sendError(endpoint.status, endpoint.body)
|
||||||
break
|
break
|
||||||
|
@ -90,6 +96,12 @@ class TestServlet5 {
|
||||||
resp.sendRedirect(endpoint.body)
|
resp.sendRedirect(endpoint.body)
|
||||||
context.complete()
|
context.complete()
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"))
|
||||||
|
resp.status = endpoint.status
|
||||||
|
resp.writer.print(endpoint.body)
|
||||||
|
context.complete()
|
||||||
|
break
|
||||||
case ERROR:
|
case ERROR:
|
||||||
resp.status = endpoint.status
|
resp.status = endpoint.status
|
||||||
resp.writer.print(endpoint.body)
|
resp.writer.print(endpoint.body)
|
||||||
|
@ -136,6 +148,11 @@ class TestServlet5 {
|
||||||
case REDIRECT:
|
case REDIRECT:
|
||||||
resp.sendRedirect(endpoint.body)
|
resp.sendRedirect(endpoint.body)
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"))
|
||||||
|
resp.status = endpoint.status
|
||||||
|
resp.writer.print(endpoint.body)
|
||||||
|
break
|
||||||
case ERROR:
|
case ERROR:
|
||||||
resp.sendError(endpoint.status, endpoint.body)
|
resp.sendError(endpoint.status, endpoint.body)
|
||||||
break
|
break
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit
|
||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.NOT_FOUND
|
||||||
|
@ -358,6 +359,7 @@ class TomcatServlet5TestForward extends TomcatDispatchTest {
|
||||||
addServlet(context, "/dispatch" + ERROR.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + ERROR.path, RequestDispatcherServlet.Forward)
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + EXCEPTION.path, RequestDispatcherServlet.Forward)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, RequestDispatcherServlet.Forward)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, RequestDispatcherServlet.Forward)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, RequestDispatcherServlet.Forward)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,6 +379,11 @@ class TomcatServlet5TestInclude extends TomcatDispatchTest {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testError() {
|
boolean testError() {
|
||||||
false
|
false
|
||||||
|
@ -416,6 +423,7 @@ class TomcatServlet5TestDispatchImmediate extends TomcatDispatchTest {
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet5.DispatchImmediate)
|
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet5.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet5.DispatchImmediate)
|
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet5.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet5.DispatchImmediate)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet5.DispatchImmediate)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, TestServlet5.DispatchImmediate)
|
||||||
addServlet(context, "/dispatch/recursive", TestServlet5.DispatchRecursive)
|
addServlet(context, "/dispatch/recursive", TestServlet5.DispatchRecursive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,6 +444,7 @@ class TomcatServlet5TestDispatchAsync extends TomcatDispatchTest {
|
||||||
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet5.DispatchAsync)
|
addServlet(context, "/dispatch" + EXCEPTION.path, TestServlet5.DispatchAsync)
|
||||||
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet5.DispatchAsync)
|
addServlet(context, "/dispatch" + REDIRECT.path, TestServlet5.DispatchAsync)
|
||||||
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet5.DispatchAsync)
|
addServlet(context, "/dispatch" + AUTH_REQUIRED.path, TestServlet5.DispatchAsync)
|
||||||
|
addServlet(context, "/dispatch" + CAPTURE_HEADERS.path, TestServlet5.DispatchAsync)
|
||||||
addServlet(context, "/dispatch/recursive", TestServlet5.DispatchRecursive)
|
addServlet(context, "/dispatch/recursive", TestServlet5.DispatchRecursive)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,11 @@ abstract class SpringWebFluxServerTest extends HttpServerTest<ConfigurableApplic
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Class<?> expectedExceptionClass() {
|
Class<?> expectedExceptionClass() {
|
||||||
return IllegalStateException
|
return IllegalStateException
|
||||||
|
|
|
@ -71,11 +71,6 @@ class SpringBootBasedTest extends HttpServerTest<ConfigurableApplicationContext>
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean testCapturedHttpHeaders() {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean hasErrorPageSpans(ServerEndpoint endpoint) {
|
boolean hasErrorPageSpans(ServerEndpoint endpoint) {
|
||||||
endpoint == NOT_FOUND
|
endpoint == NOT_FOUND
|
||||||
|
|
|
@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletRequest
|
||||||
import javax.servlet.http.HttpServletResponse
|
import javax.servlet.http.HttpServletResponse
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.PATH_PARAM
|
||||||
|
@ -108,6 +109,11 @@ class FilteredAppConfig extends WebMvcConfigurerAdapter {
|
||||||
case REDIRECT:
|
case REDIRECT:
|
||||||
resp.sendRedirect(endpoint.body)
|
resp.sendRedirect(endpoint.body)
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"))
|
||||||
|
resp.status = endpoint.status
|
||||||
|
resp.writer.print(endpoint.body)
|
||||||
|
break
|
||||||
case ERROR:
|
case ERROR:
|
||||||
resp.sendError(endpoint.status, endpoint.body)
|
resp.sendError(endpoint.status, endpoint.body)
|
||||||
break
|
break
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
package test.filter
|
package test.filter
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus
|
import org.springframework.http.HttpStatus
|
||||||
import org.springframework.http.ResponseEntity
|
import org.springframework.http.ResponseEntity
|
||||||
import org.springframework.stereotype.Controller
|
import org.springframework.stereotype.Controller
|
||||||
|
@ -56,6 +57,12 @@ class TestController {
|
||||||
throw new Exception("This should not be called")
|
throw new Exception("This should not be called")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/captureHeaders")
|
||||||
|
ResponseEntity capture_headers() {
|
||||||
|
throw new Exception("This should not be called")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ExceptionHandler
|
@ExceptionHandler
|
||||||
ResponseEntity handleException(Throwable throwable) {
|
ResponseEntity handleException(Throwable throwable) {
|
||||||
new ResponseEntity(throwable.message, HttpStatus.INTERNAL_SERVER_ERROR)
|
new ResponseEntity(throwable.message, HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
|
|
|
@ -38,6 +38,12 @@ class Struts2ActionSpanTest extends HttpServerTest<Server> implements AgentTestT
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no idea how to test that in struts
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean hasHandlerSpan(ServerEndpoint endpoint) {
|
boolean hasHandlerSpan(ServerEndpoint endpoint) {
|
||||||
return endpoint != NOT_FOUND
|
return endpoint != NOT_FOUND
|
||||||
|
|
|
@ -13,6 +13,7 @@ import jakarta.servlet.http.HttpServletResponse
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -51,6 +52,12 @@ class AsyncServlet extends HttpServlet {
|
||||||
resp.sendRedirect(endpoint.body)
|
resp.sendRedirect(endpoint.body)
|
||||||
context.complete()
|
context.complete()
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"))
|
||||||
|
resp.status = endpoint.status
|
||||||
|
resp.writer.print(endpoint.body)
|
||||||
|
context.complete()
|
||||||
|
break
|
||||||
case ERROR:
|
case ERROR:
|
||||||
resp.status = endpoint.status
|
resp.status = endpoint.status
|
||||||
resp.writer.print(endpoint.body)
|
resp.writer.print(endpoint.body)
|
||||||
|
|
|
@ -25,6 +25,9 @@ public class TestServlet extends HttpServlet {
|
||||||
if (serverEndpoint == HttpServerTest.ServerEndpoint.EXCEPTION) {
|
if (serverEndpoint == HttpServerTest.ServerEndpoint.EXCEPTION) {
|
||||||
throw new Exception(serverEndpoint.getBody());
|
throw new Exception(serverEndpoint.getBody());
|
||||||
}
|
}
|
||||||
|
if (serverEndpoint == HttpServerTest.ServerEndpoint.CAPTURE_HEADERS) {
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"));
|
||||||
|
}
|
||||||
resp.getWriter().print(serverEndpoint.getBody());
|
resp.getWriter().print(serverEndpoint.getBody());
|
||||||
if (serverEndpoint == HttpServerTest.ServerEndpoint.REDIRECT) {
|
if (serverEndpoint == HttpServerTest.ServerEndpoint.REDIRECT) {
|
||||||
resp.sendRedirect(serverEndpoint.getBody());
|
resp.sendRedirect(serverEndpoint.getBody());
|
||||||
|
|
|
@ -19,6 +19,7 @@ import spock.lang.Unroll
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -82,6 +83,7 @@ class TomcatAsyncTest extends HttpServerTest<Tomcat> implements AgentTestTrait {
|
||||||
addServlet(context, EXCEPTION.path, servlet)
|
addServlet(context, EXCEPTION.path, servlet)
|
||||||
addServlet(context, REDIRECT.path, servlet)
|
addServlet(context, REDIRECT.path, servlet)
|
||||||
addServlet(context, AUTH_REQUIRED.path, servlet)
|
addServlet(context, AUTH_REQUIRED.path, servlet)
|
||||||
|
addServlet(context, CAPTURE_HEADERS.path, servlet)
|
||||||
addServlet(context, INDEXED_CHILD.path, servlet)
|
addServlet(context, INDEXED_CHILD.path, servlet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletRequest
|
||||||
import javax.servlet.http.HttpServletResponse
|
import javax.servlet.http.HttpServletResponse
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -51,6 +52,12 @@ class AsyncServlet extends AbstractHttpServlet {
|
||||||
resp.sendRedirect(endpoint.body)
|
resp.sendRedirect(endpoint.body)
|
||||||
context.complete()
|
context.complete()
|
||||||
break
|
break
|
||||||
|
case CAPTURE_HEADERS:
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"))
|
||||||
|
resp.status = endpoint.status
|
||||||
|
resp.writer.print(endpoint.body)
|
||||||
|
context.complete()
|
||||||
|
break
|
||||||
case ERROR:
|
case ERROR:
|
||||||
resp.status = endpoint.status
|
resp.status = endpoint.status
|
||||||
resp.writer.print(endpoint.body)
|
resp.writer.print(endpoint.body)
|
||||||
|
|
|
@ -25,6 +25,9 @@ public class TestServlet extends HttpServlet {
|
||||||
if (serverEndpoint == HttpServerTest.ServerEndpoint.EXCEPTION) {
|
if (serverEndpoint == HttpServerTest.ServerEndpoint.EXCEPTION) {
|
||||||
throw new Exception(serverEndpoint.getBody());
|
throw new Exception(serverEndpoint.getBody());
|
||||||
}
|
}
|
||||||
|
if (serverEndpoint == HttpServerTest.ServerEndpoint.CAPTURE_HEADERS) {
|
||||||
|
resp.setHeader("X-Test-Response", req.getHeader("X-Test-Request"));
|
||||||
|
}
|
||||||
resp.getWriter().print(serverEndpoint.getBody());
|
resp.getWriter().print(serverEndpoint.getBody());
|
||||||
if (serverEndpoint == HttpServerTest.ServerEndpoint.REDIRECT) {
|
if (serverEndpoint == HttpServerTest.ServerEndpoint.REDIRECT) {
|
||||||
resp.sendRedirect(serverEndpoint.getBody());
|
resp.sendRedirect(serverEndpoint.getBody());
|
||||||
|
|
|
@ -19,6 +19,7 @@ import javax.servlet.ServletException
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.AUTH_REQUIRED
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD
|
||||||
|
@ -82,6 +83,7 @@ class TomcatAsyncTest extends HttpServerTest<Tomcat> implements AgentTestTrait {
|
||||||
addServlet(context, EXCEPTION.path, servlet)
|
addServlet(context, EXCEPTION.path, servlet)
|
||||||
addServlet(context, REDIRECT.path, servlet)
|
addServlet(context, REDIRECT.path, servlet)
|
||||||
addServlet(context, AUTH_REQUIRED.path, servlet)
|
addServlet(context, AUTH_REQUIRED.path, servlet)
|
||||||
|
addServlet(context, CAPTURE_HEADERS.path, servlet)
|
||||||
addServlet(context, INDEXED_CHILD.path, servlet)
|
addServlet(context, INDEXED_CHILD.path, servlet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,10 @@ import io.opentelemetry.testing.internal.armeria.common.AggregatedHttpResponse
|
||||||
import io.undertow.Handlers
|
import io.undertow.Handlers
|
||||||
import io.undertow.Undertow
|
import io.undertow.Undertow
|
||||||
import io.undertow.util.Headers
|
import io.undertow.util.Headers
|
||||||
|
import io.undertow.util.HttpString
|
||||||
import io.undertow.util.StatusCodes
|
import io.undertow.util.StatusCodes
|
||||||
|
|
||||||
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
|
||||||
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.QUERY_PARAM
|
||||||
|
@ -47,6 +49,13 @@ class UndertowServerTest extends HttpServerTest<Undertow> implements AgentTestTr
|
||||||
exchange.endExchange()
|
exchange.endExchange()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.addExactPath(CAPTURE_HEADERS.rawPath()) { exchange ->
|
||||||
|
controller(CAPTURE_HEADERS) {
|
||||||
|
exchange.setStatusCode(StatusCodes.OK)
|
||||||
|
exchange.getResponseHeaders().put(new HttpString("X-Test-Response"), exchange.getRequestHeaders().getFirst("X-Test-Request"))
|
||||||
|
exchange.getResponseSender().send(CAPTURE_HEADERS.body)
|
||||||
|
}
|
||||||
|
}
|
||||||
.addExactPath(ERROR.rawPath()) { exchange ->
|
.addExactPath(ERROR.rawPath()) { exchange ->
|
||||||
controller(ERROR) {
|
controller(ERROR) {
|
||||||
exchange.setStatusCode(ERROR.status)
|
exchange.setStatusCode(ERROR.status)
|
||||||
|
|
|
@ -58,6 +58,11 @@ class VertxRxHttpServerTest extends HttpServerTest<Vertx> implements AgentTestTr
|
||||||
server.close()
|
server.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean testPathParam() {
|
boolean testPathParam() {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -63,6 +63,11 @@ class VertxRxHttpServerTest extends HttpServerTest<Vertx> implements AgentTestTr
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String expectedServerSpanName(ServerEndpoint endpoint) {
|
String expectedServerSpanName(ServerEndpoint endpoint) {
|
||||||
switch (endpoint) {
|
switch (endpoint) {
|
||||||
|
|
|
@ -60,6 +60,11 @@ abstract class AbstractVertxHttpServerTest extends HttpServerTest<Vertx> impleme
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean testCapturedHttpHeaders() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
List<AttributeKey<?>> extraAttributes() {
|
List<AttributeKey<?>> extraAttributes() {
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -103,9 +103,8 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: enable it everywhere
|
|
||||||
boolean testCapturedHttpHeaders() {
|
boolean testCapturedHttpHeaders() {
|
||||||
false
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean testErrorBody() {
|
boolean testErrorBody() {
|
||||||
|
|
Loading…
Reference in New Issue