Skip to content

Commit a9a87f4

Browse files
authored
refactor!: track upstream observability API changes (#974)
Refactor observability (tracing) API and introduce an OTeL backed provider.
1 parent 38040c3 commit a9a87f4

35 files changed

+220
-105
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "5b1a8324-02da-4281-bd23-81c565eed973",
3+
"type": "misc",
4+
"description": "**BREAKING**: Refactor observability API and configuration. See the [discussion](https://github.com/awslabs/aws-sdk-kotlin/discussions/981) for more information."
5+
}

aws-runtime/aws-config/api/aws-config.api

Lines changed: 21 additions & 21 deletions
Large diffs are not rendered by default.

aws-runtime/aws-config/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ kotlin {
3636
dependencies {
3737
api(project(":aws-runtime:aws-core"))
3838
api("aws.smithy.kotlin:aws-credentials:$smithyKotlinVersion")
39-
implementation("aws.smithy.kotlin:logging:$smithyKotlinVersion")
4039
implementation("aws.smithy.kotlin:http:$smithyKotlinVersion")
4140
implementation("aws.smithy.kotlin:http-auth:$smithyKotlinVersion")
42-
implementation("aws.smithy.kotlin:tracing-core:$smithyKotlinVersion")
41+
implementation("aws.smithy.kotlin:telemetry-api:$smithyKotlinVersion")
4342
implementation("aws.smithy.kotlin:http-client-engine-default:$smithyKotlinVersion")
4443
implementation(project(":aws-runtime:aws-http"))
4544

@@ -56,6 +55,7 @@ kotlin {
5655
implementation("aws.smithy.kotlin:aws-signing-common:$smithyKotlinVersion")
5756
implementation("aws.smithy.kotlin:aws-signing-default:$smithyKotlinVersion")
5857
implementation("aws.smithy.kotlin:http-auth-aws:$smithyKotlinVersion")
58+
implementation("aws.smithy.kotlin:telemetry-defaults:$smithyKotlinVersion")
5959

6060
// additional dependencies required by generated sso provider(s)
6161
implementation("aws.smithy.kotlin:aws-json-protocols:$smithyKotlinVersion")

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/EcsCredentialsProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import aws.smithy.kotlin.runtime.retries.policy.RetryDirective
2929
import aws.smithy.kotlin.runtime.retries.policy.RetryErrorType
3030
import aws.smithy.kotlin.runtime.retries.policy.RetryPolicy
3131
import aws.smithy.kotlin.runtime.serde.json.JsonDeserializer
32+
import aws.smithy.kotlin.runtime.telemetry.logging.logger
3233
import aws.smithy.kotlin.runtime.time.TimestampFormat
3334
import aws.smithy.kotlin.runtime.util.Attributes
3435
import aws.smithy.kotlin.runtime.util.PlatformEnvironProvider
@@ -68,7 +69,7 @@ public class EcsCredentialsProvider internal constructor(
6869
private val manageEngine = httpClient == null
6970
private val httpClient = httpClient ?: DefaultHttpEngine()
7071
override suspend fun resolve(attributes: Attributes): Credentials {
71-
val logger = coroutineContext.getLogger<EcsCredentialsProvider>()
72+
val logger = coroutineContext.logger<EcsCredentialsProvider>()
7273
val authToken = AwsSdkSetting.AwsContainerAuthorizationToken.resolve(platformProvider)
7374
val relativeUri = AwsSdkSetting.AwsContainerCredentialsRelativeUri.resolve(platformProvider)
7475
val fullUri = AwsSdkSetting.AwsContainerCredentialsFullUri.resolve(platformProvider)
@@ -84,6 +85,7 @@ public class EcsCredentialsProvider internal constructor(
8485
deserializer = EcsCredentialsDeserializer()
8586
context {
8687
operationName = "EcsCredentialsProvider"
88+
serviceName = "EcsContainerMetadata"
8789
}
8890
execution.endpointResolver = EndpointResolver { Endpoint(url) }
8991
}

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/EnvironmentCredentialsProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package aws.sdk.kotlin.runtime.auth.credentials
88
import aws.sdk.kotlin.runtime.config.AwsSdkSetting
99
import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
1010
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
11-
import aws.smithy.kotlin.runtime.tracing.trace
11+
import aws.smithy.kotlin.runtime.telemetry.logging.trace
1212
import aws.smithy.kotlin.runtime.util.Attributes
1313
import aws.smithy.kotlin.runtime.util.PlatformProvider
1414
import kotlin.coroutines.coroutineContext

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ImdsCredentialsProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.DEFAULT_CREDENTIALS_REFRESH
1717
import aws.smithy.kotlin.runtime.config.resolve
1818
import aws.smithy.kotlin.runtime.http.HttpStatusCode
1919
import aws.smithy.kotlin.runtime.serde.json.JsonDeserializer
20+
import aws.smithy.kotlin.runtime.telemetry.logging.info
21+
import aws.smithy.kotlin.runtime.telemetry.logging.warn
2022
import aws.smithy.kotlin.runtime.time.Clock
2123
import aws.smithy.kotlin.runtime.time.Instant
22-
import aws.smithy.kotlin.runtime.tracing.info
23-
import aws.smithy.kotlin.runtime.tracing.warn
2424
import aws.smithy.kotlin.runtime.util.Attributes
2525
import aws.smithy.kotlin.runtime.util.PlatformEnvironProvider
2626
import aws.smithy.kotlin.runtime.util.PlatformProvider

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ProcessCredentialsProvider.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ package aws.sdk.kotlin.runtime.auth.credentials
77
import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
88
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
99
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException
10-
import aws.smithy.kotlin.runtime.logging.Logger
1110
import aws.smithy.kotlin.runtime.serde.json.JsonDeserializer
11+
import aws.smithy.kotlin.runtime.telemetry.logging.logger
1212
import aws.smithy.kotlin.runtime.time.Clock
1313
import aws.smithy.kotlin.runtime.time.Instant
1414
import aws.smithy.kotlin.runtime.util.Attributes
1515
import aws.smithy.kotlin.runtime.util.PlatformProvider
16+
import kotlin.coroutines.coroutineContext
1617

1718
internal expect suspend fun executeCommand(
1819
command: String,
@@ -48,7 +49,7 @@ public class ProcessCredentialsProvider(
4849
private val timeoutMillis: Long = 60_000,
4950
) : CredentialsProvider {
5051
override suspend fun resolve(attributes: Attributes): Credentials {
51-
val logger = Logger.getLogger<ProcessCredentialsProvider>()
52+
val logger = coroutineContext.logger<ProcessCredentialsProvider>()
5253

5354
val (exitCode, output) = try {
5455
executeCommand(credentialProcess, platformProvider, maxOutputLengthBytes, timeoutMillis)

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ProfileBearerTokenProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import aws.sdk.kotlin.runtime.config.profile.loadAwsSharedConfig
1414
import aws.smithy.kotlin.runtime.http.auth.BearerToken
1515
import aws.smithy.kotlin.runtime.http.auth.BearerTokenProvider
1616
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
17-
import aws.smithy.kotlin.runtime.http.operation.getLogger
17+
import aws.smithy.kotlin.runtime.telemetry.logging.logger
1818
import aws.smithy.kotlin.runtime.time.Clock
1919
import aws.smithy.kotlin.runtime.util.Attributes
2020
import aws.smithy.kotlin.runtime.util.PlatformProvider
@@ -64,7 +64,7 @@ internal class ProfileBearerTokenProvider(
6464
private val sharedConfig = asyncLazy { loadAwsSharedConfig(platformProvider, profileName) }
6565

6666
override suspend fun resolve(attributes: Attributes): BearerToken {
67-
val logger = coroutineContext.getLogger<ProfileBearerTokenProvider>()
67+
val logger = coroutineContext.logger<ProfileBearerTokenProvider>()
6868
val config = sharedConfig.get()
6969
logger.debug { "Loading bearer token from profile `${config.activeProfile.name}`" }
7070

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ProfileCredentialsProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.CloseableCredentialsProvide
1616
import aws.smithy.kotlin.runtime.auth.awscredentials.Credentials
1717
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
1818
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
19-
import aws.smithy.kotlin.runtime.http.operation.getLogger
2019
import aws.smithy.kotlin.runtime.io.closeIfCloseable
20+
import aws.smithy.kotlin.runtime.telemetry.logging.logger
2121
import aws.smithy.kotlin.runtime.time.TimestampFormat
2222
import aws.smithy.kotlin.runtime.util.Attributes
2323
import aws.smithy.kotlin.runtime.util.LazyAsyncValue
@@ -95,7 +95,7 @@ public class ProfileCredentialsProvider(
9595
)
9696

9797
override suspend fun resolve(attributes: Attributes): Credentials {
98-
val logger = coroutineContext.getLogger<ProfileCredentialsProvider>()
98+
val logger = coroutineContext.logger<ProfileCredentialsProvider>()
9999
val sharedConfig = loadAwsSharedConfig(platformProvider, profileName)
100100
logger.debug { "Loading credentials from profile `${sharedConfig.activeProfile.name}`" }
101101
val chain = ProfileChain.resolve(sharedConfig)

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/SsoCredentialsProvider.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
1212
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderException
1313
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
1414
import aws.smithy.kotlin.runtime.serde.json.*
15+
import aws.smithy.kotlin.runtime.telemetry.logging.logger
16+
import aws.smithy.kotlin.runtime.telemetry.telemetryProvider
1517
import aws.smithy.kotlin.runtime.time.Clock
1618
import aws.smithy.kotlin.runtime.time.Instant
1719
import aws.smithy.kotlin.runtime.time.fromEpochMilliseconds
18-
import aws.smithy.kotlin.runtime.tracing.*
1920
import aws.smithy.kotlin.runtime.util.*
2021
import kotlin.coroutines.coroutineContext
2122

@@ -106,8 +107,7 @@ public class SsoCredentialsProvider public constructor(
106107
}
107108

108109
override suspend fun resolve(attributes: Attributes): Credentials {
109-
val traceSpan = coroutineContext.traceSpan
110-
val logger = traceSpan.logger<SsoCredentialsProvider>()
110+
val logger = coroutineContext.logger<SsoCredentialsProvider>()
111111

112112
val token = if (ssoTokenProvider != null) {
113113
logger.trace { "Attempting to load token using token provider for sso-session: `$ssoSessionName`" }
@@ -117,10 +117,11 @@ public class SsoCredentialsProvider public constructor(
117117
legacyLoadTokenFile()
118118
}
119119

120+
val telemetry = coroutineContext.telemetryProvider
120121
val client = SsoClient {
121122
region = ssoRegion
122123
httpClient = this@SsoCredentialsProvider.httpClient
123-
tracer = traceSpan.asNestedTracer("SSO-")
124+
telemetryProvider = telemetry
124125
// FIXME - create an anonymous credential provider to explicitly avoid default chain creation (technically the transform should remove need for sigv4 cred provider since it's all anon auth)
125126
}
126127

0 commit comments

Comments
 (0)