quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.44k stars 2.58k forks source link

Micrometer URI templating does not apply for Forbidden requests #40305

Closed oscarobr closed 3 months ago

oscarobr commented 3 months ago

Describe the bug

In case a HTTP request ends up in 403 Forbidden, the Micrometer URI tag will not be templated, but include the full URI

there was a similar issue for 401 that was solved quarkusio/quarkus/issues/24938

Expected behavior

All reported metrics should have templated URI tags

Actual behavior

Requests that return 403 Forbidden create metrics that are not templated

How to Reproduce?

Reproducer can be found here: https://github.com/oscarobr/micrometer-uri-template-bug

See the failing test case that verifies the issue https://github.com/oscarobr/micrometer-uri-template-bug/blob/main/src/test/java/com/example/ExampleResourceTest.java

Output of uname -a or ver

Linux ThinkPad-T14s-Gen-2a 6.5.0-28-generic #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr 4 14:39:20 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "21.0.2" 2024-01-16 LTS OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode, sharing)

Quarkus version or git rev

3.9.4

Build tool (ie. output of mvnw --version or gradlew --version)

------------------------------------------------------------ Gradle 8.6 ------------------------------------------------------------ Build time: 2024-02-02 16:47:16 UTC Revision: d55c486870a0dc6f6278f53d21381396d0741c6e Kotlin: 1.9.20 Groovy: 3.0.17 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 JVM: 21.0.2 (Eclipse Adoptium 21.0.2+13-LTS) OS: Linux 6.5.0-28-generic amd64

Additional information

No response

quarkus-bot[bot] commented 3 months ago

/cc @brunobat (micrometer), @ebullient (micrometer), @geoand (kotlin)

geoand commented 3 months ago

Your sample is not using Quarkus REST (formelly known as RESTEasy Reactive). However even with it, https://github.com/quarkusio/quarkus/pull/40308 is required to make the tests pass.

oscarobr commented 3 months ago

Thanks for the hint, I didn't realize that these dependencies had been migrated

imjuoy commented 1 week ago

What is the standard behavior here? I have an application which uses Quarkus 3.10.0, and I see the below behavior for URI templating.

  1. For requests with 2xx response code, the URI in the metrics is templated.
  2. For requests resulting in a 400 Bad Request response code, the URI in the metrics is NOT templated.
  3. For requests resulting in a 409 Duplicate response code, the URI in the metrics is templated.
  4. For requests resulting in a 403 Unauthorized response code, the URI in the metrics is templated.

Is this expected? I see multiple bugs related to templating not working for different error code. What is the standard behavior out of the box for Quarkus version 3.10.0?

geoand commented 1 week ago

For requests resulting in a 400 Bad Request response code, the URI in the metrics is NOT templated.

I would say that this is probably a bug, do you have a sample project that shows this problem in action?