Skip to content

Commit c00d3af

Browse files
authored
Add Contract Tests for SecretsManager, StepFunctions, and SNS (#958)
*Description of changes:* Adding contract tests for new AWS resources. Rebasing the commits in this [PR](8295fb0) since there were some merge conflicts with Gen AI contract tests. *Test plan:* <img width="1512" alt="Screenshot 2024-11-25 at 9 16 39 PM" src="https://github.com/user-attachments/assets/0216bf71-f735-48c2-a63e-09a21e1262d7"> By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent aa84018 commit c00d3af

File tree

9 files changed

+1810
-7
lines changed

9 files changed

+1810
-7
lines changed

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/awssdk/base/AwsSdkBaseTest.java

Lines changed: 863 additions & 5 deletions
Large diffs are not rendered by default.

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/awssdk/v1/AwsSdkV1Test.java

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ protected String getBedrockAgentRuntimeSpanNamePrefix() {
7676
return "AWSBedrockAgentRuntime";
7777
}
7878

79+
@Override
80+
protected String getSecretsManagerSpanNamePrefix() {
81+
return "AWSSecretsManager";
82+
}
83+
84+
@Override
85+
protected String getStepFunctionsSpanNamePrefix() {
86+
return "AWSStepFunctions";
87+
}
88+
89+
@Override
90+
protected String getSnsSpanNamePrefix() {
91+
return "SNS";
92+
}
93+
7994
protected String getS3RpcServiceName() {
8095
return "Amazon S3";
8196
}
@@ -90,6 +105,21 @@ protected String getSqsRpcServiceName() {
90105
return "AmazonSQS";
91106
}
92107

108+
@Override
109+
protected String getSecretsManagerRpcServiceName() {
110+
return "AWSSecretsManager";
111+
}
112+
113+
@Override
114+
protected String getStepFunctionsRpcServiceName() {
115+
return "AWSStepFunctions";
116+
}
117+
118+
@Override
119+
protected String getSnsRpcServiceName() {
120+
return "AmazonSNS";
121+
}
122+
93123
protected String getKinesisRpcServiceName() {
94124
return "AmazonKinesis";
95125
}
@@ -260,4 +290,54 @@ void testBedrockAgentRuntimeAgentId() {
260290
void testBedrockAgentRuntimeKnowledgeBaseId() {
261291
doTestBedrockAgentRuntimeKnowledgeBaseId();
262292
}
293+
294+
@Test
295+
void testSecretsManagerDescribeSecret() throws Exception {
296+
doTestSecretsManagerDescribeSecret();
297+
}
298+
299+
@Test
300+
void testSecretsManagerError() throws Exception {
301+
doTestSecretsManagerError();
302+
}
303+
304+
@Test
305+
void testSecretsManagerFault() throws Exception {
306+
doTestSecretsManagerFault();
307+
}
308+
309+
@Test
310+
void testStepFunctionsDescribeStateMachine() throws Exception {
311+
doTestStepFunctionsDescribeStateMachine();
312+
}
313+
314+
@Test
315+
void testStepFunctionsDescribeActivity() throws Exception {
316+
doTestStepFunctionsDescribeActivity();
317+
}
318+
319+
@Test
320+
void testStepFunctionsError() throws Exception {
321+
doTestStepFunctionsError();
322+
}
323+
324+
@Test
325+
void testStepFunctionsFault() throws Exception {
326+
doTestStepFunctionsFault();
327+
}
328+
329+
@Test
330+
void testSnsGetTopicAttributes() throws Exception {
331+
doTestSnsGetTopicAttributes();
332+
}
333+
334+
@Test
335+
void testSnsError() throws Exception {
336+
doTestStepFunctionsError();
337+
}
338+
339+
@Test
340+
void testSnsFault() throws Exception {
341+
doTestStepFunctionsFault();
342+
}
263343
}

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/awssdk/v2/AwsSdkV2Test.java

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,21 @@ protected String getBedrockAgentRuntimeSpanNamePrefix() {
7575
return "BedrockAgentRuntime";
7676
}
7777

78+
@Override
79+
protected String getSecretsManagerSpanNamePrefix() {
80+
return "SecretsManager";
81+
}
82+
83+
@Override
84+
protected String getStepFunctionsSpanNamePrefix() {
85+
return "Sfn";
86+
}
87+
88+
@Override
89+
protected String getSnsSpanNamePrefix() {
90+
return "Sns";
91+
}
92+
7893
@Override
7994
protected String getS3RpcServiceName() {
8095
return "S3";
@@ -114,6 +129,21 @@ protected String getBedrockAgentRuntimeRpcServiceName() {
114129
return "BedrockAgentRuntime";
115130
}
116131

132+
@Override
133+
protected String getSecretsManagerRpcServiceName() {
134+
return "SecretsManager";
135+
}
136+
137+
@Override
138+
protected String getStepFunctionsRpcServiceName() {
139+
return "Sfn";
140+
}
141+
142+
@Override
143+
protected String getSnsRpcServiceName() {
144+
return "Sns";
145+
}
146+
117147
@Test
118148
void testS3CreateBucket() throws Exception {
119149
doTestS3CreateBucket();
@@ -259,10 +289,58 @@ void testBedrockAgentRuntimeAgentId() {
259289
doTestBedrockAgentRuntimeAgentId();
260290
}
261291

262-
// TODO: Enable testBedrockAgentRuntimeKnowledgeBaseId test after KnowledgeBaseId is supported in
263-
// OTEL BedrockAgentRuntime instrumentation
264292
@Test
265293
void testBedrockAgentRuntimeKnowledgeBaseId() {
266294
doTestBedrockAgentRuntimeKnowledgeBaseId();
267295
}
296+
297+
@Test
298+
void testSecretsManagerDescribeSecret() throws Exception {
299+
doTestSecretsManagerDescribeSecret();
300+
}
301+
302+
@Test
303+
void testSecretsManagerError() throws Exception {
304+
doTestSecretsManagerError();
305+
}
306+
307+
@Test
308+
void testSecretsManagerFault() throws Exception {
309+
doTestSecretsManagerFault();
310+
}
311+
312+
@Test
313+
void testStepFunctionsDescribeStateMachine() throws Exception {
314+
doTestStepFunctionsDescribeStateMachine();
315+
}
316+
317+
@Test
318+
void testStepFunctionsDescribeActivity() throws Exception {
319+
doTestStepFunctionsDescribeActivity();
320+
}
321+
322+
@Test
323+
void testStepFunctionsError() throws Exception {
324+
doTestStepFunctionsError();
325+
}
326+
327+
@Test
328+
void testStepFunctionsFault() throws Exception {
329+
doTestStepFunctionsFault();
330+
}
331+
332+
@Test
333+
void testSnsGetTopicAttributes() throws Exception {
334+
doTestSnsGetTopicAttributes();
335+
}
336+
337+
@Test
338+
void testSnsError() throws Exception {
339+
doTestStepFunctionsError();
340+
}
341+
342+
@Test
343+
void testSnsFault() throws Exception {
344+
doTestStepFunctionsFault();
345+
}
268346
}

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/utils/AppSignalsConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class AppSignalsConstants {
3131
public static final String AWS_REMOTE_OPERATION = "aws.remote.operation";
3232
public static final String AWS_REMOTE_RESOURCE_TYPE = "aws.remote.resource.type";
3333
public static final String AWS_REMOTE_RESOURCE_IDENTIFIER = "aws.remote.resource.identifier";
34+
public static final String AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER =
35+
"aws.remote.resource.cfn.primary.identifier";
3436
public static final String AWS_SPAN_KIND = "aws.span.kind";
3537
public static final String AWS_REMOTE_DB_USER = "aws.remote.db.user";
3638

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/utils/SemanticConventionsConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,18 @@ public class SemanticConventionsConstants {
6262
public static final String AWS_DATA_SOURCE_ID = "aws.bedrock.data_source.id";
6363
public static final String AWS_AGENT_ID = "aws.bedrock.agent.id";
6464
public static final String AWS_GUARDRAIL_ID = "aws.bedrock.guardrail.id";
65+
public static final String AWS_GUARDRAIL_ARN = "aws.bedrock.guardrail.arn";
6566
public static final String GEN_AI_REQUEST_MODEL = "gen_ai.request.model";
6667
public static final String GEN_AI_REQUEST_MAX_TOKENS = "gen_ai.request.max_tokens";
6768
public static final String GEN_AI_REQUEST_TEMPERATURE = "gen_ai.request.temperature";
6869
public static final String GEN_AI_REQUEST_TOP_P = "gen_ai.request.top_p";
6970
public static final String GEN_AI_RESPONSE_FINISH_REASONS = "gen_ai.response.finish_reasons";
7071
public static final String GEN_AI_USAGE_INPUT_TOKENS = "gen_ai.usage.input_tokens";
7172
public static final String GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens";
73+
public static final String AWS_SECRET_ARN = "aws.secretsmanager.secret.arn";
74+
public static final String AWS_STATE_MACHINE_ARN = "aws.stepfunctions.state_machine.arn";
75+
public static final String AWS_ACTIVITY_ARN = "aws.stepfunctions.activity.arn";
76+
public static final String AWS_TOPIC_ARN = "aws.sns.topic.arn";
7277

7378
// kafka
7479
public static final String MESSAGING_CLIENT_ID = "messaging.client_id";

appsignals-tests/images/aws-sdk/aws-sdk-v1/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ dependencies {
3333
implementation("com.amazonaws:aws-java-sdk-dynamodb")
3434
implementation("com.amazonaws:aws-java-sdk-sqs")
3535
implementation("com.amazonaws:aws-java-sdk-kinesis")
36+
implementation("com.amazonaws:aws-java-sdk-secretsmanager")
37+
implementation("com.amazonaws:aws-java-sdk-iam")
38+
implementation("com.amazonaws:aws-java-sdk-stepfunctions")
39+
implementation("com.amazonaws:aws-java-sdk-sns")
3640
implementation("com.amazonaws:aws-java-sdk-bedrock")
3741
implementation("com.amazonaws:aws-java-sdk-bedrockagent")
3842
implementation("com.amazonaws:aws-java-sdk-bedrockruntime")

0 commit comments

Comments
 (0)