@@ -44,7 +44,9 @@ public abstract class AwsSdkBaseTest extends ContractTestBase {
4444 LocalStackContainer .Service .DYNAMODB ,
4545 LocalStackContainer .Service .SQS ,
4646 LocalStackContainer .Service .KINESIS ,
47- LocalStackContainer .Service .SECRETSMANAGER )
47+ LocalStackContainer .Service .SECRETSMANAGER ,
48+ LocalStackContainer .Service .IAM ,
49+ LocalStackContainer .Service .STEPFUNCTIONS )
4850 .withEnv ("DEFAULT_REGION" , "us-west-2" )
4951 .withNetwork (network )
5052 .withEnv ("LOCALSTACK_HOST" , "127.0.0.1" )
@@ -106,6 +108,8 @@ protected String getApplicationWaitPattern() {
106108
107109 protected abstract String getSecretsManagerSpanNamePrefix ();
108110
111+ protected abstract String getStepFunctionsSpanNamePrefix ();
112+
109113 protected abstract String getS3RpcServiceName ();
110114
111115 protected abstract String getDynamoDbRpcServiceName ();
@@ -124,6 +128,8 @@ protected String getApplicationWaitPattern() {
124128
125129 protected abstract String getSecretsManagerRpcServiceName ();
126130
131+ protected abstract String getStepFunctionsRpcServiceName ();
132+
127133 private String getS3ServiceName () {
128134 return "AWS::S3" ;
129135 }
@@ -160,6 +166,8 @@ private String getSecretsManagerServiceName() {
160166 return "AWS::SecretsManager" ;
161167 }
162168
169+ private String getStepFunctionsServiceName () { return "AWS::StepFunctions" ; }
170+
163171 private String s3SpanName (String operation ) {
164172 return String .format ("%s.%s" , getS3SpanNamePrefix (), operation );
165173 }
@@ -196,6 +204,10 @@ private String secretsManagerSpanName(String operation) {
196204 return String .format ("%s.%s" , getSecretsManagerSpanNamePrefix (), operation );
197205 }
198206
207+ private String stepFunctionsSpanName (String operation ) {
208+ return String .format ("%s.%s" , getStepFunctionsSpanNamePrefix (), operation );
209+ }
210+
199211 protected ThrowingConsumer <KeyValue > assertAttribute (String key , String value ) {
200212 return (attribute ) -> {
201213 var actualKey = attribute .getKey ();
@@ -399,6 +411,7 @@ private void assertSpanAttributes(
399411 var spanAttributes = span .getAttributesList ();
400412 assertThat (span .getKind ()).isEqualTo (spanKind );
401413 assertThat (span .getName ()).isEqualTo (spanName );
414+
402415 assertSemanticConventionsAttributes (
403416 spanAttributes , rpcService , method , peerName , peerPort , url , statusCode );
404417 assertAwsAttributes (
@@ -2794,4 +2807,284 @@ protected void doTestSecretsManagerFault() throws Exception {
27942807 null ,
27952808 0.0 );
27962809 }
2810+
2811+ protected void doTestStepFunctionsDescribeStateMachine () throws Exception {
2812+ appClient .get ("/sfn/describestatemachine/test-state-machine" ).aggregate ().join ();
2813+ var traces = mockCollectorClient .getTraces ();
2814+ var metrics =
2815+ mockCollectorClient .getMetrics (
2816+ Set .of (
2817+ AppSignalsConstants .ERROR_METRIC ,
2818+ AppSignalsConstants .FAULT_METRIC ,
2819+ AppSignalsConstants .LATENCY_METRIC ));
2820+ var localService = getApplicationOtelServiceName ();
2821+ var localOperation = "GET /sfn/describestatemachine/:name" ;
2822+ var type = "AWS::StepFunctions::StateMachine" ;
2823+ var identifier = "test-state-machine" ;
2824+ var cloudformationIdentifier =
2825+ "arn:aws:states:us-west-2:000000000000:stateMachine:test-state-machine" ;
2826+
2827+ assertSpanClientAttributes (
2828+ traces ,
2829+ stepFunctionsSpanName ("DescribeStateMachine" ),
2830+ getStepFunctionsRpcServiceName (),
2831+ localService ,
2832+ localOperation ,
2833+ getStepFunctionsServiceName (),
2834+ "DescribeStateMachine" ,
2835+ type ,
2836+ identifier ,
2837+ cloudformationIdentifier ,
2838+ "localstack" ,
2839+ 4566 ,
2840+ "http://localstack:4566" ,
2841+ 200 ,
2842+ List .of (
2843+ assertAttribute (
2844+ SemanticConventionsConstants .AWS_STATE_MACHINE_ARN ,
2845+ "arn:aws:states:us-west-2:000000000000:stateMachine:test-state-machine" )));
2846+ assertMetricClientAttributes (
2847+ metrics ,
2848+ AppSignalsConstants .LATENCY_METRIC ,
2849+ localService ,
2850+ localOperation ,
2851+ getStepFunctionsServiceName (),
2852+ "DescribeStateMachine" ,
2853+ type ,
2854+ identifier ,
2855+ cloudformationIdentifier ,
2856+ 5000.0 );
2857+ assertMetricClientAttributes (
2858+ metrics ,
2859+ AppSignalsConstants .FAULT_METRIC ,
2860+ localService ,
2861+ localOperation ,
2862+ getStepFunctionsServiceName (),
2863+ "DescribeStateMachine" ,
2864+ type ,
2865+ identifier ,
2866+ cloudformationIdentifier ,
2867+ 0.0 );
2868+ assertMetricClientAttributes (
2869+ metrics ,
2870+ AppSignalsConstants .ERROR_METRIC ,
2871+ localService ,
2872+ localOperation ,
2873+ getStepFunctionsServiceName (),
2874+ "DescribeStateMachine" ,
2875+ type ,
2876+ identifier ,
2877+ cloudformationIdentifier ,
2878+ 0.0 );
2879+ }
2880+
2881+ protected void doTestStepFunctionsDescribeActivity () throws Exception {
2882+ appClient .get ("/sfn/describeactivity/test-activity" ).aggregate ().join ();
2883+ var traces = mockCollectorClient .getTraces ();
2884+ var metrics =
2885+ mockCollectorClient .getMetrics (
2886+ Set .of (
2887+ AppSignalsConstants .ERROR_METRIC ,
2888+ AppSignalsConstants .FAULT_METRIC ,
2889+ AppSignalsConstants .LATENCY_METRIC ));
2890+ var localService = getApplicationOtelServiceName ();
2891+ var localOperation = "GET /sfn/describeactivity/:name" ;
2892+ var type = "AWS::StepFunctions::Activity" ;
2893+ var identifier = "test-activity" ;
2894+ var cloudformationIdentifier = "arn:aws:states:us-west-2:000000000000:activity:test-activity" ;
2895+
2896+ assertSpanClientAttributes (
2897+ traces ,
2898+ stepFunctionsSpanName ("DescribeActivity" ),
2899+ getStepFunctionsRpcServiceName (),
2900+ localService ,
2901+ localOperation ,
2902+ getStepFunctionsServiceName (),
2903+ "DescribeActivity" ,
2904+ type ,
2905+ identifier ,
2906+ cloudformationIdentifier ,
2907+ "localstack" ,
2908+ 4566 ,
2909+ "http://localstack:4566" ,
2910+ 200 ,
2911+ List .of (
2912+ assertAttribute (
2913+ SemanticConventionsConstants .AWS_ACTIVITY_ARN ,
2914+ "arn:aws:states:us-west-2:000000000000:activity:test-activity" )));
2915+ assertMetricClientAttributes (
2916+ metrics ,
2917+ AppSignalsConstants .LATENCY_METRIC ,
2918+ localService ,
2919+ localOperation ,
2920+ getStepFunctionsServiceName (),
2921+ "DescribeActivity" ,
2922+ type ,
2923+ identifier ,
2924+ cloudformationIdentifier ,
2925+ 5000.0 );
2926+ assertMetricClientAttributes (
2927+ metrics ,
2928+ AppSignalsConstants .FAULT_METRIC ,
2929+ localService ,
2930+ localOperation ,
2931+ getStepFunctionsServiceName (),
2932+ "DescribeActivity" ,
2933+ type ,
2934+ identifier ,
2935+ cloudformationIdentifier ,
2936+ 0.0 );
2937+ assertMetricClientAttributes (
2938+ metrics ,
2939+ AppSignalsConstants .ERROR_METRIC ,
2940+ localService ,
2941+ localOperation ,
2942+ getStepFunctionsServiceName (),
2943+ "DescribeActivity" ,
2944+ type ,
2945+ identifier ,
2946+ cloudformationIdentifier ,
2947+ 0.0 );
2948+ }
2949+
2950+ protected void doTestStepFunctionsError () throws Exception {
2951+ appClient .get ("/sfn/error" ).aggregate ().join ();
2952+ var traces = mockCollectorClient .getTraces ();
2953+ var metrics =
2954+ mockCollectorClient .getMetrics (
2955+ Set .of (
2956+ AppSignalsConstants .ERROR_METRIC ,
2957+ AppSignalsConstants .FAULT_METRIC ,
2958+ AppSignalsConstants .LATENCY_METRIC ));
2959+
2960+ var localService = getApplicationOtelServiceName ();
2961+ var localOperation = "GET /sfn/error" ;
2962+ var type = "AWS::StepFunctions::Activity" ;
2963+ var identifier = "nonexistent-activity" ;
2964+ var cloudformationIdentifier =
2965+ "arn:aws:states:us-west-2:000000000000:activity:nonexistent-activity" ;
2966+
2967+ assertSpanClientAttributes (
2968+ traces ,
2969+ stepFunctionsSpanName ("DescribeActivity" ),
2970+ getStepFunctionsRpcServiceName (),
2971+ localService ,
2972+ localOperation ,
2973+ getStepFunctionsServiceName (),
2974+ "DescribeActivity" ,
2975+ type ,
2976+ identifier ,
2977+ cloudformationIdentifier ,
2978+ "error.test" ,
2979+ 8080 ,
2980+ "http://error.test:8080" ,
2981+ 400 ,
2982+ List .of (
2983+ assertAttribute (
2984+ SemanticConventionsConstants .AWS_ACTIVITY_ARN ,
2985+ "arn:aws:states:us-west-2:000000000000:activity:nonexistent-activity" )));
2986+ assertMetricClientAttributes (
2987+ metrics ,
2988+ AppSignalsConstants .LATENCY_METRIC ,
2989+ localService ,
2990+ localOperation ,
2991+ getStepFunctionsServiceName (),
2992+ "DescribeActivity" ,
2993+ type ,
2994+ identifier ,
2995+ cloudformationIdentifier ,
2996+ 5000.0 );
2997+ assertMetricClientAttributes (
2998+ metrics ,
2999+ AppSignalsConstants .FAULT_METRIC ,
3000+ localService ,
3001+ localOperation ,
3002+ getStepFunctionsServiceName (),
3003+ "DescribeActivity" ,
3004+ type ,
3005+ identifier ,
3006+ cloudformationIdentifier ,
3007+ 0.0 );
3008+ assertMetricClientAttributes (
3009+ metrics ,
3010+ AppSignalsConstants .ERROR_METRIC ,
3011+ localService ,
3012+ localOperation ,
3013+ getStepFunctionsServiceName (),
3014+ "DescribeActivity" ,
3015+ type ,
3016+ identifier ,
3017+ cloudformationIdentifier ,
3018+ 1.0 );
3019+ }
3020+
3021+ protected void doTestStepFunctionsFault () throws Exception {
3022+ appClient .get ("/sfn/fault" ).aggregate ().join ();
3023+ var traces = mockCollectorClient .getTraces ();
3024+ var metrics =
3025+ mockCollectorClient .getMetrics (
3026+ Set .of (
3027+ AppSignalsConstants .ERROR_METRIC ,
3028+ AppSignalsConstants .FAULT_METRIC ,
3029+ AppSignalsConstants .LATENCY_METRIC ));
3030+
3031+ var localService = getApplicationOtelServiceName ();
3032+ var localOperation = "GET /sfn/fault" ;
3033+ var type = "AWS::StepFunctions::Activity" ;
3034+ var identifier = "fault-activity" ;
3035+ var cloudformationIdentifier = "arn:aws:states:us-west-2:000000000000:activity:fault-activity" ;
3036+
3037+ assertSpanClientAttributes (
3038+ traces ,
3039+ stepFunctionsSpanName ("DescribeActivity" ),
3040+ getStepFunctionsRpcServiceName (),
3041+ localService ,
3042+ localOperation ,
3043+ getStepFunctionsServiceName (),
3044+ "DescribeActivity" ,
3045+ type ,
3046+ identifier ,
3047+ cloudformationIdentifier ,
3048+ "fault.test" ,
3049+ 8080 ,
3050+ "http://fault.test:8080" ,
3051+ 500 ,
3052+ List .of (
3053+ assertAttribute (
3054+ SemanticConventionsConstants .AWS_ACTIVITY_ARN ,
3055+ "arn:aws:states:us-west-2:000000000000:activity:fault-activity" )));
3056+ assertMetricClientAttributes (
3057+ metrics ,
3058+ AppSignalsConstants .LATENCY_METRIC ,
3059+ localService ,
3060+ localOperation ,
3061+ getStepFunctionsServiceName (),
3062+ "DescribeActivity" ,
3063+ type ,
3064+ identifier ,
3065+ cloudformationIdentifier ,
3066+ 5000.0 );
3067+ assertMetricClientAttributes (
3068+ metrics ,
3069+ AppSignalsConstants .FAULT_METRIC ,
3070+ localService ,
3071+ localOperation ,
3072+ getStepFunctionsServiceName (),
3073+ "DescribeActivity" ,
3074+ type ,
3075+ identifier ,
3076+ cloudformationIdentifier ,
3077+ 1.0 );
3078+ assertMetricClientAttributes (
3079+ metrics ,
3080+ AppSignalsConstants .ERROR_METRIC ,
3081+ localService ,
3082+ localOperation ,
3083+ getStepFunctionsServiceName (),
3084+ "DescribeActivity" ,
3085+ type ,
3086+ identifier ,
3087+ cloudformationIdentifier ,
3088+ 0.0 );
3089+ }
27973090}
0 commit comments