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

Metrics for ThreadPoolTaskScheduler can conflict with the metrics of ThreadPoolTaskExecutor if they share the same bean name prefix #28536

Closed
filiphr opened this issue Nov 4, 2021 · 0 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@filiphr
Copy link
Contributor

filiphr commented Nov 4, 2021

In #23818 support for Task Execution and Scheduling Metrics was added..

In it the name for the "executorServiceName" of the auto registered ThreadPoolTaskExecutor and ThreadPoolTaskScheduler is identitcal ("application"). This means that the only the metrics of one executor are used.

Here is an example test cases demonstrating the problem.

@Test
void taskSchedulerAndThreadPoolUsingAutoConfigurationAreInstrumented() {
    this.contextRunner.withConfiguration(AutoConfigurations.of(TaskSchedulingAutoConfiguration.class, TaskExecutionAutoConfiguration.class))
            .withPropertyValues(
                    "spring.task.execution.pool.max-size=10"
            )
            .withUserConfiguration(SchedulingTestConfiguration.class).run((context) -> {
                MeterRegistry registry = context.getBean(MeterRegistry.class);
                Collection<Gauge> meters = registry.get("executor.pool.max").gauges();
                assertThat(meters)
                        .extracting(Gauge::value)
                        .containsExactlyInAnyOrder(Double.valueOf(10), Double.valueOf(Integer.MAX_VALUE));
            });
}

The same problem will occur when I register my own custom beans.

e.g. when I have myCustomTaskScheduler and myCustomTaskExecutor then only the value of one of them will be monitored.

I noticed this because we have our own metrics, that are slightly different then the ones configured here and I was trying to adapt our usage to use MeterFilter in order to rely on the Spring Boot auto configuration.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 4, 2021
@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 9, 2021
@snicoll snicoll added this to the 2.6.x milestone Nov 9, 2021
@snicoll snicoll changed the title Metrics for ThreadPoolTaskScheduler are overridden by the metrics of ThreadPoolTaskExecutor Metrics for ThreadPoolTaskScheduler can conflict with the metrics of ThreadPoolTaskExecutor if they share the same bean name prefix Nov 9, 2021
@scottfrederick scottfrederick self-assigned this Nov 10, 2021
@scottfrederick scottfrederick modified the milestones: 2.6.x, 2.6.0 Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants