Skip to content

Metrics not collected after ExecutorService recreation #5366

@ajax-surovskyi-y

Description

@ajax-surovskyi-y

Describe the bug
When using Micrometer to collect metrics from an ExecutorService, I wrap it with ExecutorServiceMetrics.monitor. In the framework logic that I use, the original ExecutorService shuts down if it is not used for some time, and then it is recreated as needed. After it is recreated, metrics are not collected from it because it is created with the exact same name, and all methods like ThreadPoolExecutor::getCorePoolSize are called on the ThreadPoolExecutor that has already been shut down. I have created a PR with a test for this problem and a potential fix.
Environment

  • Micrometer version 1.13.1
  • Micrometer registry statsd
  • OS: Linux
  • Java version: 21.0.1

To Reproduce
How to reproduce the bug:

  1. Wrap an ExecutorService with ExecutorServiceMetrics.monitor.
  2. Allow the shutdown.
  3. Recreate the ExecutorService.
  4. Observe that metrics are not being collected.

Expected behavior
Metrics should continue to be collected from the recreated ExecutorService.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementA general enhancementinstrumentationAn issue that is related to instrumenting a componentmodule: micrometer-coreAn issue that is related to our core module

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions