Skip to content

docs: warn against combining TimedAspect with Spring Boot's built-in @Timed support#7603

Open
won-seoop wants to merge 1 commit into
micrometer-metrics:mainfrom
won-seoop:doc-4621-timedaspect-double-instrumentation-warning
Open

docs: warn against combining TimedAspect with Spring Boot's built-in @Timed support#7603
won-seoop wants to merge 1 commit into
micrometer-metrics:mainfrom
won-seoop:doc-4621-timedaspect-double-instrumentation-warning

Conversation

@won-seoop

Copy link
Copy Markdown

Summary

Closes #4621

Registering a TimedAspect bean when Spring Boot's built-in @Timed processing is active for @Controller/@RestController methods leads to double instrumentation of web endpoints. Both mechanisms time the same method, creating duplicate meters — often with the same name but different tags. This is particularly painful with the Prometheus registry, which rejects duplicate metric names at registration time.

Added a WARNING callout in the @Timed section of timers.adoc clarifying:

  • Spring Boot auto-instruments web endpoints (@Controller / @RestController) — no TimedAspect needed for those
  • TimedAspect should only be used for non-web beans (services, repositories, etc.) that Spring Boot does not instrument automatically
  • Combining both on the same method produces duplicate meters, with Prometheus being the most affected

Test plan

  • Docs build with Antora renders the WARNING callout correctly
  • Wording is consistent with guidance from the team (comment by @jonatan-ivanov in the issue)

…timed support

micrometer-metricsGH-4621: Registering a TimedAspect bean alongside Spring Boot's auto-configured
@timed processing for @Controller/@RestController results in double instrumentation:
the same method is timed twice with potentially different tags. This is especially
harmful with Prometheus, which rejects duplicate metric registrations.

Added a WARNING callout in the @timed section explaining:
- Spring Boot instruments @Controller/@RestController automatically
- TimedAspect should only be used for non-web beans (services, repositories, etc.)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timed annotation framework support and TimedAspect usage not clear enough

1 participant