From bd470ce080153c474fde9fb5d559bcdc56589f48 Mon Sep 17 00:00:00 2001 From: Tommy Ludwig <8924140+shakuzen@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:48:07 +0900 Subject: [PATCH] HTTP server instrumentation TCK (#3379) Similar to the HTTP client instrumentation tests, these tests ensure HTTP server instrumentation produces the expected tags in a minimal set of scenarios that should be supported by all HTTP server instrumentation. --- config/checkstyle/checkstyle-suppressions.xml | 1 + dependencies.gradle | 1 + .../gradle.lockfile | 2 + .../micrometer-registry-atlas/gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../micrometer-registry-humio/gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../micrometer-registry-jmx/gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + micrometer-jersey2/gradle.lockfile | 2 + micrometer-test/build.gradle | 7 + micrometer-test/gradle.lockfile | 31 ++++ ...imingInstrumentationVerificationTests.java | 157 ++++++++++++++++++ ...imingInstrumentationVerificationTests.java | 89 ++++++++++ ...imingInstrumentationVerificationTests.java | 87 ++++++++++ .../gradle.lockfile | 2 + .../gradle.lockfile | 2 + 31 files changed, 421 insertions(+) create mode 100644 micrometer-test/src/main/java/io/micrometer/core/instrument/HttpServerTimingInstrumentationVerificationTests.java create mode 100644 micrometer-test/src/test/java/io/micrometer/core/instrument/JerseyServerTimingInstrumentationVerificationTests.java create mode 100644 micrometer-test/src/test/java/io/micrometer/core/instrument/JettyServerTimingInstrumentationVerificationTests.java diff --git a/config/checkstyle/checkstyle-suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml index abb7a4ca38..78defbd99c 100644 --- a/config/checkstyle/checkstyle-suppressions.xml +++ b/config/checkstyle/checkstyle-suppressions.xml @@ -8,6 +8,7 @@ <suppress checks="IllegalImport" files="samples[\\/].+" /> <suppress checks="IllegalImport" files="test[\\/]java[\\/]io[\\/]micrometer[\\/]core[\\/]instrument[\\/]binder[\\/]jersey[\\/]server.+" /> <suppress checks="IllegalImport" files="test[\\/]java[\\/]io[\\/]micrometer[\\/]jersey.+" /> + <suppress checks="IllegalImport" files="test[\\/]java[\\/]io[\\/]micrometer[\\/]core[\\/]instrument.+Tests.java" /> <suppress checks="JavadocPackageCheck" files="benchmarks[\\/].+" /> <suppress checks="JavadocPackageCheck" files="samples[\\/].+" /> diff --git a/dependencies.gradle b/dependencies.gradle index 41b6881933..ebd96553f7 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -53,6 +53,7 @@ def VERSIONS = [ 'org.awaitility:awaitility:latest.release', 'org.eclipse.jetty:jetty-client:9.+', 'org.eclipse.jetty:jetty-server:9.+', + 'org.eclipse.jetty:jetty-servlet:9.+', 'org.ehcache:ehcache:latest.release', 'org.glassfish.jersey.core:jersey-server:2.+', 'org.glassfish.jersey.inject:jersey-hk2:2.+', diff --git a/implementations/micrometer-registry-appoptics/gradle.lockfile b/implementations/micrometer-registry-appoptics/gradle.lockfile index 276f73c6fd..c224d33112 100644 --- a/implementations/micrometer-registry-appoptics/gradle.lockfile +++ b/implementations/micrometer-registry-appoptics/gradle.lockfile @@ -35,8 +35,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-atlas/gradle.lockfile b/implementations/micrometer-registry-atlas/gradle.lockfile index d29a16ba4d..9bab0cab67 100644 --- a/implementations/micrometer-registry-atlas/gradle.lockfile +++ b/implementations/micrometer-registry-atlas/gradle.lockfile @@ -39,8 +39,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-azure-monitor/gradle.lockfile b/implementations/micrometer-registry-azure-monitor/gradle.lockfile index af5d3377bc..9e9d502164 100644 --- a/implementations/micrometer-registry-azure-monitor/gradle.lockfile +++ b/implementations/micrometer-registry-azure-monitor/gradle.lockfile @@ -38,8 +38,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-cloudwatch/gradle.lockfile b/implementations/micrometer-registry-cloudwatch/gradle.lockfile index c28a1081c3..4fca05b415 100644 --- a/implementations/micrometer-registry-cloudwatch/gradle.lockfile +++ b/implementations/micrometer-registry-cloudwatch/gradle.lockfile @@ -47,8 +47,10 @@ org.apache.httpcomponents:httpclient:4.5.13=compileClasspath,default,runtimeClas org.apache.httpcomponents:httpcore:4.4.13=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-cloudwatch2/gradle.lockfile b/implementations/micrometer-registry-cloudwatch2/gradle.lockfile index f524b13039..301d021106 100644 --- a/implementations/micrometer-registry-cloudwatch2/gradle.lockfile +++ b/implementations/micrometer-registry-cloudwatch2/gradle.lockfile @@ -48,8 +48,10 @@ org.apache.httpcomponents:httpclient:4.5.13=default,runtimeClasspath,testRuntime org.apache.httpcomponents:httpcore:4.4.13=default,runtimeClasspath,testRuntimeClasspath org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-datadog/gradle.lockfile b/implementations/micrometer-registry-datadog/gradle.lockfile index 276f73c6fd..c224d33112 100644 --- a/implementations/micrometer-registry-datadog/gradle.lockfile +++ b/implementations/micrometer-registry-datadog/gradle.lockfile @@ -35,8 +35,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-dynatrace/gradle.lockfile b/implementations/micrometer-registry-dynatrace/gradle.lockfile index f0591c2086..301867b671 100644 --- a/implementations/micrometer-registry-dynatrace/gradle.lockfile +++ b/implementations/micrometer-registry-dynatrace/gradle.lockfile @@ -40,8 +40,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-elastic/gradle.lockfile b/implementations/micrometer-registry-elastic/gradle.lockfile index 27ac5fa808..e6168c1ae7 100644 --- a/implementations/micrometer-registry-elastic/gradle.lockfile +++ b/implementations/micrometer-registry-elastic/gradle.lockfile @@ -47,9 +47,11 @@ org.antlr:antlr4-runtime:4.9.2=checkstyle org.apache.commons:commons-compress:1.21=testCompileClasspath,testRuntimeClasspath org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.jetbrains:annotations:17.0.0=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-ganglia/gradle.lockfile b/implementations/micrometer-registry-ganglia/gradle.lockfile index bc0e038e82..e3965b93bf 100644 --- a/implementations/micrometer-registry-ganglia/gradle.lockfile +++ b/implementations/micrometer-registry-ganglia/gradle.lockfile @@ -38,8 +38,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-graphite/gradle.lockfile b/implementations/micrometer-registry-graphite/gradle.lockfile index fd82c683dc..fd58493b19 100644 --- a/implementations/micrometer-registry-graphite/gradle.lockfile +++ b/implementations/micrometer-registry-graphite/gradle.lockfile @@ -56,8 +56,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-health/gradle.lockfile b/implementations/micrometer-registry-health/gradle.lockfile index 276f73c6fd..c224d33112 100644 --- a/implementations/micrometer-registry-health/gradle.lockfile +++ b/implementations/micrometer-registry-health/gradle.lockfile @@ -35,8 +35,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-humio/gradle.lockfile b/implementations/micrometer-registry-humio/gradle.lockfile index 276f73c6fd..c224d33112 100644 --- a/implementations/micrometer-registry-humio/gradle.lockfile +++ b/implementations/micrometer-registry-humio/gradle.lockfile @@ -35,8 +35,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-influx/gradle.lockfile b/implementations/micrometer-registry-influx/gradle.lockfile index 276f73c6fd..c224d33112 100644 --- a/implementations/micrometer-registry-influx/gradle.lockfile +++ b/implementations/micrometer-registry-influx/gradle.lockfile @@ -35,8 +35,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-jmx/gradle.lockfile b/implementations/micrometer-registry-jmx/gradle.lockfile index b02773c197..1b832d1176 100644 --- a/implementations/micrometer-registry-jmx/gradle.lockfile +++ b/implementations/micrometer-registry-jmx/gradle.lockfile @@ -39,8 +39,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-kairos/gradle.lockfile b/implementations/micrometer-registry-kairos/gradle.lockfile index 276f73c6fd..c224d33112 100644 --- a/implementations/micrometer-registry-kairos/gradle.lockfile +++ b/implementations/micrometer-registry-kairos/gradle.lockfile @@ -35,8 +35,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-new-relic/gradle.lockfile b/implementations/micrometer-registry-new-relic/gradle.lockfile index d2a7901bdc..84a3f47b18 100644 --- a/implementations/micrometer-registry-new-relic/gradle.lockfile +++ b/implementations/micrometer-registry-new-relic/gradle.lockfile @@ -36,8 +36,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-opentsdb/gradle.lockfile b/implementations/micrometer-registry-opentsdb/gradle.lockfile index 276f73c6fd..c224d33112 100644 --- a/implementations/micrometer-registry-opentsdb/gradle.lockfile +++ b/implementations/micrometer-registry-opentsdb/gradle.lockfile @@ -35,8 +35,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-prometheus/gradle.lockfile b/implementations/micrometer-registry-prometheus/gradle.lockfile index ea723ff417..26b5ef9f16 100644 --- a/implementations/micrometer-registry-prometheus/gradle.lockfile +++ b/implementations/micrometer-registry-prometheus/gradle.lockfile @@ -40,8 +40,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-signalfx/gradle.lockfile b/implementations/micrometer-registry-signalfx/gradle.lockfile index 5363b249dc..8578d50842 100644 --- a/implementations/micrometer-registry-signalfx/gradle.lockfile +++ b/implementations/micrometer-registry-signalfx/gradle.lockfile @@ -36,8 +36,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-stackdriver/gradle.lockfile b/implementations/micrometer-registry-stackdriver/gradle.lockfile index a68b6ecb2a..a19ff9465c 100644 --- a/implementations/micrometer-registry-stackdriver/gradle.lockfile +++ b/implementations/micrometer-registry-stackdriver/gradle.lockfile @@ -70,10 +70,12 @@ org.apache.httpcomponents:httpclient:4.5.13=compileClasspath,default,runtimeClas org.apache.httpcomponents:httpcore:4.4.14=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle,compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.codehaus.mojo:animal-sniffer-annotations:1.20=default,runtimeClasspath,testRuntimeClasspath org.conscrypt:conscrypt-openjdk-uber:2.5.1=default,runtimeClasspath,testRuntimeClasspath +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/implementations/micrometer-registry-wavefront/gradle.lockfile b/implementations/micrometer-registry-wavefront/gradle.lockfile index cfd35369ea..8233dac6fa 100644 --- a/implementations/micrometer-registry-wavefront/gradle.lockfile +++ b/implementations/micrometer-registry-wavefront/gradle.lockfile @@ -41,8 +41,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle,compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/micrometer-jersey2/gradle.lockfile b/micrometer-jersey2/gradle.lockfile index 24e3400d70..648a6a9d7a 100644 --- a/micrometer-jersey2/gradle.lockfile +++ b/micrometer-jersey2/gradle.lockfile @@ -44,6 +44,7 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle org.glassfish.hk2.external:aopalliance-repackaged:2.6.1=testRuntimeClasspath @@ -61,6 +62,7 @@ org.glassfish.jersey.media:jersey-media-jaxb:2.35=testCompileClasspath,testRunti org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-inmemory:2.35=testCompileClasspath,testRuntimeClasspath org.glassfish.jersey.test-framework:jersey-test-framework-core:2.35=testCompileClasspath,testRuntimeClasspath org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.25.0-GA=testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle diff --git a/micrometer-test/build.gradle b/micrometer-test/build.gradle index e9e8b7d29b..2caaaf53dd 100644 --- a/micrometer-test/build.gradle +++ b/micrometer-test/build.gradle @@ -10,6 +10,7 @@ dependencies { api 'ru.lanwen.wiremock:wiremock-junit5' api 'com.github.tomakehurst:wiremock-jre8-standalone' api 'org.mockito:mockito-core' + implementation 'org.awaitility:awaitility' testImplementation 'org.jsr107.ri:cache-ri-impl' @@ -24,4 +25,10 @@ dependencies { testImplementation 'io.projectreactor.netty:reactor-netty-http' testImplementation 'org.apache.httpcomponents:httpclient' testImplementation 'org.eclipse.jetty:jetty-client' + testImplementation 'org.eclipse.jetty:jetty-server' + testImplementation 'org.eclipse.jetty:jetty-servlet' + testImplementation 'org.glassfish.jersey.core:jersey-server' + testImplementation 'org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-jdk-http:2.+' + // necessary for Jersey test framework + testRuntimeOnly 'org.glassfish.jersey.inject:jersey-hk2' } diff --git a/micrometer-test/gradle.lockfile b/micrometer-test/gradle.lockfile index 0be811b911..6aba0a3f07 100644 --- a/micrometer-test/gradle.lockfile +++ b/micrometer-test/gradle.lockfile @@ -52,10 +52,18 @@ io.spring.javaformat:spring-javaformat-config:0.0.31=checkstyle io.spring.nohttp:nohttp-checkstyle:0.0.10=checkstyle,nohttp io.spring.nohttp:nohttp-cli:0.0.10=nohttp-cli io.spring.nohttp:nohttp:0.0.10=checkstyle,nohttp,nohttp-cli +jakarta.activation:jakarta.activation-api:1.2.2=testCompileClasspath,testRuntimeClasspath +jakarta.annotation:jakarta.annotation-api:1.3.5=testCompileClasspath,testRuntimeClasspath +jakarta.servlet:jakarta.servlet-api:4.0.4=testCompileClasspath,testRuntimeClasspath +jakarta.validation:jakarta.validation-api:2.0.2=testCompileClasspath,testRuntimeClasspath +jakarta.ws.rs:jakarta.ws.rs-api:2.1.6=testCompileClasspath,testRuntimeClasspath +jakarta.xml.bind:jakarta.xml.bind-api:2.3.3=testCompileClasspath,testRuntimeClasspath javax.annotation:jsr250-api:1.0=testCompileClasspath,testRuntimeClasspath javax.cache:cache-api:1.1.1=testCompileClasspath,testRuntimeClasspath javax.enterprise:cdi-api:1.0-SP4=testCompileClasspath,testRuntimeClasspath javax.inject:javax.inject:1=testCompileClasspath,testRuntimeClasspath +javax.servlet:javax.servlet-api:3.1.0=testCompileClasspath,testRuntimeClasspath +junit:junit:4.13.1=testCompileClasspath,testRuntimeClasspath net.bytebuddy:byte-buddy-agent:1.12.9=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath net.bytebuddy:byte-buddy:1.12.9=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath net.sf.ehcache:ehcache:2.10.9.2=testCompileClasspath,testRuntimeClasspath @@ -67,13 +75,36 @@ org.apache.httpcomponents:httpclient:4.5.13=testCompileClasspath,testRuntimeClas org.apache.httpcomponents:httpcore:4.4.13=testCompileClasspath,testRuntimeClasspath org.apiguardian:apiguardian-api:1.1.2=compileClasspath,testCompileClasspath org.assertj:assertj-core:3.22.0=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle,testCompileClasspath,testRuntimeClasspath org.eclipse.jetty:jetty-client:9.4.48.v20220622=testCompileClasspath,testRuntimeClasspath org.eclipse.jetty:jetty-http:9.4.48.v20220622=testCompileClasspath,testRuntimeClasspath org.eclipse.jetty:jetty-io:9.4.48.v20220622=testCompileClasspath,testRuntimeClasspath +org.eclipse.jetty:jetty-security:9.4.48.v20220622=testCompileClasspath,testRuntimeClasspath +org.eclipse.jetty:jetty-server:9.4.48.v20220622=testCompileClasspath,testRuntimeClasspath +org.eclipse.jetty:jetty-servlet:9.4.48.v20220622=testCompileClasspath,testRuntimeClasspath +org.eclipse.jetty:jetty-util-ajax:9.4.48.v20220622=testCompileClasspath,testRuntimeClasspath org.eclipse.jetty:jetty-util:9.4.48.v20220622=testCompileClasspath,testRuntimeClasspath +org.glassfish.hk2.external:aopalliance-repackaged:2.6.1=testRuntimeClasspath +org.glassfish.hk2.external:jakarta.inject:2.6.1=testCompileClasspath,testRuntimeClasspath +org.glassfish.hk2:hk2-api:2.6.1=testRuntimeClasspath +org.glassfish.hk2:hk2-locator:2.6.1=testRuntimeClasspath +org.glassfish.hk2:hk2-utils:2.6.1=testRuntimeClasspath +org.glassfish.hk2:osgi-resource-locator:1.0.3=testCompileClasspath,testRuntimeClasspath +org.glassfish.jersey.containers:jersey-container-jdk-http:2.36=testCompileClasspath,testRuntimeClasspath +org.glassfish.jersey.containers:jersey-container-servlet-core:2.36=testCompileClasspath,testRuntimeClasspath +org.glassfish.jersey.core:jersey-client:2.36=testCompileClasspath,testRuntimeClasspath +org.glassfish.jersey.core:jersey-common:2.36=testCompileClasspath,testRuntimeClasspath +org.glassfish.jersey.core:jersey-server:2.36=testCompileClasspath,testRuntimeClasspath +org.glassfish.jersey.inject:jersey-hk2:2.36=testRuntimeClasspath +org.glassfish.jersey.media:jersey-media-jaxb:2.36=testCompileClasspath,testRuntimeClasspath +org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-jdk-http:2.36=testCompileClasspath,testRuntimeClasspath +org.glassfish.jersey.test-framework:jersey-test-framework-core:2.36=testCompileClasspath,testRuntimeClasspath +org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath +org.hamcrest:hamcrest:2.1=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath +org.javassist:javassist:3.25.0-GA=testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.jboss.spec.javax.interceptor:jboss-interceptors-api_1.1_spec:1.0.0.Beta1=testCompileClasspath,testRuntimeClasspath org.jetbrains.kotlin:kotlin-stdlib-common:1.4.21=testCompileClasspath,testRuntimeClasspath diff --git a/micrometer-test/src/main/java/io/micrometer/core/instrument/HttpServerTimingInstrumentationVerificationTests.java b/micrometer-test/src/main/java/io/micrometer/core/instrument/HttpServerTimingInstrumentationVerificationTests.java new file mode 100644 index 0000000000..4c33f2b1fd --- /dev/null +++ b/micrometer-test/src/main/java/io/micrometer/core/instrument/HttpServerTimingInstrumentationVerificationTests.java @@ -0,0 +1,157 @@ +/* + * Copyright 2022 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.core.instrument; + +import io.micrometer.core.annotation.Incubating; +import io.micrometer.core.instrument.search.RequiredSearch; +import io.micrometer.core.ipc.http.HttpSender; +import io.micrometer.core.ipc.http.HttpUrlConnectionSender; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.net.URI; +import java.time.Duration; +import java.util.function.Function; + +import static org.awaitility.Awaitility.await; + +/** + * Verify the instrumentation of an HTTP server has the minimum expected results. See + * {@link #startInstrumentedServer()} for the required specification the instrumented HTTP + * server must handle. + */ +@Incubating(since = "1.8.9") +public abstract class HttpServerTimingInstrumentationVerificationTests extends InstrumentationVerificationTests { + + private final HttpSender sender = new HttpUrlConnectionSender(); + + private URI baseUri; + + /** + * A default is provided that should be preferred by new instrumentations. Existing + * instrumentations that use a different value to maintain backwards compatibility may + * override this method to run tests with a different name used in assertions. + * @return name of the meter timing http client requests + */ + protected String timerName() { + return "http.server.requests"; + } + + /** + * Start the instrumented HTTP server to be tested. No request body or query + * parameters will be sent, and any response body will be ignored. The server MUST + * serve the routes described by {@link InstrumentedRoutes}. Constants are available + * in that class for the routes that will have requests sent to them as part of the + * TCK. The server MUST NOT have a route for the following: + * <ul> + * <li>{@code GET /notFound} (returns 404 response)</li> + * </ul> + * @return base URI where the instrumented server is receiving requests. Must end with + * a slash (/). + * @see InstrumentedRoutes + */ + protected abstract URI startInstrumentedServer() throws Exception; + + /** + * Stop the instrumented server that was started with + * {@link #startInstrumentedServer()}. + */ + protected abstract void stopInstrumentedServer() throws Exception; + + @BeforeEach + void beforeEach() throws Exception { + baseUri = startInstrumentedServer(); + } + + @AfterEach + void afterEach() throws Exception { + stopInstrumentedServer(); + } + + @Test + void uriIsNotFound_whenRouteIsUnmapped() throws Throwable { + sender.get(baseUri + "notFound").send(); + checkTimer(rs -> rs.tags("uri", "NOT_FOUND", "status", "404", "method", "GET").timer().count() == 1); + } + + @Test + void uriTemplateIsTagged() throws Throwable { + sender.get(baseUri + "hello/world").send(); + checkTimer(rs -> rs.tags("uri", InstrumentedRoutes.TEMPLATED_ROUTE, "status", "200", "method", "GET").timer() + .count() == 1); + } + + @Test + void redirect() throws Throwable { + sender.get(baseUri + "foundRedirect").send(); + checkTimer(rs -> rs.tags("uri", InstrumentedRoutes.REDIRECT, "status", "302", "method", "GET").timer() + .count() == 1); + } + + @Test + void errorResponse() throws Throwable { + sender.post(baseUri + "error").send(); + checkTimer( + rs -> rs.tags("uri", InstrumentedRoutes.ERROR, "status", "500", "method", "POST").timer().count() == 1); + } + + private void checkTimer(Function<RequiredSearch, Boolean> timerCheck) { + // jersey instrumentation finishes after response is sent, creating a race + await().atLeast(Duration.ofMillis(25)).atMost(Duration.ofMillis(150)) + .until(() -> timerCheck.apply(getRegistry().get(timerName()))); + } + + /** + * Class containing constants that can be used for implementing the HTTP routes that + * the instrumented server needs to serve to pass the + * {@link HttpServerTimingInstrumentationVerificationTests}. The HTTP server MUST + * serve the following: + * <ul> + * <li>{@link #ROOT}: {@code GET /}</li> + * <li>{@link #TEMPLATED_ROUTE}: {@code GET /hello/{name}}</li> + * <li>{@link #REDIRECT}: {@code GET /foundRedirect}</li> + * <li>{@link #ERROR}: {@code POST /error}</li> + * </ul> + */ + public static class InstrumentedRoutes { + + /** + * Path for the route with a path variable. The templated route is expected to be + * used in the URI tag. + */ + public static final String TEMPLATED_ROUTE = "/hello/{name}"; + + /** + * Path for the root route. + */ + public static final String ROOT = "/"; + + /** + * Path for the route that will respond with a 500 server error to a POST method + * request. + */ + public static final String ERROR = "/error"; + + /** + * Path for the route that will redirect with status code 302 to the {@link #ROOT} + * route. + */ + public static final String REDIRECT = "/foundRedirect"; + + } + +} diff --git a/micrometer-test/src/test/java/io/micrometer/core/instrument/JerseyServerTimingInstrumentationVerificationTests.java b/micrometer-test/src/test/java/io/micrometer/core/instrument/JerseyServerTimingInstrumentationVerificationTests.java new file mode 100644 index 0000000000..04708a9793 --- /dev/null +++ b/micrometer-test/src/test/java/io/micrometer/core/instrument/JerseyServerTimingInstrumentationVerificationTests.java @@ -0,0 +1,89 @@ +/* + * Copyright 2022 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.core.instrument; + +import io.micrometer.core.instrument.binder.jersey.server.DefaultJerseyTagsProvider; +import io.micrometer.core.instrument.binder.jersey.server.MetricsApplicationEventListener; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.JerseyTest; + +import javax.ws.rs.*; +import javax.ws.rs.core.Application; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.net.URI; + +class JerseyServerTimingInstrumentationVerificationTests extends HttpServerTimingInstrumentationVerificationTests { + + JerseyTest jerseyTest; + + @Override + protected URI startInstrumentedServer() throws Exception { + jerseyTest = new JerseyTest() { + @Override + protected Application configure() { + MetricsApplicationEventListener listener = new MetricsApplicationEventListener(getRegistry(), + new DefaultJerseyTagsProvider(), timerName(), true); + + ResourceConfig config = new ResourceConfig(); + config.register(listener); + config.register(TestResource.class); + + return config; + } + }; + + jerseyTest.setUp(); + + return jerseyTest.target().getUri(); + } + + @Override + protected void stopInstrumentedServer() throws Exception { + jerseyTest.tearDown(); + } + + @Path("/") + @Produces(MediaType.TEXT_PLAIN) + public static class TestResource { + + @GET + @Path(InstrumentedRoutes.ROOT) + public String root() { + return "hello"; + } + + @GET + @Path(InstrumentedRoutes.TEMPLATED_ROUTE) + public String hello(@PathParam("name") String name) { + return "hello " + name; + } + + @GET + @Path(InstrumentedRoutes.REDIRECT) + public Response redirect() { + return Response.status(302).location(URI.create("/")).build(); + } + + @POST + @Path(InstrumentedRoutes.ERROR) + public Response error() { + return Response.serverError().build(); + } + + } + +} diff --git a/micrometer-test/src/test/java/io/micrometer/core/instrument/JettyServerTimingInstrumentationVerificationTests.java b/micrometer-test/src/test/java/io/micrometer/core/instrument/JettyServerTimingInstrumentationVerificationTests.java new file mode 100644 index 0000000000..c1ed3ef092 --- /dev/null +++ b/micrometer-test/src/test/java/io/micrometer/core/instrument/JettyServerTimingInstrumentationVerificationTests.java @@ -0,0 +1,87 @@ +/* + * Copyright 2022 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.core.instrument; + +import io.micrometer.core.instrument.binder.jetty.TimedHandler; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.servlet.ServletHandler; +import org.junit.jupiter.api.Disabled; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URI; + +@Disabled("URI is not tagged in generic Jetty servlet instrumentation") +class JettyServerTimingInstrumentationVerificationTests extends HttpServerTimingInstrumentationVerificationTests { + + private Server server; + + @Override + protected String timerName() { + return "jetty.server.requests"; + } + + @Override + protected URI startInstrumentedServer() throws Exception { + server = new Server(0); + TimedHandler timedHandler = new TimedHandler(getRegistry(), Tags.empty()); + ServletContextHandler servletContextHandler = new ServletContextHandler(); + servletContextHandler.setContextPath("/"); + servletContextHandler.addServlet(ServletHandler.Default404Servlet.class, "/notFound"); + servletContextHandler.addServlet(MyWebServlet.class, "/*"); + server.setHandler(servletContextHandler); + server.insertHandler(timedHandler); + server.start(); + return server.getURI(); + } + + @Override + protected void stopInstrumentedServer() throws Exception { + server.stop(); + } + + public static class MyWebServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + if (req.getPathInfo().contentEquals("/")) { + resp.setStatus(200); + resp.getWriter().print("hello"); + } + else if (req.getPathInfo().startsWith("/home/")) { + resp.setStatus(200); + resp.getWriter().print("hello " + "world"); + } + else if (req.getPathInfo().contentEquals("/foundRedirect")) { + resp.sendRedirect("/"); + } + else { + resp.sendError(400); + } + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + super.doPost(req, resp); + } + + } + +} diff --git a/samples/micrometer-samples-hazelcast3/gradle.lockfile b/samples/micrometer-samples-hazelcast3/gradle.lockfile index c68f67b687..5c9fddbb37 100644 --- a/samples/micrometer-samples-hazelcast3/gradle.lockfile +++ b/samples/micrometer-samples-hazelcast3/gradle.lockfile @@ -38,8 +38,10 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath diff --git a/samples/micrometer-samples-jersey3/gradle.lockfile b/samples/micrometer-samples-jersey3/gradle.lockfile index 3f346bb00d..7b77f5b092 100644 --- a/samples/micrometer-samples-jersey3/gradle.lockfile +++ b/samples/micrometer-samples-jersey3/gradle.lockfile @@ -43,6 +43,7 @@ org.antlr:antlr4-runtime:4.8-1=nohttp org.antlr:antlr4-runtime:4.9.2=checkstyle org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath org.assertj:assertj-core:3.22.0=testCompileClasspath,testRuntimeClasspath +org.awaitility:awaitility:4.2.0=testRuntimeClasspath org.checkerframework:checker-qual:2.11.1=nohttp org.checkerframework:checker-qual:3.12.0=checkstyle org.glassfish.hk2.external:aopalliance-repackaged:3.0.1=default,runtimeClasspath,testRuntimeClasspath @@ -60,6 +61,7 @@ org.glassfish.jersey.media:jersey-media-jaxb:3.0.3=testCompileClasspath,testRunt org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-jdk-http:3.0.3=testCompileClasspath,testRuntimeClasspath org.glassfish.jersey.test-framework:jersey-test-framework-core:3.0.3=testCompileClasspath,testRuntimeClasspath org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath +org.hamcrest:hamcrest:2.1=testRuntimeClasspath org.hdrhistogram:HdrHistogram:2.1.12=compileClasspath,default,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.javassist:javassist:3.25.0-GA=default,runtimeClasspath,testRuntimeClasspath org.javassist:javassist:3.26.0-GA=checkstyle