Migrate remaining test client calls to Armeria and remove testing-com… (#3250)
This commit is contained in:
parent
4c6cfb52ab
commit
84cc044ddf
|
|
@ -9,9 +9,6 @@ import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
|||
import io.opentelemetry.instrumentation.test.base.HttpServerTestTrait
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||
import java.util.concurrent.TimeUnit
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import org.eclipse.jetty.server.Server
|
||||
import org.eclipse.jetty.util.resource.Resource
|
||||
import org.eclipse.jetty.webapp.WebAppContext
|
||||
|
|
@ -168,12 +165,4 @@ class GwtTest extends AgentInstrumentationSpecification implements HttpServerTes
|
|||
kind SpanKind.SERVER
|
||||
}
|
||||
}
|
||||
|
||||
Request.Builder request(HttpUrl url, String method, RequestBody body) {
|
||||
return new Request.Builder()
|
||||
.url(url)
|
||||
.method(method, body)
|
||||
.header("User-Agent", TEST_USER_AGENT)
|
||||
.header("X-Forwarded-For", TEST_CLIENT_IP)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ import static Resource.Test3
|
|||
|
||||
import io.opentelemetry.instrumentation.test.base.HttpServerTestTrait
|
||||
import io.opentelemetry.testing.armeria.common.AggregatedHttpResponse
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import org.apache.cxf.endpoint.Server
|
||||
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean
|
||||
|
||||
|
|
@ -45,12 +42,6 @@ class CxfFilterTest extends JaxRsFilterTest implements HttpServerTestTrait<Serve
|
|||
httpServer.stop()
|
||||
}
|
||||
|
||||
Request.Builder request(HttpUrl url, String method, RequestBody body) {
|
||||
return new Request.Builder()
|
||||
.url(url)
|
||||
.method(method, body)
|
||||
}
|
||||
|
||||
@Override
|
||||
def makeRequest(String path) {
|
||||
AggregatedHttpResponse response = client.post(address.resolve(path).toString(), "").aggregate().join()
|
||||
|
|
|
|||
|
|
@ -7,15 +7,14 @@ import static io.opentelemetry.api.trace.SpanKind.SERVER
|
|||
import static io.opentelemetry.api.trace.StatusCode.ERROR
|
||||
|
||||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
||||
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
|
||||
import io.opentelemetry.instrumentation.test.utils.PortUtils
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||
import io.opentelemetry.testing.armeria.client.WebClient
|
||||
import io.opentelemetry.testing.armeria.common.AggregatedHttpResponse
|
||||
import io.opentelemetry.testing.armeria.common.HttpMethod
|
||||
import io.opentelemetry.testing.armeria.common.MediaType
|
||||
import io.opentelemetry.testing.armeria.common.RequestHeaders
|
||||
import java.nio.file.Files
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.Response
|
||||
import org.apache.catalina.Context
|
||||
import org.apache.catalina.startup.Tomcat
|
||||
import org.apache.jasper.JasperException
|
||||
|
|
@ -39,7 +38,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
@Shared
|
||||
String baseUrl
|
||||
|
||||
OkHttpClient client = OkHttpUtils.client()
|
||||
@Shared
|
||||
WebClient client
|
||||
|
||||
def setupSpec() {
|
||||
baseDir = Files.createTempDirectory("jsp").toFile()
|
||||
|
|
@ -58,6 +58,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
// https://stackoverflow.com/questions/48998387/code-works-with-embedded-apache-tomcat-8-but-not-with-9-whats-changed
|
||||
tomcatServer.getConnector()
|
||||
baseUrl = "http://localhost:$port/$jspWebappContext"
|
||||
client = WebClient.of(baseUrl)
|
||||
|
||||
appContext = tomcatServer.addWebapp("/$jspWebappContext",
|
||||
JspInstrumentationBasicTests.getResource("/webapps/jsptest").getPath())
|
||||
|
|
@ -74,12 +75,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
|
||||
@Unroll
|
||||
def "non-erroneous GET #test test"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/$jspFileName"
|
||||
def req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/${jspFileName}").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -111,15 +108,12 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /$jspFileName"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/${jspFileName}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 200
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 200
|
||||
|
||||
where:
|
||||
test | jspFileName | jspClassName | jspClassNamePrefix
|
||||
|
|
@ -131,11 +125,9 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
def "non-erroneous GET with query string"() {
|
||||
setup:
|
||||
String queryString = "HELLO"
|
||||
String reqUrl = baseUrl + "/getQuery.jsp"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl + "?" + queryString)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/getQuery.jsp?${queryString}").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -167,28 +159,22 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /getQuery.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/getQuery.jsp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 200
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 200
|
||||
}
|
||||
|
||||
def "non-erroneous POST"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/post.jsp"
|
||||
RequestBody requestBody = new MultipartBody.Builder()
|
||||
.setType(MultipartBody.FORM)
|
||||
.addFormDataPart("name", "world")
|
||||
RequestHeaders headers = RequestHeaders.builder(HttpMethod.POST, "/post.jsp")
|
||||
.contentType(MediaType.FORM_DATA)
|
||||
.build()
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).post(requestBody).build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.execute(headers, "name=world").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -220,25 +206,18 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /post.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/post.jsp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 200
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 200
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "erroneous runtime errors GET jsp with #test test"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/$jspFileName"
|
||||
def req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/${jspFileName}").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -296,15 +275,12 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
}
|
||||
}
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/${jspFileName}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 500
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 500
|
||||
|
||||
where:
|
||||
test | jspFileName | jspClassName | exceptionClass | errorMessageOptional
|
||||
|
|
@ -314,12 +290,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
}
|
||||
|
||||
def "non-erroneous include plain HTML GET"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/includes/includeHtml.jsp"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/includes/includeHtml.jsp").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -351,24 +323,17 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /includes/includeHtml.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/includes/includeHtml.jsp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 200
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 200
|
||||
}
|
||||
|
||||
def "non-erroneous multi GET"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/includes/includeMulti.jsp"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/includes/includeMulti.jsp").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -400,7 +365,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /includes/includeMulti.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/includes/includeMulti.jsp"
|
||||
}
|
||||
}
|
||||
span(3) {
|
||||
|
|
@ -415,7 +380,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
childOf span(2)
|
||||
name "Render /common/javaLoopH2.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/includes/includeMulti.jsp"
|
||||
}
|
||||
}
|
||||
span(5) {
|
||||
|
|
@ -430,24 +395,17 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
childOf span(2)
|
||||
name "Render /common/javaLoopH2.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/includes/includeMulti.jsp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 200
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 200
|
||||
}
|
||||
|
||||
def "#test compile error should not produce render traces and spans"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/$jspFileName"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/${jspFileName}").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -481,10 +439,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
}
|
||||
}
|
||||
}
|
||||
res.code() == 500
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 500
|
||||
|
||||
where:
|
||||
test | jspFileName | jspClassName | jspClassNamePrefix
|
||||
|
|
@ -493,15 +448,11 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
}
|
||||
|
||||
def "direct static file reference"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/$staticFile"
|
||||
def req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/${staticFile}").aggregate().join()
|
||||
|
||||
then:
|
||||
res.code() == 200
|
||||
res.status().code() == 200
|
||||
assertTraces(1) {
|
||||
trace(0, 1) {
|
||||
span(0) {
|
||||
|
|
@ -522,9 +473,6 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
|
|||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
|
||||
where:
|
||||
staticFile = "common/hello.html"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,11 @@ import static io.opentelemetry.api.trace.SpanKind.SERVER
|
|||
import static io.opentelemetry.api.trace.StatusCode.ERROR
|
||||
|
||||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
||||
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
|
||||
import io.opentelemetry.instrumentation.test.utils.PortUtils
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||
import io.opentelemetry.testing.armeria.client.WebClient
|
||||
import io.opentelemetry.testing.armeria.common.AggregatedHttpResponse
|
||||
import java.nio.file.Files
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.apache.catalina.Context
|
||||
import org.apache.catalina.startup.Tomcat
|
||||
import org.apache.jasper.JasperException
|
||||
|
|
@ -36,7 +34,8 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
@Shared
|
||||
String baseUrl
|
||||
|
||||
OkHttpClient client = OkHttpUtils.client()
|
||||
@Shared
|
||||
WebClient client
|
||||
|
||||
def setupSpec() {
|
||||
baseDir = Files.createTempDirectory("jsp").toFile()
|
||||
|
|
@ -56,6 +55,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
tomcatServer.getConnector()
|
||||
|
||||
baseUrl = "http://localhost:$port/$jspWebappContext"
|
||||
client = WebClient.of(baseUrl)
|
||||
|
||||
appContext = tomcatServer.addWebapp("/$jspWebappContext",
|
||||
JspInstrumentationForwardTests.getResource("/webapps/jsptest").getPath())
|
||||
|
|
@ -72,12 +72,8 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
|
||||
@Unroll
|
||||
def "non-erroneous GET forward to #forwardTo"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/$forwardFromFileName"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/$forwardFromFileName").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -109,7 +105,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /$forwardFromFileName"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/$forwardFromFileName"
|
||||
}
|
||||
}
|
||||
span(3) {
|
||||
|
|
@ -125,15 +121,12 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
name "Render /$forwardDestFileName"
|
||||
attributes {
|
||||
"jsp.forwardOrigin" "/$forwardFromFileName"
|
||||
"jsp.requestURL" baseUrl + "/$forwardDestFileName"
|
||||
"jsp.requestURL" "${baseUrl}/$forwardDestFileName"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 200
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 200
|
||||
|
||||
where:
|
||||
forwardTo | forwardFromFileName | forwardDestFileName | jspForwardFromClassName | jspForwardFromClassPrefix | jspForwardDestClassName | jspForwardDestClassPrefix
|
||||
|
|
@ -142,12 +135,8 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
}
|
||||
|
||||
def "non-erroneous GET forward to plain HTML"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/forwards/forwardToHtml.jsp"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/forwards/forwardToHtml.jsp").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -179,24 +168,17 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /forwards/forwardToHtml.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/forwards/forwardToHtml.jsp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 200
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 200
|
||||
}
|
||||
|
||||
def "non-erroneous GET forwarded to jsp with multiple includes"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/forwards/forwardToIncludeMulti.jsp"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/forwards/forwardToIncludeMulti.jsp").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -228,7 +210,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /forwards/forwardToIncludeMulti.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/forwards/forwardToIncludeMulti.jsp"
|
||||
}
|
||||
}
|
||||
span(3) {
|
||||
|
|
@ -244,7 +226,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
name "Render /includes/includeMulti.jsp"
|
||||
attributes {
|
||||
"jsp.forwardOrigin" "/forwards/forwardToIncludeMulti.jsp"
|
||||
"jsp.requestURL" baseUrl + "/includes/includeMulti.jsp"
|
||||
"jsp.requestURL" "${baseUrl}/includes/includeMulti.jsp"
|
||||
}
|
||||
}
|
||||
span(5) {
|
||||
|
|
@ -260,7 +242,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
name "Render /common/javaLoopH2.jsp"
|
||||
attributes {
|
||||
"jsp.forwardOrigin" "/forwards/forwardToIncludeMulti.jsp"
|
||||
"jsp.requestURL" baseUrl + "/includes/includeMulti.jsp"
|
||||
"jsp.requestURL" "${baseUrl}/includes/includeMulti.jsp"
|
||||
}
|
||||
}
|
||||
span(7) {
|
||||
|
|
@ -276,24 +258,17 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
name "Render /common/javaLoopH2.jsp"
|
||||
attributes {
|
||||
"jsp.forwardOrigin" "/forwards/forwardToIncludeMulti.jsp"
|
||||
"jsp.requestURL" baseUrl + "/includes/includeMulti.jsp"
|
||||
"jsp.requestURL" "${baseUrl}/includes/includeMulti.jsp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 200
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 200
|
||||
}
|
||||
|
||||
def "non-erroneous GET forward to another forward (2 forwards)"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/forwards/forwardToJspForward.jsp"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).get() build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/forwards/forwardToJspForward.jsp").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -325,7 +300,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /forwards/forwardToJspForward.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/forwards/forwardToJspForward.jsp"
|
||||
}
|
||||
}
|
||||
span(3) {
|
||||
|
|
@ -341,7 +316,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
name "Render /forwards/forwardToSimpleJava.jsp"
|
||||
attributes {
|
||||
"jsp.forwardOrigin" "/forwards/forwardToJspForward.jsp"
|
||||
"jsp.requestURL" baseUrl + "/forwards/forwardToSimpleJava.jsp"
|
||||
"jsp.requestURL" "${baseUrl}/forwards/forwardToSimpleJava.jsp"
|
||||
}
|
||||
}
|
||||
span(5) {
|
||||
|
|
@ -357,24 +332,17 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
name "Render /common/loop.jsp"
|
||||
attributes {
|
||||
"jsp.forwardOrigin" "/forwards/forwardToJspForward.jsp"
|
||||
"jsp.requestURL" baseUrl + "/common/loop.jsp"
|
||||
"jsp.requestURL" "${baseUrl}/common/loop.jsp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code() == 200
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 200
|
||||
}
|
||||
|
||||
def "forward to jsp with compile error should not produce a 2nd render span"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/forwards/forwardToCompileError.jsp"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/forwards/forwardToCompileError.jsp").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -410,7 +378,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
status ERROR
|
||||
errorEvent(JasperException, String)
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/forwards/forwardToCompileError.jsp"
|
||||
}
|
||||
}
|
||||
span(3) {
|
||||
|
|
@ -425,19 +393,12 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
}
|
||||
}
|
||||
}
|
||||
res.code() == 500
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 500
|
||||
}
|
||||
|
||||
def "forward to non existent jsp should be 404"() {
|
||||
setup:
|
||||
String reqUrl = baseUrl + "/forwards/forwardToNonExistent.jsp"
|
||||
Request req = new Request.Builder().url(new URL(reqUrl)).get().build()
|
||||
|
||||
when:
|
||||
Response res = client.newCall(req).execute()
|
||||
AggregatedHttpResponse res = client.get("/forwards/forwardToNonExistent.jsp").aggregate().join()
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
|
|
@ -470,7 +431,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
childOf span(0)
|
||||
name "Render /forwards/forwardToNonExistent.jsp"
|
||||
attributes {
|
||||
"jsp.requestURL" reqUrl
|
||||
"jsp.requestURL" "${baseUrl}/forwards/forwardToNonExistent.jsp"
|
||||
}
|
||||
}
|
||||
span(3) {
|
||||
|
|
@ -479,9 +440,6 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
|
|||
}
|
||||
}
|
||||
}
|
||||
res.code() == 404
|
||||
|
||||
cleanup:
|
||||
res.close()
|
||||
res.status().code() == 404
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,5 +3,9 @@ apply from: "$rootDir/gradle/instrumentation-library.gradle"
|
|||
dependencies {
|
||||
library "org.apache.logging.log4j:log4j-core:2.13.2"
|
||||
|
||||
// Library instrumentation cannot be applied to 2.13.2 due to a bug in Log4J. The agent works
|
||||
// around it.
|
||||
testLibrary "org.apache.logging.log4j:log4j-core:2.13.3"
|
||||
|
||||
testImplementation project(':instrumentation:log4j:log4j-2-testing')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,6 @@ import javax.servlet.ServletException
|
|||
import javax.servlet.http.HttpServlet
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
import javax.servlet.http.HttpServletResponse
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import spock.lang.Unroll
|
||||
|
||||
abstract class AbstractServlet3MappingTest<SERVER, CONTEXT> extends AgentInstrumentationSpecification implements HttpServerTestTrait<SERVER> {
|
||||
|
|
@ -35,12 +32,6 @@ abstract class AbstractServlet3MappingTest<SERVER, CONTEXT> extends AgentInstrum
|
|||
}
|
||||
}
|
||||
|
||||
Request.Builder request(HttpUrl url, String method, RequestBody body) {
|
||||
return new Request.Builder()
|
||||
.url(url)
|
||||
.method(method, body)
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "test path #path"() {
|
||||
setup:
|
||||
|
|
|
|||
|
|
@ -14,9 +14,6 @@ import jakarta.servlet.ServletException
|
|||
import jakarta.servlet.http.HttpServlet
|
||||
import jakarta.servlet.http.HttpServletRequest
|
||||
import jakarta.servlet.http.HttpServletResponse
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import spock.lang.Unroll
|
||||
|
||||
abstract class AbstractServlet5MappingTest<SERVER, CONTEXT> extends AgentInstrumentationSpecification implements HttpServerTestTrait<SERVER> {
|
||||
|
|
@ -35,12 +32,6 @@ abstract class AbstractServlet5MappingTest<SERVER, CONTEXT> extends AgentInstrum
|
|||
}
|
||||
}
|
||||
|
||||
Request.Builder request(HttpUrl url, String method, RequestBody body) {
|
||||
return new Request.Builder()
|
||||
.url(url)
|
||||
.method(method, body)
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "test path #path"() {
|
||||
setup:
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@
|
|||
import static io.opentelemetry.api.trace.SpanKind.SERVER
|
||||
|
||||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
||||
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
|
||||
import io.opentelemetry.instrumentation.test.utils.PortUtils
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import io.opentelemetry.testing.armeria.client.WebClient
|
||||
import spark.Spark
|
||||
import spock.lang.Shared
|
||||
|
||||
|
|
@ -19,11 +17,13 @@ class SparkJavaBasedTest extends AgentInstrumentationSpecification {
|
|||
@Shared
|
||||
int port
|
||||
|
||||
OkHttpClient client = OkHttpUtils.client()
|
||||
@Shared
|
||||
WebClient client
|
||||
|
||||
def setupSpec() {
|
||||
port = PortUtils.findOpenPort()
|
||||
TestSparkJavaApplication.initSpark(port)
|
||||
client = WebClient.of("http://localhost:${port}")
|
||||
}
|
||||
|
||||
def cleanupSpec() {
|
||||
|
|
@ -31,16 +31,12 @@ class SparkJavaBasedTest extends AgentInstrumentationSpecification {
|
|||
}
|
||||
|
||||
def "generates spans"() {
|
||||
setup:
|
||||
def request = new Request.Builder()
|
||||
.url("http://localhost:$port/param/asdf1234")
|
||||
.get()
|
||||
.build()
|
||||
def response = client.newCall(request).execute()
|
||||
when:
|
||||
def response = client.get("/param/asdf1234").aggregate().join()
|
||||
|
||||
expect:
|
||||
then:
|
||||
port != 0
|
||||
def content = response.body.string()
|
||||
def content = response.contentUtf8()
|
||||
content == "Hello asdf1234"
|
||||
|
||||
assertTraces(1) {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,14 @@ import static io.opentelemetry.api.trace.SpanKind.SERVER
|
|||
import static io.opentelemetry.api.trace.StatusCode.ERROR
|
||||
|
||||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
||||
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import io.opentelemetry.testing.armeria.client.ClientRequestContext
|
||||
import io.opentelemetry.testing.armeria.client.DecoratingHttpClientFunction
|
||||
import io.opentelemetry.testing.armeria.client.HttpClient
|
||||
import io.opentelemetry.testing.armeria.client.WebClient
|
||||
import io.opentelemetry.testing.armeria.common.HttpHeaderNames
|
||||
import io.opentelemetry.testing.armeria.common.HttpRequest
|
||||
import io.opentelemetry.testing.armeria.common.HttpResponse
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.boot.test.context.TestConfiguration
|
||||
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory
|
||||
|
|
@ -35,26 +38,39 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
}
|
||||
}
|
||||
|
||||
static final okhttp3.MediaType PLAIN_TYPE = okhttp3.MediaType.parse("text/plain; charset=utf-8")
|
||||
static final String INNER_HANDLER_FUNCTION_CLASS_TAG_PREFIX = SpringWebFluxTestApplication.getName() + "\$"
|
||||
static final String SPRING_APP_CLASS_ANON_NESTED_CLASS_PREFIX = SpringWebFluxTestApplication.getSimpleName() + "\$"
|
||||
|
||||
@LocalServerPort
|
||||
private int port
|
||||
int port
|
||||
|
||||
OkHttpClient client = OkHttpUtils.client(true)
|
||||
WebClient client
|
||||
|
||||
def setup() {
|
||||
client = WebClient.builder("h1c://localhost:$port")
|
||||
.decorator(new DecoratingHttpClientFunction() {
|
||||
// https://github.com/line/armeria/issues/2489
|
||||
@Override
|
||||
HttpResponse execute(HttpClient delegate, ClientRequestContext ctx, HttpRequest req) throws Exception {
|
||||
return HttpResponse.from(delegate.execute(ctx, req).aggregate().thenApply {resp ->
|
||||
if (resp.status().isRedirection()) {
|
||||
return delegate.execute(ctx, HttpRequest.of(req.method(), resp.headers().get(HttpHeaderNames.LOCATION)))
|
||||
}
|
||||
return resp.toHttpResponse()
|
||||
})
|
||||
}
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "Basic GET test #testName"() {
|
||||
setup:
|
||||
String url = "http://localhost:$port$urlPath"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
def response = client.get(urlPath).aggregate().join()
|
||||
|
||||
then:
|
||||
response.code == 200
|
||||
response.body().string() == expectedResponseBody
|
||||
response.status().code() == 200
|
||||
response.contentUtf8() == expectedResponseBody
|
||||
assertTraces(1) {
|
||||
trace(0, 2) {
|
||||
span(0) {
|
||||
|
|
@ -64,7 +80,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.HTTP_URL.key}" url
|
||||
"${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port$urlPath"
|
||||
"${SemanticAttributes.HTTP_METHOD.key}" "GET"
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key}" 200
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||
|
|
@ -113,15 +129,12 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
|
||||
@Unroll
|
||||
def "GET test with async response #testName"() {
|
||||
setup:
|
||||
String url = "http://localhost:$port$urlPath"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
def response = client.get(urlPath).aggregate().join()
|
||||
|
||||
then:
|
||||
response.code == 200
|
||||
response.body().string() == expectedResponseBody
|
||||
response.status().code() == 200
|
||||
response.contentUtf8() == expectedResponseBody
|
||||
assertTraces(1) {
|
||||
trace(0, 3) {
|
||||
span(0) {
|
||||
|
|
@ -131,7 +144,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.HTTP_URL.key}" url
|
||||
"${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port$urlPath"
|
||||
"${SemanticAttributes.HTTP_METHOD.key}" "GET"
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key}" 200
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||
|
|
@ -199,15 +212,12 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
when INTERNAL handler span has already finished. Thus, "tracedMethod" has SERVER Netty span as its parent.
|
||||
*/
|
||||
def "Create span during handler function"() {
|
||||
setup:
|
||||
String url = "http://localhost:$port$urlPath"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
def response = client.get(urlPath).aggregate().join()
|
||||
|
||||
then:
|
||||
response.code == 200
|
||||
response.body().string() == expectedResponseBody
|
||||
response.status().code() == 200
|
||||
response.contentUtf8() == expectedResponseBody
|
||||
assertTraces(1) {
|
||||
trace(0, 3) {
|
||||
span(0) {
|
||||
|
|
@ -217,7 +227,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.HTTP_URL.key}" url
|
||||
"${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port$urlPath"
|
||||
"${SemanticAttributes.HTTP_METHOD.key}" "GET"
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key}" 200
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||
|
|
@ -264,15 +274,11 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
}
|
||||
|
||||
def "404 GET test"() {
|
||||
setup:
|
||||
String url = "http://localhost:$port/notfoundgreet"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
def response = client.get("/notfoundgreet").aggregate().join()
|
||||
|
||||
then:
|
||||
response.code == 404
|
||||
response.status().code() == 404
|
||||
assertTraces(1) {
|
||||
trace(0, 2) {
|
||||
span(0) {
|
||||
|
|
@ -283,7 +289,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.HTTP_URL.key}" url
|
||||
"${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port/notfoundgreet"
|
||||
"${SemanticAttributes.HTTP_METHOD.key}" "GET"
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key}" 404
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||
|
|
@ -308,16 +314,12 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
def "Basic POST test"() {
|
||||
setup:
|
||||
String echoString = "TEST"
|
||||
String url = "http://localhost:$port/echo"
|
||||
RequestBody body = RequestBody.create(PLAIN_TYPE, echoString)
|
||||
def request = new Request.Builder().url(url).post(body).build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
def response = client.post("/echo", echoString).aggregate().join()
|
||||
|
||||
then:
|
||||
response.code() == 202
|
||||
response.body().string() == echoString
|
||||
response.status().code() == 202
|
||||
response.contentUtf8() == echoString
|
||||
assertTraces(1) {
|
||||
trace(0, 3) {
|
||||
span(0) {
|
||||
|
|
@ -327,7 +329,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.HTTP_URL.key}" url
|
||||
"${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port/echo"
|
||||
"${SemanticAttributes.HTTP_METHOD.key}" "POST"
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key}" 202
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||
|
|
@ -358,15 +360,11 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
|
||||
@Unroll
|
||||
def "GET to bad endpoint #testName"() {
|
||||
setup:
|
||||
String url = "http://localhost:$port$urlPath"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
def response = client.get(urlPath).aggregate().join()
|
||||
|
||||
then:
|
||||
response.code() == 500
|
||||
response.status().code() == 500
|
||||
assertTraces(1) {
|
||||
trace(0, 2) {
|
||||
span(0) {
|
||||
|
|
@ -377,7 +375,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.HTTP_URL.key}" url
|
||||
"${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port$urlPath"
|
||||
"${SemanticAttributes.HTTP_METHOD.key}" "GET"
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key}" 500
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||
|
|
@ -424,15 +422,13 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
|
||||
def "Redirect test"() {
|
||||
setup:
|
||||
String url = "http://localhost:$port/double-greet-redirect"
|
||||
String finalUrl = "http://localhost:$port/double-greet"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = client.newCall(request).execute()
|
||||
def response = client.get("/double-greet-redirect").aggregate().join()
|
||||
|
||||
then:
|
||||
response.code == 200
|
||||
response.status().code() == 200
|
||||
assertTraces(2) {
|
||||
// TODO: why order of spans is different in these traces?
|
||||
trace(0, 2) {
|
||||
|
|
@ -443,7 +439,7 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.HTTP_URL.key}" url
|
||||
"${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port/double-greet-redirect"
|
||||
"${SemanticAttributes.HTTP_METHOD.key}" "GET"
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key}" 307
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||
|
|
@ -499,14 +495,13 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification {
|
|||
def "Multiple GETs to delaying route #testName"() {
|
||||
setup:
|
||||
def requestsCount = 50 // Should be more than 2x CPUs to fish out some bugs
|
||||
String url = "http://localhost:$port$urlPath"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
def url = "http://localhost:$port$urlPath"
|
||||
when:
|
||||
def responses = (0..requestsCount - 1).collect { client.newCall(request).execute() }
|
||||
def responses = (0..requestsCount - 1).collect { client.get(urlPath).aggregate().join() }
|
||||
|
||||
then:
|
||||
responses.every { it.code == 200 }
|
||||
responses.every { it.body().string() == expectedResponseBody }
|
||||
responses.every { it.status().code() == 200 }
|
||||
responses.every { it.contentUtf8() == expectedResponseBody }
|
||||
assertTraces(responses.size()) {
|
||||
responses.eachWithIndex { def response, int i ->
|
||||
trace(i, 2) {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@ import io.opentelemetry.api.trace.SpanKind
|
|||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
||||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
||||
import io.opentelemetry.instrumentation.test.base.HttpServerTestTrait
|
||||
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.Response
|
||||
import io.opentelemetry.testing.armeria.client.ClientRequestContext
|
||||
import io.opentelemetry.testing.armeria.client.DecoratingHttpClientFunction
|
||||
import io.opentelemetry.testing.armeria.client.HttpClient
|
||||
import io.opentelemetry.testing.armeria.client.WebClient
|
||||
import io.opentelemetry.testing.armeria.common.AggregatedHttpResponse
|
||||
import io.opentelemetry.testing.armeria.common.HttpHeaderNames
|
||||
import io.opentelemetry.testing.armeria.common.HttpRequest
|
||||
import io.opentelemetry.testing.armeria.common.HttpResponse
|
||||
import org.eclipse.jetty.server.Server
|
||||
import org.eclipse.jetty.util.resource.Resource
|
||||
import org.eclipse.jetty.webapp.WebAppContext
|
||||
|
|
@ -23,8 +25,6 @@ import org.jsoup.Jsoup
|
|||
|
||||
class TapestryTest extends AgentInstrumentationSpecification implements HttpServerTestTrait<Server> {
|
||||
|
||||
static OkHttpClient client = OkHttpUtils.client(true)
|
||||
|
||||
@Override
|
||||
Server startServer(int port) {
|
||||
WebAppContext webAppContext = new WebAppContext()
|
||||
|
|
@ -54,6 +54,25 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ
|
|||
return "/jetty-context"
|
||||
}
|
||||
|
||||
WebClient client
|
||||
|
||||
def setup() {
|
||||
client = WebClient.builder(address)
|
||||
.decorator(new DecoratingHttpClientFunction() {
|
||||
// https://github.com/line/armeria/issues/2489
|
||||
@Override
|
||||
HttpResponse execute(HttpClient delegate, ClientRequestContext ctx, HttpRequest req) throws Exception {
|
||||
return HttpResponse.from(delegate.execute(ctx, req).aggregate().thenApply {resp ->
|
||||
if (resp.status().isRedirection()) {
|
||||
return delegate.execute(ctx, HttpRequest.of(req.method(), URI.create(resp.headers().get(HttpHeaderNames.LOCATION)).path))
|
||||
}
|
||||
return resp.toHttpResponse()
|
||||
})
|
||||
}
|
||||
})
|
||||
.build()
|
||||
}
|
||||
|
||||
static serverSpan(TraceAssert trace, int index, String spanName) {
|
||||
trace.span(index) {
|
||||
hasNoParent()
|
||||
|
|
@ -65,13 +84,11 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ
|
|||
|
||||
def "test index page"() {
|
||||
setup:
|
||||
def url = HttpUrl.get(address.resolve("")).newBuilder().build()
|
||||
def request = request(url, "GET", null).build()
|
||||
Response response = client.newCall(request).execute()
|
||||
def doc = Jsoup.parse(response.body().string())
|
||||
AggregatedHttpResponse response = client.get("/").aggregate().join()
|
||||
def doc = Jsoup.parse(response.contentUtf8())
|
||||
|
||||
expect:
|
||||
response.code() == 200
|
||||
response.status().code() == 200
|
||||
doc.selectFirst("title").text() == "Index page"
|
||||
|
||||
assertTraces(1) {
|
||||
|
|
@ -85,13 +102,11 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ
|
|||
def "test start action"() {
|
||||
setup:
|
||||
// index.start triggers an action named "start" on index page
|
||||
def url = HttpUrl.get(address.resolve("index.start")).newBuilder().build()
|
||||
def request = request(url, "GET", null).build()
|
||||
Response response = client.newCall(request).execute()
|
||||
def doc = Jsoup.parse(response.body().string())
|
||||
AggregatedHttpResponse response = client.get("/index.start").aggregate().join()
|
||||
def doc = Jsoup.parse(response.contentUtf8())
|
||||
|
||||
expect:
|
||||
response.code() == 200
|
||||
response.status().code() == 200
|
||||
doc.selectFirst("title").text() == "Other page"
|
||||
|
||||
assertTraces(2) {
|
||||
|
|
@ -99,7 +114,7 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ
|
|||
serverSpan(it, 0, getContextPath() + "/Index")
|
||||
basicSpan(it, 1, "activate/Index", span(0))
|
||||
basicSpan(it, 2, "action/Index:start", span(0))
|
||||
basicSpan(it, 3, "HttpServletResponseWrapper.sendRedirect", span(2))
|
||||
basicSpan(it, 3, "Response.sendRedirect", span(2))
|
||||
}
|
||||
trace(1, 2) {
|
||||
serverSpan(it, 0, getContextPath() + "/Other")
|
||||
|
|
@ -111,12 +126,10 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ
|
|||
def "test exception action"() {
|
||||
setup:
|
||||
// index.exception triggers an action named "exception" on index page
|
||||
def url = HttpUrl.get(address.resolve("index.exception")).newBuilder().build()
|
||||
def request = request(url, "GET", null).build()
|
||||
Response response = client.newCall(request).execute()
|
||||
AggregatedHttpResponse response = client.get("/index.exception").aggregate().join()
|
||||
|
||||
expect:
|
||||
response.code() == 500
|
||||
response.status().code() == 500
|
||||
|
||||
assertTraces(1) {
|
||||
trace(0, 3) {
|
||||
|
|
@ -131,12 +144,4 @@ class TapestryTest extends AgentInstrumentationSpecification implements HttpServ
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Request.Builder request(HttpUrl url, String method, RequestBody body) {
|
||||
return new Request.Builder()
|
||||
.url(url)
|
||||
.method(method, body)
|
||||
.header("User-Agent", TEST_USER_AGENT)
|
||||
.header("X-Forwarded-For", TEST_CLIENT_IP)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
|||
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
|
||||
import io.opentelemetry.instrumentation.test.base.HttpServerTestTrait
|
||||
import java.util.concurrent.TimeUnit
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import org.openqa.selenium.chrome.ChromeOptions
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
|
|
@ -79,14 +76,6 @@ abstract class AbstractVaadinTest extends AgentInstrumentationSpecification impl
|
|||
return "/xyz"
|
||||
}
|
||||
|
||||
Request.Builder request(HttpUrl url, String method, RequestBody body) {
|
||||
return new Request.Builder()
|
||||
.url(url)
|
||||
.method(method, body)
|
||||
.header("User-Agent", TEST_USER_AGENT)
|
||||
.header("X-Forwarded-For", TEST_CLIENT_IP)
|
||||
}
|
||||
|
||||
def waitForStart(driver) {
|
||||
// In development mode ui javascript is compiled when application starts
|
||||
// this involves downloading and installing npm and a bunch of packages
|
||||
|
|
|
|||
|
|
@ -17,19 +17,19 @@ import io.opentelemetry.api.GlobalOpenTelemetry
|
|||
import io.opentelemetry.api.trace.Span
|
||||
import io.opentelemetry.context.Context
|
||||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
||||
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
|
||||
import io.opentelemetry.instrumentation.test.utils.PortUtils
|
||||
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
|
||||
import io.opentelemetry.testing.armeria.client.WebClient
|
||||
import io.opentelemetry.testing.armeria.common.HttpRequest
|
||||
import io.opentelemetry.testing.armeria.common.HttpRequestBuilder
|
||||
import io.vertx.reactivex.core.Vertx
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.concurrent.Executors
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import spock.lang.Shared
|
||||
|
||||
class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
|
||||
@Shared
|
||||
OkHttpClient client = OkHttpUtils.client()
|
||||
WebClient client
|
||||
|
||||
@Shared
|
||||
int port
|
||||
|
|
@ -40,6 +40,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
|
|||
def setupSpec() {
|
||||
port = PortUtils.findOpenPort()
|
||||
server = VertxReactiveWebServer.start(port)
|
||||
client = WebClient.of("h1c://localhost:${port}")
|
||||
}
|
||||
|
||||
def cleanupSpec() {
|
||||
|
|
@ -50,12 +51,10 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
|
|||
//Tests io.opentelemetry.javaagent.instrumentation.vertx.reactive.VertxRxInstrumentation
|
||||
def "should propagate context over vert.x rx-java framework"() {
|
||||
setup:
|
||||
def url = "http://localhost:$port/listProducts"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
def response = client.newCall(request).execute()
|
||||
def response = client.get("/listProducts").aggregate().join()
|
||||
|
||||
expect:
|
||||
response.code() == SUCCESS.status
|
||||
response.status().code() == SUCCESS.status
|
||||
|
||||
and:
|
||||
assertTraces(1) {
|
||||
|
|
@ -67,7 +66,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
|
|||
attributes {
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.HTTP_URL.key}" url
|
||||
"${SemanticAttributes.HTTP_URL.key}" "http://localhost:${port}/listProducts"
|
||||
"${SemanticAttributes.HTTP_METHOD.key}" "GET"
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key}" 200
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||
|
|
@ -98,12 +97,12 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
|
|||
def "should propagate context correctly over vert.x rx-java framework with high concurrency"() {
|
||||
setup:
|
||||
int count = 100
|
||||
def baseUrl = "http://localhost:$port/listProducts"
|
||||
def baseUrl = "/listProducts"
|
||||
def latch = new CountDownLatch(1)
|
||||
|
||||
def pool = Executors.newFixedThreadPool(8)
|
||||
def propagator = GlobalOpenTelemetry.getPropagators().getTextMapPropagator()
|
||||
def setter = { Request.Builder carrier, String name, String value ->
|
||||
def setter = { HttpRequestBuilder carrier, String name, String value ->
|
||||
carrier.header(name, value)
|
||||
}
|
||||
|
||||
|
|
@ -111,12 +110,12 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
|
|||
count.times { index ->
|
||||
def job = {
|
||||
latch.await()
|
||||
Request.Builder builder = new Request.Builder().url("$baseUrl?$TEST_REQUEST_ID_PARAMETER=$index").get()
|
||||
|
||||
runUnderTrace("client " + index) {
|
||||
HttpRequestBuilder builder = HttpRequest.builder()
|
||||
.get("${baseUrl}?${TEST_REQUEST_ID_PARAMETER}=${index}")
|
||||
Span.current().setAttribute(TEST_REQUEST_ID_ATTRIBUTE, index)
|
||||
propagator.inject(Context.current(), builder, setter)
|
||||
client.newCall(builder.build()).execute()
|
||||
client.execute(builder.build()).aggregate().join()
|
||||
}
|
||||
}
|
||||
pool.submit(job)
|
||||
|
|
@ -137,7 +136,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
|
|||
basicServerSpan(it, 1, "/listProducts", span(0), null) {
|
||||
"${SemanticAttributes.NET_PEER_PORT.key}" Long
|
||||
"${SemanticAttributes.NET_PEER_IP.key}" "127.0.0.1"
|
||||
"${SemanticAttributes.HTTP_URL.key}" "$baseUrl?$TEST_REQUEST_ID_PARAMETER=$requestId"
|
||||
"${SemanticAttributes.HTTP_URL.key}" "http://localhost:$port$baseUrl?$TEST_REQUEST_ID_PARAMETER=$requestId"
|
||||
"${SemanticAttributes.HTTP_METHOD.key}" "GET"
|
||||
"${SemanticAttributes.HTTP_STATUS_CODE.key}" 200
|
||||
"${SemanticAttributes.HTTP_FLAVOR.key}" "1.1"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import static org.junit.Assume.assumeTrue
|
|||
import io.opentelemetry.proto.trace.v1.Span
|
||||
import java.util.jar.Attributes
|
||||
import java.util.jar.JarFile
|
||||
import okhttp3.Request
|
||||
import org.junit.runner.RunWith
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Unroll
|
||||
|
|
@ -77,15 +76,13 @@ abstract class AppServerTest extends SmokeTest {
|
|||
def "#appServer smoke test on JDK #jdk"(String appServer, String jdk, boolean isWindows) {
|
||||
assumeTrue(testSmoke())
|
||||
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/greeting"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/app/greeting").aggregate().join()
|
||||
TraceInspector traces = new TraceInspector(waitForTraces())
|
||||
Set<String> traceIds = traces.traceIds
|
||||
String responseBody = response.body().string()
|
||||
String responseBody = response.contentUtf8()
|
||||
|
||||
then: "There is one trace"
|
||||
traceIds.size() == 1
|
||||
|
|
@ -101,7 +98,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traces.countSpansByName(getSpanName('/app/headers')) == 1
|
||||
|
||||
and: "The span for the initial web request"
|
||||
traces.countFilteredAttributes("http.url", url) == 1
|
||||
traces.countFilteredAttributes("http.url", "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/greeting") == 1
|
||||
|
||||
and: "Client and server spans for the remote call"
|
||||
traces.countFilteredAttributes("http.url", "http://localhost:8080/app/headers") == 2
|
||||
|
|
@ -115,24 +112,19 @@ abstract class AppServerTest extends SmokeTest {
|
|||
and: "Number of spans tagged with expected OS type"
|
||||
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == 3
|
||||
|
||||
cleanup:
|
||||
response?.close()
|
||||
|
||||
where:
|
||||
[appServer, jdk, isWindows] << getTestParams()
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "#appServer test static file found on JDK #jdk"(String appServer, String jdk, boolean isWindows) {
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/hello.txt"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/app/hello.txt").aggregate().join()
|
||||
TraceInspector traces = new TraceInspector(waitForTraces())
|
||||
Set<String> traceIds = traces.traceIds
|
||||
String responseBody = response.body().string()
|
||||
String responseBody = response.contentUtf8()
|
||||
|
||||
then: "There is one trace"
|
||||
traceIds.size() == 1
|
||||
|
|
@ -147,7 +139,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traces.countSpansByName(getSpanName('/app/hello.txt')) == 1
|
||||
|
||||
and: "The span for the initial web request"
|
||||
traces.countFilteredAttributes("http.url", url) == 1
|
||||
traces.countFilteredAttributes("http.url", "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/hello.txt") == 1
|
||||
|
||||
and: "Number of spans tagged with current otel library version"
|
||||
traces.countFilteredResourceAttributes("telemetry.auto.version", currentAgentVersion) == 1
|
||||
|
|
@ -155,21 +147,16 @@ abstract class AppServerTest extends SmokeTest {
|
|||
and: "Number of spans tagged with expected OS type"
|
||||
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == 1
|
||||
|
||||
cleanup:
|
||||
response?.close()
|
||||
|
||||
where:
|
||||
[appServer, jdk, isWindows] << getTestParams()
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "#appServer test static file not found on JDK #jdk"(String appServer, String jdk, boolean isWindows) {
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/file-that-does-not-exist"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/app/file-that-does-not-exist").aggregate().join()
|
||||
TraceInspector traces = new TraceInspector(waitForTraces())
|
||||
Set<String> traceIds = traces.traceIds
|
||||
|
||||
|
|
@ -177,7 +164,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traceIds.size() == 1
|
||||
|
||||
and: "Response code is 404"
|
||||
response.code() == 404
|
||||
response.status().code() == 404
|
||||
|
||||
and: "There is one server span"
|
||||
traces.countSpansByKind(Span.SpanKind.SPAN_KIND_SERVER) == 1
|
||||
|
|
@ -186,7 +173,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traces.countSpansByName(getSpanName('/app/file-that-does-not-exist')) == 1
|
||||
|
||||
and: "The span for the initial web request"
|
||||
traces.countFilteredAttributes("http.url", url) == 1
|
||||
traces.countFilteredAttributes("http.url", "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/file-that-does-not-exist") == 1
|
||||
|
||||
and: "Number of spans tagged with current otel library version"
|
||||
traces.countFilteredResourceAttributes("telemetry.auto.version", currentAgentVersion) == traces.countSpans()
|
||||
|
|
@ -194,9 +181,6 @@ abstract class AppServerTest extends SmokeTest {
|
|||
and: "Number of spans tagged with expected OS type"
|
||||
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == traces.countSpans()
|
||||
|
||||
cleanup:
|
||||
response?.close()
|
||||
|
||||
where:
|
||||
[appServer, jdk, isWindows] << getTestParams()
|
||||
}
|
||||
|
|
@ -205,12 +189,10 @@ abstract class AppServerTest extends SmokeTest {
|
|||
def "#appServer test request for WEB-INF/web.xml on JDK #jdk"(String appServer, String jdk, boolean isWindows) {
|
||||
assumeTrue(testRequestWebInfWebXml())
|
||||
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/WEB-INF/web.xml"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/app/WEB-INF/web.xml").aggregate().join()
|
||||
TraceInspector traces = new TraceInspector(waitForTraces())
|
||||
Set<String> traceIds = traces.traceIds
|
||||
|
||||
|
|
@ -218,7 +200,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traceIds.size() == 1
|
||||
|
||||
and: "Response code is 404"
|
||||
response.code() == 404
|
||||
response.status().code() == 404
|
||||
|
||||
and: "There is one server span"
|
||||
traces.countSpansByKind(Span.SpanKind.SPAN_KIND_SERVER) == 1
|
||||
|
|
@ -227,7 +209,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traces.countSpansByName(getSpanName('/app/WEB-INF/web.xml')) == 1
|
||||
|
||||
and: "The span for the initial web request"
|
||||
traces.countFilteredAttributes("http.url", url) == 1
|
||||
traces.countFilteredAttributes("http.url", "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/WEB-INF/web.xml") == 1
|
||||
|
||||
and: "Number of spans with http protocol version"
|
||||
traces.countFilteredAttributes("http.flavor", "1.1") == 1
|
||||
|
|
@ -238,9 +220,6 @@ abstract class AppServerTest extends SmokeTest {
|
|||
and: "Number of spans tagged with expected OS type"
|
||||
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == traces.countSpans()
|
||||
|
||||
cleanup:
|
||||
response?.close()
|
||||
|
||||
where:
|
||||
[appServer, jdk, isWindows] << getTestParams()
|
||||
}
|
||||
|
|
@ -249,12 +228,10 @@ abstract class AppServerTest extends SmokeTest {
|
|||
def "#appServer test request with error JDK #jdk"(String appServer, String jdk, boolean isWindows) {
|
||||
assumeTrue(testException())
|
||||
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/exception"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/app/exception").aggregate().join()
|
||||
TraceInspector traces = new TraceInspector(waitForTraces())
|
||||
Set<String> traceIds = traces.traceIds
|
||||
|
||||
|
|
@ -262,7 +239,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traceIds.size() == 1
|
||||
|
||||
and: "Response code is 500"
|
||||
response.code() == 500
|
||||
response.status().code() == 500
|
||||
|
||||
and: "There is one server span"
|
||||
traces.countSpansByKind(Span.SpanKind.SPAN_KIND_SERVER) == 1
|
||||
|
|
@ -274,7 +251,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traces.countFilteredEventAttributes('exception.message', 'This is expected') == 1
|
||||
|
||||
and: "The span for the initial web request"
|
||||
traces.countFilteredAttributes("http.url", url) == 1
|
||||
traces.countFilteredAttributes("http.url", "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/exception") == 1
|
||||
|
||||
and: "Number of spans tagged with current otel library version"
|
||||
traces.countFilteredResourceAttributes("telemetry.auto.version", currentAgentVersion) == 1
|
||||
|
|
@ -282,21 +259,16 @@ abstract class AppServerTest extends SmokeTest {
|
|||
and: "Number of spans tagged with expected OS type"
|
||||
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == 1
|
||||
|
||||
cleanup:
|
||||
response?.close()
|
||||
|
||||
where:
|
||||
[appServer, jdk, isWindows] << getTestParams()
|
||||
}
|
||||
|
||||
@Unroll
|
||||
def "#appServer test request outside deployed application JDK #jdk"(String appServer, String jdk, boolean isWindows) {
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/this-is-definitely-not-there-but-there-should-be-a-trace-nevertheless"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/this-is-definitely-not-there-but-there-should-be-a-trace-nevertheless").aggregate().join()
|
||||
TraceInspector traces = new TraceInspector(waitForTraces())
|
||||
Set<String> traceIds = traces.traceIds
|
||||
|
||||
|
|
@ -304,7 +276,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traceIds.size() == 1
|
||||
|
||||
and: "Response code is 404"
|
||||
response.code() == 404
|
||||
response.status().code() == 404
|
||||
|
||||
and: "There is one server span"
|
||||
traces.countSpansByKind(Span.SpanKind.SPAN_KIND_SERVER) == 1
|
||||
|
|
@ -313,7 +285,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traces.countSpansByName(getSpanName('/this-is-definitely-not-there-but-there-should-be-a-trace-nevertheless')) == 1
|
||||
|
||||
and: "The span for the initial web request"
|
||||
traces.countFilteredAttributes("http.url", url) == 1
|
||||
traces.countFilteredAttributes("http.url", "http://localhost:${containerManager.getTargetMappedPort(8080)}/this-is-definitely-not-there-but-there-should-be-a-trace-nevertheless") == 1
|
||||
|
||||
and: "Number of spans with http protocol version"
|
||||
traces.countFilteredAttributes("http.flavor", "1.1") == 1
|
||||
|
|
@ -324,9 +296,6 @@ abstract class AppServerTest extends SmokeTest {
|
|||
and: "Number of spans tagged with expected OS type"
|
||||
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == traces.countSpans()
|
||||
|
||||
cleanup:
|
||||
response?.close()
|
||||
|
||||
where:
|
||||
[appServer, jdk, isWindows] << getTestParams()
|
||||
}
|
||||
|
|
@ -335,15 +304,13 @@ abstract class AppServerTest extends SmokeTest {
|
|||
def "#appServer async smoke test on JDK #jdk"(String appServer, String jdk, boolean isWindows) {
|
||||
assumeTrue(testAsyncSmoke())
|
||||
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/asyncgreeting"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/app/asyncgreeting").aggregate().join()
|
||||
TraceInspector traces = new TraceInspector(waitForTraces())
|
||||
Set<String> traceIds = traces.traceIds
|
||||
String responseBody = response.body().string()
|
||||
String responseBody = response.contentUtf8()
|
||||
|
||||
then: "There is one trace"
|
||||
traceIds.size() == 1
|
||||
|
|
@ -359,7 +326,7 @@ abstract class AppServerTest extends SmokeTest {
|
|||
traces.countSpansByName(getSpanName('/app/headers')) == 1
|
||||
|
||||
and: "The span for the initial web request"
|
||||
traces.countFilteredAttributes("http.url", url) == 1
|
||||
traces.countFilteredAttributes("http.url", "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/asyncgreeting") == 1
|
||||
|
||||
and: "Client and server spans for the remote call"
|
||||
traces.countFilteredAttributes("http.url", "http://localhost:8080/app/headers") == 2
|
||||
|
|
@ -373,9 +340,6 @@ abstract class AppServerTest extends SmokeTest {
|
|||
and: "Number of spans tagged with expected OS type"
|
||||
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == 3
|
||||
|
||||
cleanup:
|
||||
response?.close()
|
||||
|
||||
where:
|
||||
[appServer, jdk, isWindows] << getTestParams()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import static java.util.stream.Collectors.toSet
|
|||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
|
||||
import java.util.jar.Attributes
|
||||
import java.util.jar.JarFile
|
||||
import okhttp3.Request
|
||||
import spock.lang.IgnoreIf
|
||||
|
||||
@IgnoreIf({ os.windows })
|
||||
|
|
@ -32,17 +31,14 @@ class JaegerExporterSmokeTest extends SmokeTest {
|
|||
setup:
|
||||
startTarget(11)
|
||||
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/greeting"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/greeting").aggregate().join()
|
||||
Collection<ExportTraceServiceRequest> traces = waitForTraces()
|
||||
|
||||
then:
|
||||
response.body().string() == "Hi!"
|
||||
response.contentUtf8() == "Hi!"
|
||||
countSpansByName(traces, '/greeting') == 1
|
||||
countSpansByName(traces, 'WebController.greeting') == 1
|
||||
countSpansByName(traces, 'WebController.withSpan') == 1
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
package io.opentelemetry.smoketest
|
||||
|
||||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
|
||||
import okhttp3.Request
|
||||
import spock.lang.IgnoreIf
|
||||
|
||||
@IgnoreIf({ os.windows })
|
||||
|
|
@ -19,15 +18,12 @@ class PlaySmokeTest extends SmokeTest {
|
|||
def "play smoke test on JDK #jdk"(int jdk) {
|
||||
setup:
|
||||
startTarget(jdk)
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/welcome?id=1"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/welcome?id=1").aggregate().join()
|
||||
Collection<ExportTraceServiceRequest> traces = waitForTraces()
|
||||
|
||||
then:
|
||||
response.body().string() == "Welcome 1."
|
||||
response.contentUtf8() == "Welcome 1."
|
||||
//Both play and akka-http support produce spans with the same name.
|
||||
//One internal, one SERVER
|
||||
countSpansByName(traces, '/welcome') == 2
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import static java.util.stream.Collectors.toSet
|
|||
|
||||
import io.opentelemetry.api.trace.TraceId
|
||||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
|
||||
import okhttp3.Request
|
||||
import spock.lang.IgnoreIf
|
||||
|
||||
abstract class PropagationTest extends SmokeTest {
|
||||
|
|
@ -22,11 +21,8 @@ abstract class PropagationTest extends SmokeTest {
|
|||
def "Should propagate test"() {
|
||||
setup:
|
||||
startTarget(11)
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/front"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/front").aggregate().join()
|
||||
Collection<ExportTraceServiceRequest> traces = waitForTraces()
|
||||
def traceIds = getSpanStream(traces)
|
||||
.map({ TraceId.fromBytes(it.getTraceId().toByteArray()) })
|
||||
|
|
@ -37,7 +33,7 @@ abstract class PropagationTest extends SmokeTest {
|
|||
|
||||
def traceId = traceIds.first()
|
||||
|
||||
response.body().string() == "${traceId};${traceId}"
|
||||
response.contentUtf8() == "${traceId};${traceId}"
|
||||
|
||||
cleanup:
|
||||
stopTarget()
|
||||
|
|
@ -94,11 +90,8 @@ class OtTracePropagationTest extends SmokeTest {
|
|||
def "Should propagate test"() {
|
||||
setup:
|
||||
startTarget(11)
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/front"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/front").aggregate().join()
|
||||
Collection<ExportTraceServiceRequest> traces = waitForTraces()
|
||||
def traceIds = getSpanStream(traces)
|
||||
.map({ TraceId.fromBytes(it.getTraceId().toByteArray()).substring(16) })
|
||||
|
|
@ -109,7 +102,7 @@ class OtTracePropagationTest extends SmokeTest {
|
|||
|
||||
def traceId = traceIds.first()
|
||||
|
||||
response.body().string().matches(/[0-9a-f]{16}${traceId};[0]{16}${traceId}/)
|
||||
response.contentUtf8().matches(/[0-9a-f]{16}${traceId};[0]{16}${traceId}/)
|
||||
|
||||
cleanup:
|
||||
stopTarget()
|
||||
|
|
|
|||
|
|
@ -7,15 +7,14 @@ package io.opentelemetry.smoketest
|
|||
|
||||
import static java.util.stream.Collectors.toSet
|
||||
|
||||
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
|
||||
import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest
|
||||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
|
||||
import io.opentelemetry.proto.common.v1.AnyValue
|
||||
import io.opentelemetry.proto.trace.v1.Span
|
||||
import io.opentelemetry.smoketest.windows.WindowsTestContainerManager
|
||||
import io.opentelemetry.testing.armeria.client.WebClient
|
||||
import java.util.regex.Pattern
|
||||
import java.util.stream.Stream
|
||||
import okhttp3.OkHttpClient
|
||||
import org.testcontainers.containers.output.ToStringConsumer
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
|
@ -23,8 +22,6 @@ import spock.lang.Specification
|
|||
abstract class SmokeTest extends Specification {
|
||||
private static final Pattern TRACE_ID_PATTERN = Pattern.compile(".*trace_id=(?<traceId>[a-zA-Z0-9]+).*")
|
||||
|
||||
protected static final OkHttpClient CLIENT = OkHttpUtils.client()
|
||||
|
||||
protected static final TestContainerManager containerManager = createContainerManager()
|
||||
|
||||
@Shared
|
||||
|
|
@ -33,6 +30,10 @@ abstract class SmokeTest extends Specification {
|
|||
@Shared
|
||||
protected String agentPath = System.getProperty("io.opentelemetry.smoketest.agent.shadowJar.path")
|
||||
|
||||
protected WebClient client() {
|
||||
return WebClient.of("h1c://localhost:${containerManager.getTargetMappedPort(8080)}")
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses can override this method to pass jvm arguments in another environment variable
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import io.opentelemetry.api.trace.TraceId
|
|||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
|
||||
import java.util.jar.Attributes
|
||||
import java.util.jar.JarFile
|
||||
import okhttp3.Request
|
||||
import spock.lang.IgnoreIf
|
||||
import spock.lang.Unroll
|
||||
|
||||
|
|
@ -26,17 +25,14 @@ class SpringBootSmokeTest extends SmokeTest {
|
|||
def "spring boot smoke test on JDK #jdk"(int jdk) {
|
||||
setup:
|
||||
def output = startTarget(jdk)
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/greeting"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION).toString()
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/greeting").aggregate().join()
|
||||
Collection<ExportTraceServiceRequest> traces = waitForTraces()
|
||||
|
||||
then: "spans are exported"
|
||||
response.body().string() == "Hi!"
|
||||
response.contentUtf8() == "Hi!"
|
||||
countSpansByName(traces, '/greeting') == 1
|
||||
countSpansByName(traces, 'WebController.greeting') == 1
|
||||
countSpansByName(traces, 'WebController.withSpan') == 1
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
package io.opentelemetry.smoketest
|
||||
|
||||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
|
||||
import okhttp3.Request
|
||||
import spock.lang.IgnoreIf
|
||||
|
||||
@IgnoreIf({ os.windows })
|
||||
|
|
@ -31,12 +30,9 @@ class SpringBootWithSamplingSmokeTest extends SmokeTest {
|
|||
def "spring boot with probability sampling enabled on JDK #jdk"(int jdk) {
|
||||
setup:
|
||||
startTarget(jdk)
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/greeting"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
for (int i = 1; i <= NUM_TRIES; i++) {
|
||||
CLIENT.newCall(request).execute().close()
|
||||
client().get("/greeting").aggregate().join()
|
||||
}
|
||||
Collection<ExportTraceServiceRequest> traces = waitForTraces()
|
||||
|
||||
|
|
|
|||
|
|
@ -8,30 +8,24 @@ package io.opentelemetry.smoketest
|
|||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import com.google.protobuf.GeneratedMessageV3
|
||||
import com.google.protobuf.util.JsonFormat
|
||||
import io.opentelemetry.instrumentation.test.utils.OkHttpUtils
|
||||
import io.opentelemetry.proto.collector.metrics.v1.ExportMetricsServiceRequest
|
||||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
|
||||
import io.opentelemetry.testing.armeria.client.WebClient
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.function.Supplier
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
|
||||
class TelemetryRetriever {
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
|
||||
protected static final OkHttpClient CLIENT = OkHttpUtils.client()
|
||||
|
||||
final int backendPort
|
||||
|
||||
final WebClient client
|
||||
|
||||
TelemetryRetriever(int backendPort) {
|
||||
this.backendPort = backendPort
|
||||
client = WebClient.of("http://localhost:${backendPort}")
|
||||
}
|
||||
|
||||
void clearTelemetry() {
|
||||
CLIENT.newCall(new Request.Builder()
|
||||
.url("http://localhost:${backendPort}/clear")
|
||||
.build())
|
||||
.execute()
|
||||
.close()
|
||||
client.get("/clear").aggregate().join()
|
||||
}
|
||||
|
||||
Collection<ExportTraceServiceRequest> waitForTraces() {
|
||||
|
|
@ -58,16 +52,7 @@ class TelemetryRetriever {
|
|||
long deadline = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(30)
|
||||
String content = "[]"
|
||||
while (System.currentTimeMillis() < deadline) {
|
||||
def body = content = CLIENT.newCall(new Request.Builder()
|
||||
.url("http://localhost:${backendPort}/${path}")
|
||||
.build())
|
||||
.execute()
|
||||
.body()
|
||||
try {
|
||||
content = body.string()
|
||||
} finally {
|
||||
body.close()
|
||||
}
|
||||
content = client.get(path).aggregate().join().contentUtf8()
|
||||
if (content.length() > 2 && content.length() == previousSize) {
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
package io.opentelemetry.smoketest;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import groovy.lang.GString;
|
||||
import io.opentelemetry.api.trace.TraceId;
|
||||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
|
||||
import io.opentelemetry.proto.common.v1.AnyValue;
|
||||
|
|
@ -51,11 +52,17 @@ public class TraceInspector {
|
|||
}
|
||||
|
||||
public long countFilteredAttributes(String attributeName, Object attributeValue) {
|
||||
final Object value;
|
||||
if (attributeValue instanceof GString) {
|
||||
value = attributeValue.toString();
|
||||
} else {
|
||||
value = attributeValue;
|
||||
}
|
||||
return getSpanStream()
|
||||
.flatMap(s -> s.getAttributesList().stream())
|
||||
.filter(a -> a.getKey().equals(attributeName))
|
||||
.map(a -> a.getValue().getStringValue())
|
||||
.filter(s -> s.equals(attributeValue))
|
||||
.filter(s -> s.equals(value))
|
||||
.count();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
package io.opentelemetry.smoketest
|
||||
|
||||
import io.opentelemetry.proto.trace.v1.Span
|
||||
import okhttp3.Request
|
||||
import spock.lang.Unroll
|
||||
|
||||
@AppServer(version = "13.0.0.Final", jdk = "8")
|
||||
|
|
@ -23,16 +22,13 @@ class WildflySmokeTest extends AppServerTest {
|
|||
|
||||
@Unroll
|
||||
def "JSP smoke test on WildFly"() {
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/app/jsp"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/app/jsp").aggregate().join()
|
||||
TraceInspector traces = new TraceInspector(waitForTraces())
|
||||
String responseBody = response.body().string()
|
||||
String responseBody = response.contentUtf8()
|
||||
|
||||
then:
|
||||
response.successful
|
||||
response.status().isSuccess()
|
||||
responseBody.contains("Successful JSP test")
|
||||
|
||||
traces.countSpansByKind(Span.SpanKind.SPAN_KIND_SERVER) == 1
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
package io.opentelemetry.smoketest
|
||||
|
||||
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest
|
||||
import okhttp3.Request
|
||||
import spock.lang.IgnoreIf
|
||||
|
||||
@IgnoreIf({ os.windows })
|
||||
|
|
@ -28,17 +27,14 @@ class ZipkinExporterSmokeTest extends SmokeTest {
|
|||
setup:
|
||||
startTarget(11)
|
||||
|
||||
String url = "http://localhost:${containerManager.getTargetMappedPort(8080)}/greeting"
|
||||
def request = new Request.Builder().url(url).get().build()
|
||||
|
||||
// def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
// def currentAgentVersion = new JarFile(agentPath).getManifest().getMainAttributes().get(Attributes.Name.IMPLEMENTATION_VERSION)
|
||||
|
||||
when:
|
||||
def response = CLIENT.newCall(request).execute()
|
||||
def response = client().get("/greeting").aggregate().join()
|
||||
Collection<ExportTraceServiceRequest> traces = waitForTraces()
|
||||
|
||||
then:
|
||||
response.body().string() == "Hi!"
|
||||
response.contentUtf8() == "Hi!"
|
||||
countSpansByName(traces, '/greeting') == 1
|
||||
countSpansByName(traces, 'webcontroller.greeting') == 1
|
||||
countSpansByName(traces, 'webcontroller.withspan') == 1
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ import com.github.dockerjava.core.DockerClientImpl;
|
|||
import com.github.dockerjava.httpclient5.ApacheDockerHttpClient;
|
||||
import io.opentelemetry.smoketest.AbstractTestContainerManager;
|
||||
import io.opentelemetry.smoketest.TargetWaitStrategy;
|
||||
import io.opentelemetry.testing.armeria.client.WebClient;
|
||||
import io.opentelemetry.testing.armeria.common.AggregatedHttpResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
|
|
@ -35,9 +37,6 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
|
@ -410,8 +409,8 @@ public class WindowsTestContainerManager extends AbstractTestContainerManager {
|
|||
}
|
||||
|
||||
private static class HttpWaiter implements Waiter {
|
||||
private static final OkHttpClient CLIENT =
|
||||
new OkHttpClient.Builder().callTimeout(Duration.ofSeconds(1)).build();
|
||||
private static final WebClient CLIENT =
|
||||
WebClient.builder().responseTimeout(Duration.ofSeconds(1)).build();
|
||||
|
||||
private final int internalPort;
|
||||
private final String path;
|
||||
|
|
@ -430,16 +429,10 @@ public class WindowsTestContainerManager extends AbstractTestContainerManager {
|
|||
|
||||
@Override
|
||||
public void waitFor(Container container) {
|
||||
Request request =
|
||||
new Request.Builder()
|
||||
.url("http://localhost:" + extractMappedPort(container, internalPort) + path)
|
||||
.build();
|
||||
String url = "http://localhost:" + extractMappedPort(container, internalPort) + path;
|
||||
|
||||
logger.info(
|
||||
"Waiting for container {}/{} on url {}",
|
||||
container.imageName,
|
||||
container.containerId,
|
||||
request.url());
|
||||
"Waiting for container {}/{} on url {}", container.imageName, container.containerId, url);
|
||||
|
||||
try {
|
||||
Unreliables.retryUntilSuccess(
|
||||
|
|
@ -448,15 +441,11 @@ public class WindowsTestContainerManager extends AbstractTestContainerManager {
|
|||
() -> {
|
||||
rateLimiter.doWhenReady(
|
||||
() -> {
|
||||
try {
|
||||
Response response = CLIENT.newCall(request).execute();
|
||||
AggregatedHttpResponse response = CLIENT.get(url).aggregate().join();
|
||||
|
||||
if (response.code() != 200) {
|
||||
throw new IllegalStateException(
|
||||
"Received status code " + response.code() + " from " + request.url());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
if (response.status().code() != 200) {
|
||||
throw new IllegalStateException(
|
||||
"Received status code " + response.status().code() + " from " + url);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.instrumentation.test.utils;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import okhttp3.logging.HttpLoggingInterceptor.Level;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class OkHttpUtils {
|
||||
|
||||
private static final Logger CLIENT_LOGGER = LoggerFactory.getLogger("http-client");
|
||||
|
||||
static {
|
||||
LoggerUtils.setLevel(CLIENT_LOGGER, ch.qos.logback.classic.Level.DEBUG);
|
||||
}
|
||||
|
||||
private static final HttpLoggingInterceptor LOGGING_INTERCEPTOR =
|
||||
new HttpLoggingInterceptor(
|
||||
new HttpLoggingInterceptor.Logger() {
|
||||
@Override
|
||||
public void log(String message) {
|
||||
CLIENT_LOGGER.debug(message);
|
||||
}
|
||||
});
|
||||
|
||||
static {
|
||||
LOGGING_INTERCEPTOR.setLevel(Level.BASIC);
|
||||
}
|
||||
|
||||
static OkHttpClient.Builder clientBuilder() {
|
||||
TimeUnit unit = TimeUnit.MINUTES;
|
||||
return new OkHttpClient.Builder()
|
||||
.addInterceptor(LOGGING_INTERCEPTOR)
|
||||
.connectTimeout(1, unit)
|
||||
.writeTimeout(1, unit)
|
||||
.readTimeout(1, unit);
|
||||
}
|
||||
|
||||
public static OkHttpClient client() {
|
||||
return client(false);
|
||||
}
|
||||
|
||||
public static OkHttpClient client(boolean followRedirects) {
|
||||
return clientBuilder().followRedirects(followRedirects).build();
|
||||
}
|
||||
|
||||
private OkHttpUtils() {}
|
||||
}
|
||||
|
|
@ -70,7 +70,6 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class AgentTestingExporterAccess {
|
||||
private static final char TRACESTATE_KEY_VALUE_DELIMITER = '=';
|
||||
|
|
@ -262,7 +261,6 @@ public final class AgentTestingExporterAccess {
|
|||
return metrics;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static MetricData createMetricData(
|
||||
Metric metric,
|
||||
io.opentelemetry.sdk.resources.Resource resource,
|
||||
|
|
|
|||
|
|
@ -33,12 +33,6 @@ dependencies {
|
|||
implementation "io.opentelemetry:opentelemetry-exporter-logging"
|
||||
implementation project(':instrumentation-api')
|
||||
|
||||
api "com.squareup.okhttp3:okhttp:4.9.0"
|
||||
api "com.squareup.okhttp3:logging-interceptor:4.9.0"
|
||||
|
||||
//TODO replace with Servlet API?
|
||||
implementation "org.eclipse.jetty:jetty-server:8.0.0.v20110901"
|
||||
|
||||
annotationProcessor "com.google.auto.service:auto-service"
|
||||
compileOnly "com.google.auto.service:auto-service"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue