All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.smithy.kotlin.runtime.telemetry.context.TelemetryContextElement.kt Maven / Gradle / Ivy

There is a newer version: 1.3.23
Show newest version
/*
 * 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 kotlin.coroutines.CoroutineContext

/**
 * A [CoroutineContext] element that carries a telemetry [Context].
 * @param context The active context
 */
@InternalApi
public expect class TelemetryContextElement(context: Context) : CoroutineContext.Element {
    public companion object Key : CoroutineContext.Key

    public val context: Context
    override val key: CoroutineContext.Key<*>
    override fun  get(key: CoroutineContext.Key): E?
    override fun  fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R
    override fun plus(context: CoroutineContext): CoroutineContext
    override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext
}

/**
 * Extract the current telemetry [Context] from the coroutine context if available.
 */
@InternalApi
public val CoroutineContext.telemetryContext: Context?
    get() = get(TelemetryContextElement)?.context




© 2015 - 2024 Weber Informatics LLC | Privacy Policy