Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
6 changes: 6 additions & 0 deletions .changes/next-release/feature-AWSSDKforJavav2-ee91960.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "AWS SDK for Java v2",
"contributor": "",
"description": "Add business metrics support for RPC v2 CBOR protocol to track smithy rpcv2 cbor protocol usage."
}
Original file line number Diff line number Diff line change
Expand Up @@ -1170,4 +1170,4 @@ private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(Base
public void close() {
clientHandler.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import software.amazon.awssdk.awscore.util.SignerOverrideUtils;
import software.amazon.awssdk.core.HttpChecksumConstant;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkProtocolMetadata;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.SdkResponse;
import software.amazon.awssdk.core.SelectedAuthScheme;
Expand All @@ -56,6 +57,7 @@
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.core.useragent.AdditionalMetadata;
import software.amazon.awssdk.core.useragent.BusinessMetricCollection;
import software.amazon.awssdk.core.useragent.BusinessMetricFeatureId;
import software.amazon.awssdk.endpoints.EndpointProvider;
import software.amazon.awssdk.http.ContentStreamProvider;
import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme;
Expand Down Expand Up @@ -133,7 +135,8 @@ private AwsExecutionContextBuilder() {
clientConfig.option(SdkClientOption.REQUEST_CHECKSUM_CALCULATION))
.putAttribute(SdkInternalExecutionAttribute.RESPONSE_CHECKSUM_VALIDATION,
clientConfig.option(SdkClientOption.RESPONSE_CHECKSUM_VALIDATION))
.putAttribute(SdkInternalExecutionAttribute.BUSINESS_METRICS, resolveUserAgentBusinessMetrics(clientConfig))
.putAttribute(SdkInternalExecutionAttribute.BUSINESS_METRICS,
resolveUserAgentBusinessMetrics(clientConfig, executionParams))
.putAttribute(AwsExecutionAttribute.AWS_SIGV4A_SIGNING_REGION_SET,
clientConfig.option(AwsClientOption.AWS_SIGV4A_SIGNING_REGION_SET));

Expand Down Expand Up @@ -350,11 +353,23 @@ private static EndpointProvider resolveEndpointProvider(SdkRequest request,
.orElse(clientConfig.option(SdkClientOption.ENDPOINT_PROVIDER));
}

private static BusinessMetricCollection resolveUserAgentBusinessMetrics(SdkClientConfiguration clientConfig) {
private static <InputT extends SdkRequest, OutputT extends SdkResponse> BusinessMetricCollection
resolveUserAgentBusinessMetrics(SdkClientConfiguration clientConfig,
ClientExecutionParams<InputT, OutputT> executionParams) {
BusinessMetricCollection businessMetrics = new BusinessMetricCollection();
Optional<String> retryModeMetric = resolveRetryMode(clientConfig.option(RETRY_POLICY),
clientConfig.option(RETRY_STRATEGY));
retryModeMetric.ifPresent(businessMetrics::addMetric);

if (isRpcV2CborProtocol(executionParams.getProtocolMetadata())) {
businessMetrics.addMetric(BusinessMetricFeatureId.PROTOCOL_RPC_V2_CBOR.value());
}

return businessMetrics;
}

private static boolean isRpcV2CborProtocol(SdkProtocolMetadata protocolMetadata) {
return protocolMetadata != null &&
"smithy-rpc-v2-cbor".equals(protocolMetadata.serviceProtocol());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* An enum class representing a short form of identity providers to record in the UA string.
*
* Unimplemented metrics: I,J,K,M,O,S,U-c
* Unimplemented metrics: I,J,K,O,S,U-c
* Unsupported metrics (these will never be added): A,H
*/
@SdkProtectedApi
Expand All @@ -35,6 +35,7 @@ public enum BusinessMetricFeatureId {
RETRY_MODE_ADAPTIVE("F"),
S3_TRANSFER("G"),
GZIP_REQUEST_COMPRESSION("L"), //TODO(metrics): Not working, compression happens after header
PROTOCOL_RPC_V2_CBOR("M"),
ENDPOINT_OVERRIDE("N"),
ACCOUNT_ID_MODE_PREFERRED("P"),
ACCOUNT_ID_MODE_DISABLED("Q"),
Expand Down
6 changes: 6 additions & 0 deletions test/codegen-generated-classes-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>smithy-rpcv2-protocol</artifactId>
<version>${awsjavasdk.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"enableGenerateCompiledEndpointRules": true,
"skipEndpointTestGeneration": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "1.3",
"parameters": {
"Region": {
"builtIn": "AWS::Region",
"required": true,
"documentation": "The AWS region used to dispatch the request.",
"type": "String"
}
},
"rules": [
{
"conditions": [],
"endpoint": {
"url": "http://localhost/",
"properties": {
"authSchemes": [
{
"name": "sigv4",
"signingRegion": "{Region}",
"signingName": "jsonrpc"
}
]
},
"headers": {}
},
"type": "endpoint"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"testCases": [
],
"version": "1.0"
}
Loading
Loading