Skip to content
New issue

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

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

Already on GitHub? # to your account

Duplicate observations recorded with RestClient #33068

Closed
MilanSMA opened this issue Jun 19, 2024 · 1 comment
Closed

Duplicate observations recorded with RestClient #33068

MilanSMA opened this issue Jun 19, 2024 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: observability An issue related to observability and tracing type: bug A general bug
Milestone

Comments

@MilanSMA
Copy link

MilanSMA commented Jun 19, 2024

Hi,

I'm using spring-boot 3.3.0 (spring-framework 6.1.8). After migration from spring-boot 3.2.5, the metrics are false because the timer for RestClient counts twice the calls (http.client.request).

This can be reproduced with a simple spring boot test:

@Test
void restClientMetricsBug() {
   // registry and clientBuilder are injected 
   clientBuilder.baseUrl("http://localhost:8080").build().get().retrieve().toEntity(String.class);
   var tm = registry.get("http.client.requests").timer();
   assertEquals(1, tm.count());  // fails with 1 != 2
}

The problem seems to be (to my opinion) that Timer.stop is called twice:

  • the first time on DefaultRestClient L230 because clientResponse is AutoClosable (close stops the observation),
  • the second time in finally on L254 (observation.stop is called a second time) (observation.stop() calls indirectly Timer$Sample.stop()).

I hope my analysis will be helpfull.

Thanks.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 19, 2024
@bclozel bclozel self-assigned this Jun 19, 2024
@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) theme: observability An issue related to observability and tracing labels Jun 19, 2024
@bclozel bclozel changed the title RestClient calls are counted 2x Duplicate observations recorded with RestClient Jun 19, 2024
@bclozel bclozel added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 19, 2024
@bclozel bclozel added this to the 6.1.10 milestone Jun 19, 2024
@bclozel
Copy link
Member

bclozel commented Jun 19, 2024

Thanks for your report @MilanSMA , this is now fixed in 6.1.10-SNAPSHOT and will be released later today.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: observability An issue related to observability and tracing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants