spring-framework/framework-docs/modules/ROOT
Brian Clozel ef2a403df6 Add PropagationContextElement Kotlin operator
Prior to this commit, the Micrometer context-propagation project would
help propagating information from `ThreadLocal`, Reactor `Context` and
other context objects. This is already well supported for Micrometer
Observations.

In the case of Kotlin suspending functions, the processing of tasks
would not necessarily update the `ThreadLocal` when the function is
scheduled on a different thread.

This commit introduces the `PropagationContextElement` operator that
connects the `ThreadLocal`, Reactor `Context` and Coroutine `Context`
for all libraries using the "context-propagation" project.

Applications must manually use this operator in suspending functions
like so:

```
suspend fun suspendingFunction() {
  return withContext(PropagationContextElement(currentCoroutineContext())) {
    logger.info("Suspending function with traceId")
  }
}
```

Closes gh-35185
2025-09-09 21:42:08 +02:00
..
assets/images Migrate Structure 2023-05-04 15:35:05 +01:00
examples Use include-code Macro 2023-05-04 15:35:05 +01:00
pages Add PropagationContextElement Kotlin operator 2025-09-09 21:42:08 +02:00
partials/web Polishing contribution 2025-09-01 11:50:22 +02:00
nav.adoc Add RestTestClient 2025-07-30 07:13:48 +01:00