クラス PropagationContextElement
java.lang.ObjectSE
kotlin.coroutines.AbstractCoroutineContextElement
org.springframework.core.PropagationContextElement
- 実装済みのインターフェース一覧:
kotlin.coroutines.CoroutineContext, kotlin.coroutines.CoroutineContext.Element, kotlinx.coroutines.ThreadContextElement<io.micrometer.context.ContextSnapshot.Scope>
public final class PropagationContextElement
extends kotlin.coroutines.AbstractCoroutineContextElement
implements kotlinx.coroutines.ThreadContextElement<io.micrometer.context.ContextSnapshot.Scope>
ThreadContextElement that ensures that contexts registered with the Micrometer Context Propagation library are captured and restored when a coroutine is resumed on a thread. This is typically being used for Micrometer Tracing support in Kotlin suspended functions.io.micrometer:context-propagation ライブラリが必要です。クラスパスに org.jetbrains.kotlinx:kotlinx-coroutines-reactor 依存関係も存在する場合、この要素は Reactor と Context もサポートします。
PropagationContextElement は次のように使用できます。
fun main() {
runBlocking(Dispatchers.IO + PropagationContextElement()) {
suspendingFunction()
}
}
suspend fun suspendingFunction() {
delay(1)
logger.info("Log statement with traceId")
}
- 導入:
- 7.0
- 作成者:
- Brian Clozel, Sebastien Deleuze
ネストされたクラスの概要
ネストされたクラスインターフェース kotlin.coroutines.CoroutineContext から継承されたネストクラス / インターフェース
kotlin.coroutines.CoroutineContext.Elementインターフェース kotlin.coroutines.CoroutineContext.Element から継承されたネストクラス / インターフェース
kotlin.coroutines.CoroutineContext.Element.DefaultImplsインターフェース kotlinx.coroutines.ThreadContextElement から継承されたネストクラス / インターフェース
kotlinx.coroutines.ThreadContextElement.DefaultImplsフィールド概要
フィールドコンストラクター概要
コンストラクター方法の概要
修飾子と型メソッド説明voidrestoreThreadContext(kotlin.coroutines.CoroutineContext context, io.micrometer.context.ContextSnapshot.Scope oldState) io.micrometer.context.ContextSnapshot.ScopeupdateThreadContext(kotlin.coroutines.CoroutineContext context) クラス kotlin.coroutines.AbstractCoroutineContextElement から継承されたメソッド
fold, get, getKey, minusKey, plusクラス ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSEインターフェース kotlin.coroutines.CoroutineContext から継承されたメソッド
plusインターフェース kotlin.coroutines.CoroutineContext.Element から継承されたメソッド
fold, get, getKey, minusKey
フィールドの詳細
Key
PropagationContextElementキー。
コンストラクターの詳細
PropagationContextElement
public PropagationContextElement()
方法の詳細
restoreThreadContext
public void restoreThreadContext(kotlin.coroutines.CoroutineContext context, io.micrometer.context.ContextSnapshot.Scope oldState) - 次で指定:
- インターフェース
kotlinx.coroutines.ThreadContextElement<io.micrometer.context.ContextSnapshot.Scope>内のrestoreThreadContext
updateThreadContext
public io.micrometer.context.ContextSnapshot.Scope updateThreadContext(kotlin.coroutines.CoroutineContext context) - 次で指定:
- インターフェース
kotlinx.coroutines.ThreadContextElement<io.micrometer.context.ContextSnapshot.Scope>内のupdateThreadContext