|
15 | 15 | import static io.opentelemetry.semconv.UrlAttributes.URL_FULL;
|
16 | 16 | import static io.opentelemetry.semconv.incubating.AwsIncubatingAttributes.AWS_REQUEST_ID;
|
17 | 17 | import static io.opentelemetry.semconv.incubating.AwsIncubatingAttributes.AWS_SECRETSMANAGER_SECRET_ARN;
|
| 18 | +import static io.opentelemetry.semconv.incubating.AwsIncubatingAttributes.AWS_STEP_FUNCTIONS_ACTIVITY_ARN; |
| 19 | +import static io.opentelemetry.semconv.incubating.AwsIncubatingAttributes.AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN; |
18 | 20 | import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME;
|
19 | 21 | import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID;
|
20 | 22 | import static io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes.MESSAGING_OPERATION;
|
|
86 | 88 | import software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder;
|
87 | 89 | import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueRequest;
|
88 | 90 | import software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse;
|
| 91 | +import software.amazon.awssdk.services.sfn.SfnAsyncClient; |
| 92 | +import software.amazon.awssdk.services.sfn.SfnAsyncClientBuilder; |
| 93 | +import software.amazon.awssdk.services.sfn.SfnClient; |
| 94 | +import software.amazon.awssdk.services.sfn.SfnClientBuilder; |
| 95 | +import software.amazon.awssdk.services.sfn.model.DescribeActivityRequest; |
| 96 | +import software.amazon.awssdk.services.sfn.model.DescribeStateMachineRequest; |
89 | 97 | import software.amazon.awssdk.services.sns.SnsAsyncClient;
|
90 | 98 | import software.amazon.awssdk.services.sns.SnsAsyncClientBuilder;
|
91 | 99 | import software.amazon.awssdk.services.sns.SnsClient;
|
@@ -233,6 +241,14 @@ private void clientAssertions(
|
233 | 241 | equalTo(MESSAGING_SYSTEM, AWS_SQS))));
|
234 | 242 | }
|
235 | 243 |
|
| 244 | + if (service.equals("Sfn")) { |
| 245 | + if (operation.equals("DescribeStateMachine")) { |
| 246 | + attributes.add(equalTo(AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN, "state:machine:arn:foo")); |
| 247 | + } else if (operation.equals("DescribeActivity")) { |
| 248 | + attributes.add(equalTo(AWS_STEP_FUNCTIONS_ACTIVITY_ARN, "activity:arn:foo")); |
| 249 | + } |
| 250 | + } |
| 251 | + |
236 | 252 | if (service.equals("SecretsManager")) {
|
237 | 253 | attributes.add(
|
238 | 254 | equalTo(
|
@@ -749,6 +765,86 @@ void testS3ListNullBucket() {
|
749 | 765 | assertThat(Context.current()).isEqualTo(Context.root());
|
750 | 766 | }
|
751 | 767 |
|
| 768 | + private static Stream<Arguments> provideStepFunctionsArguments() { |
| 769 | + return Stream.of( |
| 770 | + Arguments.of( |
| 771 | + (Function<SfnClient, Object>) |
| 772 | + c -> |
| 773 | + c.describeStateMachine( |
| 774 | + DescribeStateMachineRequest.builder() |
| 775 | + .stateMachineArn("state:machine:arn:foo") |
| 776 | + .build()), |
| 777 | + "DescribeStateMachine", |
| 778 | + "POST", |
| 779 | + "UNKNOWN"), |
| 780 | + Arguments.of( |
| 781 | + (Function<SfnClient, Object>) |
| 782 | + c -> |
| 783 | + c.describeActivity( |
| 784 | + DescribeActivityRequest.builder().activityArn("activity:arn:foo").build()), |
| 785 | + "DescribeActivity", |
| 786 | + "POST", |
| 787 | + "UNKNOWN")); |
| 788 | + } |
| 789 | + |
| 790 | + @ParameterizedTest |
| 791 | + @MethodSource("provideStepFunctionsArguments") |
| 792 | + void testSfnSendOperationRequestWithBuilder( |
| 793 | + Function<SfnClient, Object> call, String operation, String method, String requestId) { |
| 794 | + SfnClientBuilder builder = SfnClient.builder(); |
| 795 | + configureSdkClient(builder); |
| 796 | + SfnClient client = |
| 797 | + builder |
| 798 | + .endpointOverride(clientUri) |
| 799 | + .region(Region.AP_NORTHEAST_1) |
| 800 | + .credentialsProvider(CREDENTIALS_PROVIDER) |
| 801 | + .build(); |
| 802 | + |
| 803 | + server.enqueue(HttpResponse.of(HttpStatus.OK, MediaType.PLAIN_TEXT_UTF_8, "")); |
| 804 | + Object response = call.apply(client); |
| 805 | + assertThat(response.getClass().getSimpleName()) |
| 806 | + .satisfiesAnyOf( |
| 807 | + v -> |
| 808 | + assertThat(response) |
| 809 | + .isInstanceOf( |
| 810 | + software.amazon.awssdk.services.sfn.model.DescribeActivityResponse.class), |
| 811 | + v -> |
| 812 | + assertThat(response) |
| 813 | + .isInstanceOf( |
| 814 | + software.amazon.awssdk.services.sfn.model.DescribeStateMachineResponse |
| 815 | + .class)); |
| 816 | + clientAssertions("Sfn", operation, method, response, requestId); |
| 817 | + } |
| 818 | + |
| 819 | + @ParameterizedTest |
| 820 | + @MethodSource("provideStepFunctionsArguments") |
| 821 | + void testSfnAsyncSendOperationRequestWithBuilder( |
| 822 | + Function<SfnClient, Object> call, String operation, String method, String requestId) { |
| 823 | + SfnAsyncClientBuilder builder = SfnAsyncClient.builder(); |
| 824 | + configureSdkClient(builder); |
| 825 | + SfnAsyncClient client = |
| 826 | + builder |
| 827 | + .endpointOverride(clientUri) |
| 828 | + .region(Region.AP_NORTHEAST_1) |
| 829 | + .credentialsProvider(CREDENTIALS_PROVIDER) |
| 830 | + .build(); |
| 831 | + |
| 832 | + server.enqueue(HttpResponse.of(HttpStatus.OK, MediaType.PLAIN_TEXT_UTF_8, "")); |
| 833 | + Object response = call.apply(wrapClient(SfnClient.class, SfnAsyncClient.class, client)); |
| 834 | + assertThat(response.getClass().getSimpleName()) |
| 835 | + .satisfiesAnyOf( |
| 836 | + v -> |
| 837 | + assertThat(response) |
| 838 | + .isInstanceOf( |
| 839 | + software.amazon.awssdk.services.sfn.model.DescribeActivityResponse.class), |
| 840 | + v -> |
| 841 | + assertThat(response) |
| 842 | + .isInstanceOf( |
| 843 | + software.amazon.awssdk.services.sfn.model.DescribeStateMachineResponse |
| 844 | + .class)); |
| 845 | + clientAssertions("Sfn", operation, method, response, requestId); |
| 846 | + } |
| 847 | + |
752 | 848 | @Test
|
753 | 849 | void testSecretsManagerSendOperationRequestWithBuilder() {
|
754 | 850 | SecretsManagerClientBuilder builder = SecretsManagerClient.builder();
|
|
0 commit comments