You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit enhances the `ScheduledAnnotationBeanPostProcessor` to
instrument `@Scheduled` methods declared on beans. This will create
`"tasks.scheduled.execution"` observations for each execution of a
scheduled method. This supports both blocking and reactive variants.
By default, observations are no-ops; developers must configure the
current `ObservationRegistry` on the `ScheduledTaskRegistrar` by using a
`SchedulingConfigurer`.
Closesgh-29883
You can configure `ObservationFilter` instances on the `ObservationRegistry`.
81
84
85
+
[[observability.tasks-scheduled]]
86
+
== @Scheduled tasks instrumentation
87
+
88
+
An Observation is created for xref:integration/scheduling.adoc#scheduling-enable-annotation-support[each execution of an `@Scheduled` task].
89
+
Applications need to configure the `ObservationRegistry` on the `ScheduledTaskRegistrar` to enable the recording of observations.
90
+
This can be done by declaring a `SchedulingConfigurer` bean that sets the observation registry:
91
+
92
+
include-code::./ObservationSchedulingConfigurer[]
93
+
94
+
It is using the `org.springframework.scheduling.config.DefaultScheduledTaskObservationConvention` by default, backed by the `ScheduledTaskObservationContext`.
95
+
You can configure a custom implementation on the `ObservationRegistry` directly.
96
+
During the execution of the scheduled method, the current observation is restored in the `ThreadLocal` context or the Reactor context (if the scheduled method returns a `Mono` or `Flux` type).
97
+
98
+
By default, the following `KeyValues` are created:
99
+
100
+
.Low cardinality Keys
101
+
[cols="a,a"]
102
+
|===
103
+
|Name | Description
104
+
|`exception` _(required)_|Name of the exception thrown during the execution, or `KeyValue#NONE_VALUE`} if no exception happened.
105
+
|`method.name` _(required)_|Name of Java `Method` that is scheduled for execution.
106
+
|`outcome` _(required)_|Outcome of the method execution. Can be `"SUCCESS"`, `"ERROR"` or `"UNKNOWN"` (if for example the operation was cancelled during execution.
107
+
|`target.type` _(required)_|Simple class name of the bean instance that holds the scheduled method.
Copy file name to clipboardExpand all lines: spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java
Copy file name to clipboardExpand all lines: spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationReactiveSupport.java
0 commit comments