|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2022 the original author or authors. |
| 2 | + * Copyright 2012-2023 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
25 | 25 | import io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics;
|
26 | 26 |
|
27 | 27 | import org.springframework.beans.factory.annotation.Autowired;
|
| 28 | +import org.springframework.boot.LazyInitializationExcludeFilter; |
28 | 29 | import org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration;
|
29 | 30 | import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration;
|
30 | 31 | import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
33 | 34 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
34 | 35 | import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
|
35 | 36 | import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration;
|
| 37 | +import org.springframework.context.annotation.Bean; |
36 | 38 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
37 | 39 | import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
38 | 40 |
|
@@ -63,6 +65,11 @@ else if (executor instanceof ThreadPoolTaskScheduler) {
|
63 | 65 | });
|
64 | 66 | }
|
65 | 67 |
|
| 68 | + @Bean |
| 69 | + static LazyInitializationExcludeFilter eagerTaskExecutorMetrics() { |
| 70 | + return LazyInitializationExcludeFilter.forBeanTypes(TaskExecutorMetricsAutoConfiguration.class); |
| 71 | + } |
| 72 | + |
66 | 73 | private void monitor(MeterRegistry registry, ThreadPoolExecutor threadPoolExecutor, String name) {
|
67 | 74 | if (threadPoolExecutor != null) {
|
68 | 75 | new ExecutorServiceMetrics(threadPoolExecutor, name, Collections.emptyList()).bindTo(registry);
|
|
0 commit comments