jvmMain.aws.smithy.kotlin.runtime.telemetry.context.TelemetryContextElementJVM.kt Maven / Gradle / Ivy
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.smithy.kotlin.runtime.telemetry.context
import aws.smithy.kotlin.runtime.InternalApi
import kotlinx.coroutines.ThreadContextElement
import kotlin.coroutines.AbstractCoroutineContextElement
import kotlin.coroutines.CoroutineContext
@InternalApi
public actual class TelemetryContextElement public actual constructor(
public actual val context: Context,
) : AbstractCoroutineContextElement(TelemetryContextElement),
CoroutineContext.Element,
ThreadContextElement {
public actual companion object Key : CoroutineContext.Key
override fun updateThreadContext(context: CoroutineContext): Scope =
this.context.makeCurrent()
override fun restoreThreadContext(context: CoroutineContext, oldState: Scope) {
oldState.close()
}
}