Move observation support classes to scheduling.support package

Avoids a package cycle between config and support (only config->support allowed).

See gh-29883
This commit is contained in:
Juergen Hoeller
2023-07-08 14:57:02 +02:00
parent 8fb412ea74
commit f0fe58f0ec
9 changed files with 44 additions and 39 deletions

View File

@@ -38,15 +38,15 @@ import org.springframework.core.KotlinDetector;
import org.springframework.core.ReactiveAdapter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.lang.Nullable;
import org.springframework.scheduling.config.DefaultScheduledTaskObservationConvention;
import org.springframework.scheduling.config.ScheduledTaskObservationContext;
import org.springframework.scheduling.config.ScheduledTaskObservationConvention;
import org.springframework.scheduling.support.DefaultScheduledTaskObservationConvention;
import org.springframework.scheduling.support.ScheduledTaskObservationContext;
import org.springframework.scheduling.support.ScheduledTaskObservationConvention;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;
import static org.springframework.scheduling.config.ScheduledTaskObservationDocumentation.TASKS_SCHEDULED_EXECUTION;
import static org.springframework.scheduling.support.ScheduledTaskObservationDocumentation.TASKS_SCHEDULED_EXECUTION;
/**
* Helper class for @{@link ScheduledAnnotationBeanPostProcessor} to support reactive

View File

@@ -14,14 +14,14 @@
* limitations under the License.
*/
package org.springframework.scheduling.config;
package org.springframework.scheduling.support;
import io.micrometer.common.KeyValue;
import io.micrometer.common.KeyValues;
import org.springframework.util.StringUtils;
import static org.springframework.scheduling.config.ScheduledTaskObservationDocumentation.LowCardinalityKeyNames;
import static org.springframework.scheduling.support.ScheduledTaskObservationDocumentation.LowCardinalityKeyNames;
/**
* Default implementation for {@link ScheduledTaskObservationConvention}.

View File

@@ -24,10 +24,6 @@ import java.util.function.Supplier;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationRegistry;
import org.springframework.scheduling.config.DefaultScheduledTaskObservationConvention;
import org.springframework.scheduling.config.ScheduledTaskObservationContext;
import org.springframework.scheduling.config.ScheduledTaskObservationConvention;
import org.springframework.scheduling.config.ScheduledTaskObservationDocumentation;
import org.springframework.util.ReflectionUtils;
/**
@@ -42,7 +38,8 @@ import org.springframework.util.ReflectionUtils;
*/
public class ScheduledMethodRunnable implements Runnable {
private static final ScheduledTaskObservationConvention DEFAULT_CONVENTION = new DefaultScheduledTaskObservationConvention();
private static final ScheduledTaskObservationConvention DEFAULT_CONVENTION =
new DefaultScheduledTaskObservationConvention();
private final Object target;
@@ -50,6 +47,7 @@ public class ScheduledMethodRunnable implements Runnable {
private final Supplier<ObservationRegistry> observationRegistrySupplier;
/**
* Create a {@code ScheduledMethodRunnable} for the given target instance,
* calling the specified method.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.scheduling.config;
package org.springframework.scheduling.support;
import java.lang.reflect.Method;
@@ -23,8 +23,9 @@ import io.micrometer.observation.Observation;
import org.springframework.util.ClassUtils;
/**
* Context that holds information for observation metadata collection
* during the {@link ScheduledTaskObservationDocumentation#TASKS_SCHEDULED_EXECUTION execution of scheduled tasks}.
* Context that holds information for observation metadata collection during the
* {@link ScheduledTaskObservationDocumentation#TASKS_SCHEDULED_EXECUTION execution of scheduled tasks}.
*
* @author Brian Clozel
* @since 6.1
*/
@@ -36,6 +37,7 @@ public class ScheduledTaskObservationContext extends Observation.Context {
private boolean complete;
/**
* Create a new observation context for a task, given the target object
* and the method to be called.
@@ -47,6 +49,7 @@ public class ScheduledTaskObservationContext extends Observation.Context {
this.method = method;
}
/**
* Return the type of the target object.
*/
@@ -77,4 +80,5 @@ public class ScheduledTaskObservationContext extends Observation.Context {
public void setComplete(boolean complete) {
this.complete = complete;
}
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.scheduling.config;
package org.springframework.scheduling.support;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationConvention;
@@ -22,6 +22,7 @@ import io.micrometer.observation.ObservationConvention;
/**
* Interface for an {@link ObservationConvention} for
* {@link ScheduledTaskObservationDocumentation#TASKS_SCHEDULED_EXECUTION scheduled task executions}.
*
* @author Brian Clozel
* @since 6.1
*/

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.scheduling.config;
package org.springframework.scheduling.support;
import io.micrometer.common.KeyValue;
import io.micrometer.common.docs.KeyName;
@@ -24,8 +24,10 @@ import io.micrometer.observation.docs.ObservationDocumentation;
/**
* Documented {@link io.micrometer.common.KeyValue KeyValues} for the observations on
* executions of {@link org.springframework.scheduling.annotation.Scheduled scheduled tasks}.
* <p>This class is used by automated tools to document KeyValues attached to the {@code @Scheduled} observations.
* executions of {@link org.springframework.scheduling.annotation.Scheduled scheduled tasks}
*
* <p>This class is used by automated tools to document KeyValues attached to the
* {@code @Scheduled} observations.
*
* @author Brian Clozel
* @since 6.1
@@ -40,19 +42,17 @@ public enum ScheduledTaskObservationDocumentation implements ObservationDocument
public Class<? extends ObservationConvention<? extends Observation.Context>> getDefaultConvention() {
return DefaultScheduledTaskObservationConvention.class;
}
@Override
public KeyName[] getLowCardinalityKeyNames() {
return LowCardinalityKeyNames.values();
}
@Override
public KeyName[] getHighCardinalityKeyNames() {
return new KeyName[] {};
}
};
public enum LowCardinalityKeyNames implements KeyName {
/**