diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerApplicationTest.groovy b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerApplicationTest.groovy index 280fb8977b3c..8d696fdcc928 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerApplicationTest.groovy +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerApplicationTest.groovy @@ -39,51 +39,57 @@ class RatpackServerApplicationTest extends Specification { def "add span on handlers"() { expect: - app.test { httpClient -> "hi-foo" == httpClient.get("foo").body.text } - - new PollingConditions().eventually { - def spanData = app.spanExporter.finishedSpanItems.find { it.name == "GET /foo" } - def attributes = spanData.attributes.asMap() - - spanData.kind == SpanKind.SERVER - attributes[HTTP_ROUTE] == "/foo" - attributes[HTTP_TARGET] == "/foo" - attributes[HTTP_METHOD] == "GET" - attributes[HTTP_STATUS_CODE] == 200L + app.test { httpClient -> + assert "hi-foo" == httpClient.get("foo").body.text + + new PollingConditions().eventually { + def spanData = app.spanExporter.finishedSpanItems.find { it.name == "GET /foo" } + def attributes = spanData.attributes.asMap() + + spanData.kind == SpanKind.SERVER + attributes[HTTP_ROUTE] == "/foo" + attributes[HTTP_TARGET] == "/foo" + attributes[HTTP_METHOD] == "GET" + attributes[HTTP_STATUS_CODE] == 200L + } } } def "propagate trace to http calls"() { expect: - app.test { httpClient -> "hi-bar" == httpClient.get("bar").body.text } - - new PollingConditions().eventually { - def spanData = app.spanExporter.finishedSpanItems.find { it.name == "GET /bar" } - def spanDataClient = app.spanExporter.finishedSpanItems.find { it.name == "GET" } - def attributes = spanData.attributes.asMap() - - spanData.traceId == spanDataClient.traceId - - spanData.kind == SpanKind.SERVER - attributes[HTTP_ROUTE] == "/bar" - attributes[HTTP_TARGET] == "/bar" - attributes[HTTP_METHOD] == "GET" - attributes[HTTP_STATUS_CODE] == 200L - - spanDataClient.kind == SpanKind.CLIENT - def attributesClient = spanDataClient.attributes.asMap() - attributesClient[HTTP_ROUTE] == "/other" - attributesClient[HTTP_METHOD] == "GET" - attributesClient[HTTP_STATUS_CODE] == 200L + app.test { httpClient -> + assert "hi-bar" == httpClient.get("bar").body.text + + new PollingConditions().eventually { + def spanData = app.spanExporter.finishedSpanItems.find { it.name == "GET /bar" } + def spanDataClient = app.spanExporter.finishedSpanItems.find { it.name == "GET" } + def attributes = spanData.attributes.asMap() + + spanData.traceId == spanDataClient.traceId + + spanData.kind == SpanKind.SERVER + attributes[HTTP_ROUTE] == "/bar" + attributes[HTTP_TARGET] == "/bar" + attributes[HTTP_METHOD] == "GET" + attributes[HTTP_STATUS_CODE] == 200L + + spanDataClient.kind == SpanKind.CLIENT + def attributesClient = spanDataClient.attributes.asMap() + attributesClient[HTTP_ROUTE] == "/other" + attributesClient[HTTP_METHOD] == "GET" + attributesClient[HTTP_STATUS_CODE] == 200L + } } } def "ignore handlers before OpenTelemetryServerHandler"() { expect: - app.test { httpClient -> "ignored" == httpClient.get("ignore").body.text } + app.test { httpClient -> + assert "ignored" == httpClient.get("ignore").body.text - new PollingConditions(initialDelay: 0.1, timeout: 0.3).eventually { - !app.spanExporter.finishedSpanItems.any { it.name == "GET /ignore" } + new PollingConditions(initialDelay: 0.1, timeout: 0.3).eventually { + !app.spanExporter.finishedSpanItems.any { it.name == "GET /ignore" } + } } } } diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerTest.groovy b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerTest.groovy index 1ca8c5f3fbb2..bea98619c0ef 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerTest.groovy +++ b/instrumentation/ratpack/ratpack-1.7/library/src/test/groovy/io/opentelemetry/instrumentation/ratpack/v1_7/server/RatpackServerTest.groovy @@ -46,19 +46,20 @@ class RatpackServerTest extends Specification { } } - when: - app.test { httpClient -> "hi-foo" == httpClient.get("foo").body.text } - - then: - new PollingConditions().eventually { - def spanData = spanExporter.finishedSpanItems.find { it.name == "GET /foo" } - def attributes = spanData.attributes.asMap() - - spanData.kind == SpanKind.SERVER - attributes[SemanticAttributes.HTTP_ROUTE] == "/foo" - attributes[SemanticAttributes.HTTP_TARGET] == "/foo" - attributes[SemanticAttributes.HTTP_METHOD] == "GET" - attributes[SemanticAttributes.HTTP_STATUS_CODE] == 200L + expect: + app.test { httpClient -> + assert "hi-foo" == httpClient.get("foo").body.text + + new PollingConditions().eventually { + def spanData = spanExporter.finishedSpanItems.find { it.name == "GET /foo" } + def attributes = spanData.attributes.asMap() + + spanData.kind == SpanKind.SERVER + attributes[SemanticAttributes.HTTP_ROUTE] == "/foo" + attributes[SemanticAttributes.HTTP_TARGET] == "/foo" + attributes[SemanticAttributes.HTTP_METHOD] == "GET" + attributes[SemanticAttributes.HTTP_STATUS_CODE] == 200L + } } } @@ -81,7 +82,7 @@ class RatpackServerTest extends Specification { } app.test { httpClient -> - "hi-foo" == httpClient.get("foo").body.text + assert "hi-foo" == httpClient.get("foo").body.text new PollingConditions().eventually { def spanData = spanExporter.finishedSpanItems.find { it.name == "GET /foo" } @@ -130,8 +131,9 @@ class RatpackServerTest extends Specification { } app.test { httpClient -> - "hi-foo" == httpClient.get("foo").body.text - "hi-bar" == httpClient.get("bar").body.text + assert "hi-foo" == httpClient.get("foo").body.text + assert "hi-bar" == httpClient.get("bar").body.text + new PollingConditions().eventually { def spanData = spanExporter.finishedSpanItems.find { it.name == "GET /foo" } def spanDataChild = spanExporter.finishedSpanItems.find { it.name == "a-span" }