Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] MicrometerObservationCapability not reporting timeouts #2566

Open
elgbar opened this issue Sep 25, 2024 · 1 comment · May be fixed by #2644
Open

[BUG] MicrometerObservationCapability not reporting timeouts #2566

elgbar opened this issue Sep 25, 2024 · 1 comment · May be fixed by #2644
Labels
bug Unexpected or incorrect behavior spring-cloud Issues related to Spring Cloud OpenFeign

Comments

@elgbar
Copy link

elgbar commented Sep 25, 2024

Copied from spring-cloud/spring-cloud-openfeign#958
Seems like nobody created an issue here as requested in the original issue

Describe the bug Feign cloud version: 4.1.0

When using the MicrometerObservationCapability, any java.net.SocketTimeoutException is not caught and observations is never closed (MicrometerObservationCapability#enrich only catches FeignExceptions). Probably affects other errors from the underlying web layer too. The result is that these requests are never added to the metrics. There is either an ordering error, or MicrometerObservationCapability should catch more types of errors

Sample No specific config added. Plain FeignClients

@FeignClient(name = "NAME", url = "${url.prop}")
interface Client {
// calls here
}

@Configuration
class FeignConfig {
  @Bean
  def observation(observationRegistry: ObservationRegistry): MicrometerObservationCapability = new MicrometerObservationCapability(observationRegistry, new DefaultFeignObservationConvention())
}

application.yml

spring:
  cloud:
    openfeign:
      client:
        config:
          default:
            connect-timeout: 3000
            read-timeout: 3000

Stacktrace

Caused by: java.net.SocketTimeoutException: Read timed out
	at java.base/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:288)
	at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:314)
	at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:355)
	at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:808)
	at java.base/java.net.Socket$SocketInputStream.read(Socket.java:966)
	at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:244)
	at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
	at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:343)
	at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:826)
	at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:761)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1688)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
	at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:529)
	at feign.Client$Default.convertResponse(Client.java:111)
	at feign.Client$Default.execute(Client.java:107)
	at feign.micrometer.MicrometerObservationCapability.lambda$enrich$1(MicrometerObservationCapability.java:53)
	at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:100)
@kdavisk6 kdavisk6 added bug Unexpected or incorrect behavior spring-cloud Issues related to Spring Cloud OpenFeign labels Sep 25, 2024
@r-dimitrov
Copy link

I can confirm that I'm facing the same issue and it is not only for java.net.SocketTimeoutException.. It is for all exceptions, as they are not wrapped to FeignException but to the underlying client ones. For example Method threw 'org.apache.hc.client5.http.HttpHostConnectException' exception.

Screenshot 2024-10-25 at 10 54 14

Why we are not catching just Exception? As the behaviour will be the same and everything will work.

@r-dimitrov r-dimitrov linked a pull request Nov 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect behavior spring-cloud Issues related to Spring Cloud OpenFeign
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants