Skip to content

Commit 72740e0

Browse files
committed
Merge branch '3.5.x'
Closes gh-48053
2 parents 3c64bdf + f69fbdb commit 72740e0

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/observability.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ Observability support relies on the https://github.com/micrometer-metrics/contex
2929
By default, javadoc:java.lang.ThreadLocal[] values are not automatically reinstated in reactive operators.
3030
This behavior is controlled with the configprop:spring.reactor.context-propagation[] property, which can be set to `auto` to enable automatic propagation.
3131

32+
If you're working with javadoc:org.springframework.scheduling.annotation.Async[format=annotation] methods or use an javadoc:org.springframework.core.task.AsyncTaskExecutor[], you have to register the javadoc:org.springframework.core.task.support.ContextPropagatingTaskDecorator[] on the executor, otherwise the observability context is lost when switching threads.
33+
This can be done using this configuration:
34+
35+
include-code::ContextPropagationConfiguration[]
36+
3237
For more details about observations please see the {url-micrometer-docs}/observation[Micrometer Observation documentation].
3338

3439

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.actuator.observability.contextpropagation;
18+
19+
import org.springframework.context.annotation.Bean;
20+
import org.springframework.context.annotation.Configuration;
21+
import org.springframework.core.task.support.ContextPropagatingTaskDecorator;
22+
23+
@Configuration(proxyBeanMethods = false)
24+
class ContextPropagationConfiguration {
25+
26+
@Bean
27+
ContextPropagatingTaskDecorator contextPropagatingTaskDecorator() {
28+
return new ContextPropagatingTaskDecorator();
29+
}
30+
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.actuator.observability.contextpropagation
18+
19+
import org.springframework.context.annotation.Bean
20+
import org.springframework.context.annotation.Configuration
21+
import org.springframework.core.task.support.ContextPropagatingTaskDecorator
22+
23+
@Configuration(proxyBeanMethods = false)
24+
class ContextPropagationConfiguration {
25+
26+
@Bean
27+
fun contextPropagatingTaskDecorator(): ContextPropagatingTaskDecorator {
28+
return ContextPropagatingTaskDecorator()
29+
}
30+
31+
}

0 commit comments

Comments
 (0)