-
Notifications
You must be signed in to change notification settings - Fork 31
fix: include more info for retry token bucket capacity errors #1217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "id": "3456d00f-1b29-4d88-ab02-045db1b1ebce", | ||
| "type": "bugfix", | ||
| "description": "Include more information when retry strategy halts early due to capacity errors", | ||
| "issues": [ | ||
| "awslabs/aws-sdk-kotlin#1321" | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,41 @@ import aws.smithy.kotlin.runtime.collections.AttributeKey | |
| import aws.smithy.kotlin.runtime.collections.MutableAttributes | ||
| import aws.smithy.kotlin.runtime.collections.mutableAttributes | ||
|
|
||
| /** | ||
| * Describes additional context about an error which may be useful in client-side debugging. This information will be | ||
| * included in exception messages. This contrasts with [ErrorMetadata] which is not _necessarily_ included in messages | ||
| * and not _necessarily_ client-related. | ||
| * @param key A header or key for the information | ||
| * @param value A value for the information | ||
| */ | ||
| public class ClientErrorContext(public val key: String, public val value: String) { | ||
| override fun equals(other: Any?): Boolean { | ||
| if (this === other) return true | ||
| if (other == null || this::class != other::class) return false | ||
|
|
||
| other as ClientErrorContext | ||
|
|
||
| if (key != other.key) return false | ||
| if (value != other.value) return false | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| /** | ||
| * Gets a formatted representation of this error context suitable for inclusion in a message. This format is | ||
| * generally `"$key: $value"`. | ||
| */ | ||
| public val formatted: String = "$key: $value" | ||
|
|
||
| override fun hashCode(): Int { | ||
| var result = key.hashCode() | ||
| result = 31 * result + value.hashCode() | ||
| return result | ||
| } | ||
|
|
||
| override fun toString(): String = "ClientErrorContext(key='$key', value='$value')" | ||
| } | ||
|
|
||
| /** | ||
| * Additional metadata about an error | ||
| */ | ||
|
|
@@ -16,6 +51,12 @@ public open class ErrorMetadata { | |
| public val attributes: MutableAttributes = mutableAttributes() | ||
|
|
||
| public companion object { | ||
| /** | ||
| * Set if there are additional context elements about the error | ||
| */ | ||
| public val AdditionalClientContext: AttributeKey<List<ClientErrorContext>> = | ||
| AttributeKey("aws.smithy.kotlin#AdditionalClientContext") | ||
|
||
|
|
||
| /** | ||
| * Set if an error is retryable | ||
| */ | ||
|
|
@@ -32,6 +73,9 @@ public open class ErrorMetadata { | |
|
|
||
| public val isThrottling: Boolean | ||
| get() = attributes.getOrNull(ThrottlingError) ?: false | ||
|
|
||
| public val additionalClientContext: List<ClientErrorContext> | ||
| get() = attributes.getOrNull(AdditionalClientContext).orEmpty() | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -156,7 +200,7 @@ public open class ServiceException : SdkBaseException { | |
|
|
||
| public constructor(cause: Throwable?) : super(cause) | ||
|
|
||
| protected open val displayMetadata: List<String> | ||
| private val displayMetadata: List<String> | ||
| get() = buildList { | ||
| val serviceProvidedMessage = super.message ?: sdkErrorMetadata.errorMessage | ||
| if (serviceProvidedMessage == null) { | ||
|
|
@@ -166,7 +210,10 @@ public open class ServiceException : SdkBaseException { | |
| } else { | ||
| add(serviceProvidedMessage) | ||
| } | ||
|
|
||
| sdkErrorMetadata.requestId?.let { add("Request ID: $it") } | ||
|
|
||
| sdkErrorMetadata.additionalClientContext.mapTo(this@buildList) { it.formatted } | ||
| } | ||
|
|
||
| override val message: String | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
Include more information when retry strategy halts early due to **retry token bucket** capacity errorsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. 👍