Skip to content
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

feat: surface HTTP connection manager metrics #88

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/11a891eb-b51f-4508-9010-f17d35ce96a3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "11a891eb-b51f-4508-9010-f17d35ce96a3",
"type": "feature",
"description": "Surface HTTP connection manager metrics",
"issues": [
"awslabs/smithy-kotlin#893"
]
}
16 changes: 16 additions & 0 deletions aws-crt-kotlin/api/android/aws-crt-kotlin.api
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ public final class aws/sdk/kotlin/crt/http/HttpClientConnectionManager : aws/sdk
public fun <init> (Laws/sdk/kotlin/crt/http/HttpClientConnectionManagerOptions;)V
public final fun acquireConnection (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun close ()V
public final fun getManagerMetrics ()Laws/sdk/kotlin/crt/http/HttpManagerMetrics;
public final fun getOptions ()Laws/sdk/kotlin/crt/http/HttpClientConnectionManagerOptions;
public final fun releaseConnection (Laws/sdk/kotlin/crt/http/HttpClientConnection;)V
public fun waitForShutdown (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -527,6 +528,21 @@ public final class aws/sdk/kotlin/crt/http/HttpHeaderBlock : java/lang/Enum {
public static fun values ()[Laws/sdk/kotlin/crt/http/HttpHeaderBlock;
}

public final class aws/sdk/kotlin/crt/http/HttpManagerMetrics {
public fun <init> (JJJ)V
public final fun component1 ()J
public final fun component2 ()J
public final fun component3 ()J
public final fun copy (JJJ)Laws/sdk/kotlin/crt/http/HttpManagerMetrics;
public static synthetic fun copy$default (Laws/sdk/kotlin/crt/http/HttpManagerMetrics;JJJILjava/lang/Object;)Laws/sdk/kotlin/crt/http/HttpManagerMetrics;
public fun equals (Ljava/lang/Object;)Z
public final fun getAvailableConcurrency ()J
public final fun getLeasedConcurrency ()J
public final fun getPendingConcurrencyAcquires ()J
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class aws/sdk/kotlin/crt/http/HttpMonitoringOptions {
public fun <init> ()V
public fun <init> (II)V
Expand Down
16 changes: 16 additions & 0 deletions aws-crt-kotlin/api/jvm/aws-crt-kotlin.api
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ public final class aws/sdk/kotlin/crt/http/HttpClientConnectionManager : aws/sdk
public fun <init> (Laws/sdk/kotlin/crt/http/HttpClientConnectionManagerOptions;)V
public final fun acquireConnection (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun close ()V
public final fun getManagerMetrics ()Laws/sdk/kotlin/crt/http/HttpManagerMetrics;
public final fun getOptions ()Laws/sdk/kotlin/crt/http/HttpClientConnectionManagerOptions;
public final fun releaseConnection (Laws/sdk/kotlin/crt/http/HttpClientConnection;)V
public fun waitForShutdown (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -527,6 +528,21 @@ public final class aws/sdk/kotlin/crt/http/HttpHeaderBlock : java/lang/Enum {
public static fun values ()[Laws/sdk/kotlin/crt/http/HttpHeaderBlock;
}

public final class aws/sdk/kotlin/crt/http/HttpManagerMetrics {
public fun <init> (JJJ)V
public final fun component1 ()J
public final fun component2 ()J
public final fun component3 ()J
public final fun copy (JJJ)Laws/sdk/kotlin/crt/http/HttpManagerMetrics;
public static synthetic fun copy$default (Laws/sdk/kotlin/crt/http/HttpManagerMetrics;JJJILjava/lang/Object;)Laws/sdk/kotlin/crt/http/HttpManagerMetrics;
public fun equals (Ljava/lang/Object;)Z
public final fun getAvailableConcurrency ()J
public final fun getLeasedConcurrency ()J
public final fun getPendingConcurrencyAcquires ()J
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class aws/sdk/kotlin/crt/http/HttpMonitoringOptions {
public fun <init> ()V
public fun <init> (II)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import aws.sdk.kotlin.crt.Closeable
public expect class HttpClientConnectionManager(options: HttpClientConnectionManagerOptions) :
Closeable,
AsyncShutdown {
/**
* The active metrics for this connection manager
*/
public val managerMetrics: HttpManagerMetrics
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Wouldn't metrics suffice here given it's namespaced under HttpClientConnectionManager

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to other Java→Kotlin mapping classes, I chose to keep this the same as the underlying property. If you feel strongly I can change it to be simpler (which I would generally prefer when not mapping existing classes).


/**
* The options this manager was configured with
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.crt.http

public data class HttpManagerMetrics(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Are these connection manager metrics? If so HttpManager seems ambiguous and should probably be HttpConnectionManagerMetrics or HttpConnectionMetrics

fix: Missing docs on these metrics. I know they are meant to match SRA but probably should document them still and any differences/quirks that may lie herein.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to other Java→Kotlin mapping classes, I chose to keep this the same as the underlying class. If you feel strongly I can change it to be clearer (which I would generally prefer when not mapping existing classes).

public val availableConcurrency: Long,
public val pendingConcurrencyAcquires: Long,
public val leasedConcurrency: Long,
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public actual class HttpClientConnectionManager actual constructor(

private val jniManager = HttpClientConnectionManagerJni.create(options.into())

public actual val managerMetrics: HttpManagerMetrics
get() {
val jniMetrics = jniManager.managerMetrics
return HttpManagerMetrics(
availableConcurrency = jniMetrics.availableConcurrency,
pendingConcurrencyAcquires = jniMetrics.pendingConcurrencyAcquires,
leasedConcurrency = jniMetrics.leasedConcurrency,
)
}

/**
* Request an HttpClientConnection from the pool
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import aws.sdk.kotlin.crt.Closeable
public actual class HttpClientConnectionManager actual constructor(
public actual val options: HttpClientConnectionManagerOptions,
) : Closeable, AsyncShutdown {
public actual val managerMetrics: HttpManagerMetrics
get() = TODO("Not yet implemented")

/**
* Request an HttpClientConnection from the pool
*/
Expand Down
Loading