Polish gh-29883
This commit is contained in:
parent
7bc731dfa6
commit
433b72d493
|
@ -103,8 +103,8 @@ By default, the following `KeyValues` are created:
|
|||
|Name | Description
|
||||
|`code.function` _(required)_|Name of Java `Method` that is scheduled for execution.
|
||||
|`code.namespace` _(required)_|Canonical name of the class of the bean instance that holds the scheduled method.
|
||||
|`exception` _(required)_|Name of the exception thrown during the execution, or `KeyValue#NONE_VALUE`} if no exception happened.
|
||||
|`outcome` _(required)_|Outcome of the method execution. Can be `"SUCCESS"`, `"ERROR"` or `"UNKNOWN"` (if for example the operation was cancelled during execution.
|
||||
|`exception` _(required)_|Name of the exception thrown during the execution, or `"none"` if no exception happened.
|
||||
|`outcome` _(required)_|Outcome of the method execution. Can be `"SUCCESS"`, `"ERROR"` or `"UNKNOWN"` (if for example the operation was cancelled during execution).
|
||||
|===
|
||||
|
||||
|
||||
|
@ -135,7 +135,7 @@ By default, the following `KeyValues` are created:
|
|||
[cols="a,a"]
|
||||
|===
|
||||
|Name | Description
|
||||
|`exception` _(required)_|Name of the exception thrown during the exchange, or `KeyValue#NONE_VALUE`} if no exception happened.
|
||||
|`exception` _(required)_|Name of the exception thrown during the exchange, or `"none"` if no exception happened.
|
||||
|`method` _(required)_|Name of HTTP request method or `"none"` if the request was not received properly.
|
||||
|`outcome` _(required)_|Outcome of the HTTP server exchange.
|
||||
|`status` _(required)_|HTTP response raw status code, or `"UNKNOWN"` if no response was created.
|
||||
|
|
|
@ -75,7 +75,7 @@ public class DefaultScheduledTaskObservationConvention implements ScheduledTaskO
|
|||
if (context.getError() != null) {
|
||||
return OUTCOME_ERROR;
|
||||
}
|
||||
else if (!context.isComplete()) {
|
||||
if (!context.isComplete()) {
|
||||
return OUTCOME_UNKNOWN;
|
||||
}
|
||||
return OUTCOME_SUCCESS;
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.springframework.context.support.StaticApplicationContext;
|
|||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.scheduling.config.ScheduledTask;
|
||||
import org.springframework.scheduling.config.ScheduledTaskHolder;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
import org.springframework.scheduling.support.ScheduledTaskObservationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -155,14 +154,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
targetDefinition.getPropertyValues().add("observationRegistry", this.observationRegistry);
|
||||
context.registerBeanDefinition("postProcessor", processorDefinition);
|
||||
context.registerBeanDefinition("target", targetDefinition);
|
||||
context.registerBean("schedulingConfigurer", SchedulingConfigurer.class, () -> {
|
||||
return new SchedulingConfigurer() {
|
||||
@Override
|
||||
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
||||
taskRegistrar.setObservationRegistry(observationRegistry);
|
||||
}
|
||||
};
|
||||
});
|
||||
context.registerBean("schedulingConfigurer", SchedulingConfigurer.class, () -> taskRegistrar -> taskRegistrar.setObservationRegistry(observationRegistry));
|
||||
context.refresh();
|
||||
}
|
||||
|
||||
|
@ -198,7 +190,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
this.observationRegistry = observationRegistry;
|
||||
}
|
||||
|
||||
public void await() throws InterruptedException {
|
||||
void await() throws InterruptedException {
|
||||
this.latch.await(3, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +199,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
static class FixedDelayBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public void fixedDelay() {
|
||||
void fixedDelay() {
|
||||
this.latch.countDown();
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +208,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
static class FixedDelayErrorBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public void error() {
|
||||
void error() {
|
||||
this.latch.countDown();
|
||||
throw new IllegalStateException("test error");
|
||||
}
|
||||
|
@ -226,7 +218,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
static class FixedDelayReactiveBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public Mono<Object> fixedDelay() {
|
||||
Mono<Object> fixedDelay() {
|
||||
return Mono.empty().doOnTerminate(() -> this.latch.countDown());
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +227,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
static class FixedDelayReactiveErrorBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public Mono<Object> error() {
|
||||
Mono<Object> error() {
|
||||
return Mono.error(new IllegalStateException("test error"))
|
||||
.doOnTerminate(() -> this.latch.countDown());
|
||||
}
|
||||
|
@ -245,7 +237,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
static class CancelledTaskBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public void cancelled() {
|
||||
void cancelled() {
|
||||
this.latch.countDown();
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
|
@ -260,7 +252,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
static class CancelledReactiveTaskBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public Flux<Long> cancelled() {
|
||||
Flux<Long> cancelled() {
|
||||
return Flux.interval(Duration.ZERO, Duration.ofSeconds(1))
|
||||
.doOnNext(el -> this.latch.countDown());
|
||||
}
|
||||
|
@ -270,9 +262,10 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
static class CurrentObservationBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public void hasCurrentObservation() {
|
||||
assertThat(this.observationRegistry.getCurrentObservation()).isNotNull();
|
||||
assertThat(this.observationRegistry.getCurrentObservation().getContext()).isInstanceOf(ScheduledTaskObservationContext.class);
|
||||
void hasCurrentObservation() {
|
||||
Observation observation = this.observationRegistry.getCurrentObservation();
|
||||
assertThat(observation).isNotNull();
|
||||
assertThat(observation.getContext()).isInstanceOf(ScheduledTaskObservationContext.class);
|
||||
this.latch.countDown();
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +274,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests {
|
|||
static class CurrentObservationReactiveBean extends TaskTester {
|
||||
|
||||
@Scheduled(fixedDelay = 10_000, initialDelay = 5_000)
|
||||
public Mono<String> hasCurrentObservation() {
|
||||
Mono<String> hasCurrentObservation() {
|
||||
return Mono.just("test")
|
||||
.tap(() -> new DefaultSignalListener<String>() {
|
||||
@Override
|
||||
|
|
|
@ -101,6 +101,7 @@ class DefaultScheduledTaskObservationConventionTests {
|
|||
|
||||
static class BeanWithScheduledMethods implements TaskProcessor {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue