クラス 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 は、スレッド上でコルーチンが再開された際に、Micrometer コンテキスト伝播ライブラリに登録されたコンテキストがキャプチャーされ、復元されることを保証します。これは通常、Kotlin の中断された関数における Micrometer トレースのサポートに使用されます。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