mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '3.5.x'
Closes gh-48053
This commit is contained in:
+5
@@ -29,6 +29,11 @@ Observability support relies on the https://github.com/micrometer-metrics/contex
|
||||
By default, javadoc:java.lang.ThreadLocal[] values are not automatically reinstated in reactive operators.
|
||||
This behavior is controlled with the configprop:spring.reactor.context-propagation[] property, which can be set to `auto` to enable automatic propagation.
|
||||
|
||||
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.
|
||||
This can be done using this configuration:
|
||||
|
||||
include-code::ContextPropagationConfiguration[]
|
||||
|
||||
For more details about observations please see the {url-micrometer-docs}/observation[Micrometer Observation documentation].
|
||||
|
||||
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2012-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.actuator.observability.contextpropagation;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.task.support.ContextPropagatingTaskDecorator;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
class ContextPropagationConfiguration {
|
||||
|
||||
@Bean
|
||||
ContextPropagatingTaskDecorator contextPropagatingTaskDecorator() {
|
||||
return new ContextPropagatingTaskDecorator();
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2012-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.actuator.observability.contextpropagation
|
||||
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.core.task.support.ContextPropagatingTaskDecorator
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
class ContextPropagationConfiguration {
|
||||
|
||||
@Bean
|
||||
fun contextPropagatingTaskDecorator(): ContextPropagatingTaskDecorator {
|
||||
return ContextPropagatingTaskDecorator()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user