From c46221e50608e799c2d791500927026205335510 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 23 Apr 2021 11:20:36 -0700 Subject: [PATCH] Fix grails latest dep test (#2857) --- .../src/test/groovy/test/ErrorController.groovy | 5 +++++ .../src/test/groovy/test/GrailsTest.groovy | 15 ++++++++++++++- .../src/test/groovy/test/UrlMappings.groovy | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/instrumentation/grails-3.0/javaagent/src/test/groovy/test/ErrorController.groovy b/instrumentation/grails-3.0/javaagent/src/test/groovy/test/ErrorController.groovy index 2f8137cd4c..6ca586eb40 100644 --- a/instrumentation/grails-3.0/javaagent/src/test/groovy/test/ErrorController.groovy +++ b/instrumentation/grails-3.0/javaagent/src/test/groovy/test/ErrorController.groovy @@ -16,4 +16,9 @@ class ErrorController implements Controller { def index() { render ERROR.body } + + @Action + def notFound() { + response.sendError(404, "Not Found") + } } diff --git a/instrumentation/grails-3.0/javaagent/src/test/groovy/test/GrailsTest.groovy b/instrumentation/grails-3.0/javaagent/src/test/groovy/test/GrailsTest.groovy index b7916d1d90..c4290d0e60 100644 --- a/instrumentation/grails-3.0/javaagent/src/test/groovy/test/GrailsTest.groovy +++ b/instrumentation/grails-3.0/javaagent/src/test/groovy/test/GrailsTest.groovy @@ -101,6 +101,11 @@ class GrailsTest extends HttpServerTest implemen endpoint == ERROR || endpoint == EXCEPTION || endpoint == NOT_FOUND } + @Override + int getErrorPageSpansCount(ServerEndpoint endpoint) { + endpoint == NOT_FOUND ? 2 : 1 + } + @Override boolean testPathParam() { true @@ -109,11 +114,19 @@ class GrailsTest extends HttpServerTest implemen @Override void errorPageSpans(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint) { trace.span(index) { - name endpoint == NOT_FOUND ? "BasicErrorController.error" : "ErrorController.index" + name endpoint == NOT_FOUND ? "ErrorController.notFound" : "ErrorController.index" kind INTERNAL attributes { } } + if (endpoint == NOT_FOUND) { + trace.span(index + 1) { + name ~/\.sendError$/ + kind INTERNAL + attributes { + } + } + } } @Override diff --git a/instrumentation/grails-3.0/javaagent/src/test/groovy/test/UrlMappings.groovy b/instrumentation/grails-3.0/javaagent/src/test/groovy/test/UrlMappings.groovy index bb65ff069c..7e79a7d455 100644 --- a/instrumentation/grails-3.0/javaagent/src/test/groovy/test/UrlMappings.groovy +++ b/instrumentation/grails-3.0/javaagent/src/test/groovy/test/UrlMappings.groovy @@ -16,5 +16,6 @@ class UrlMappings { "/path/$id/param"(controller: 'test', action: 'path') "500"(controller: 'error') + "404"(controller: 'error', action: 'notFound') } }