Skip to content

Commit 5d211eb

Browse files
mxiamxiazzhlogin
andauthored
Add Bedrock contract tests. (#855)
* Add Bedrock contract tests. * address comments. * Address comments. * Delete un-useful text file * Clean up. * Addressing non-blocking comments. * Apply spotless. --------- Co-authored-by: Zhonghao Zhao <[email protected]>
1 parent faa9a08 commit 5d211eb

File tree

12 files changed

+1164
-7
lines changed

12 files changed

+1164
-7
lines changed

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

Lines changed: 491 additions & 2 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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ protected String getKinesisSpanNamePrefix() {
5757
return "Kinesis";
5858
}
5959

60+
protected String getBedrockSpanNamePrefix() {
61+
return "Bedrock";
62+
}
63+
64+
@Override
65+
protected String getBedrockAgentSpanNamePrefix() {
66+
return "AWSBedrockAgent";
67+
}
68+
69+
@Override
70+
protected String getBedrockRuntimeSpanNamePrefix() {
71+
return "BedrockRuntime";
72+
}
73+
74+
@Override
75+
protected String getBedrockAgentRuntimeSpanNamePrefix() {
76+
return "AWSBedrockAgentRuntime";
77+
}
78+
6079
protected String getS3RpcServiceName() {
6180
return "Amazon S3";
6281
}
@@ -75,6 +94,22 @@ protected String getKinesisRpcServiceName() {
7594
return "AmazonKinesis";
7695
}
7796

97+
protected String getBedrockRpcServiceName() {
98+
return "AmazonBedrock";
99+
}
100+
101+
protected String getBedrockAgentRpcServiceName() {
102+
return "AWSBedrockAgent";
103+
}
104+
105+
protected String getBedrockRuntimeRpcServiceName() {
106+
return "AmazonBedrockRuntime";
107+
}
108+
109+
protected String getBedrockAgentRuntimeRpcServiceName() {
110+
return "AWSBedrockAgentRuntime";
111+
}
112+
78113
@Test
79114
void testS3CreateBucket() throws Exception {
80115
doTestS3CreateBucket();
@@ -165,4 +200,39 @@ void testKinsesisError() throws Exception {
165200
void testKinesisFault() throws Exception {
166201
doTestKinesisFault();
167202
}
203+
204+
@Test
205+
void testBedrockAgentGetKnowledgeBaseId() {
206+
doTestBedrockAgentKnowledgeBaseId();
207+
}
208+
209+
@Test
210+
void testBedrockAgentAgentId() {
211+
doTestBedrockAgentAgentId();
212+
}
213+
214+
@Test
215+
void testBedrockAgentDataSourceId() {
216+
doTestBedrockAgentDataSourceId();
217+
}
218+
219+
@Test
220+
void testBedrockRuntimeModelId() {
221+
doTestBedrockRuntimeModelId();
222+
}
223+
224+
@Test
225+
void testBedrockGuardrailId() {
226+
doTestBedrockGuardrailId();
227+
}
228+
229+
@Test
230+
void testBedrockAgentRuntimeAgentId() {
231+
doTestBedrockAgentRuntimeAgentId();
232+
}
233+
234+
@Test
235+
void testBedrockAgentRuntimeKnowledgeBaseId() {
236+
doTestBedrockAgentRuntimeKnowledgeBaseId();
237+
}
168238
}

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,25 @@ protected String getKinesisSpanNamePrefix() {
5656
return "Kinesis";
5757
}
5858

59+
protected String getBedrockSpanNamePrefix() {
60+
return "Bedrock";
61+
}
62+
63+
@Override
64+
protected String getBedrockAgentSpanNamePrefix() {
65+
return "BedrockAgent";
66+
}
67+
68+
@Override
69+
protected String getBedrockRuntimeSpanNamePrefix() {
70+
return "BedrockRuntime";
71+
}
72+
73+
@Override
74+
protected String getBedrockAgentRuntimeSpanNamePrefix() {
75+
return "BedrockAgentRuntime";
76+
}
77+
5978
@Override
6079
protected String getS3RpcServiceName() {
6180
return "S3";
@@ -75,6 +94,26 @@ protected String getKinesisRpcServiceName() {
7594
return "Kinesis";
7695
}
7796

97+
@Override
98+
protected String getBedrockRpcServiceName() {
99+
return "Bedrock";
100+
}
101+
102+
@Override
103+
protected String getBedrockAgentRpcServiceName() {
104+
return "BedrockAgent";
105+
}
106+
107+
@Override
108+
protected String getBedrockRuntimeRpcServiceName() {
109+
return "BedrockRuntime";
110+
}
111+
112+
@Override
113+
protected String getBedrockAgentRuntimeRpcServiceName() {
114+
return "BedrockAgentRuntime";
115+
}
116+
78117
@Test
79118
void testS3CreateBucket() throws Exception {
80119
doTestS3CreateBucket();
@@ -164,4 +203,41 @@ void testKinesisError() throws Exception {
164203
void testKinesisFault() throws Exception {
165204
doTestKinesisFault();
166205
}
206+
207+
@Test
208+
void testBedrockAgentGetKnowlesgeBaseId() {
209+
doTestBedrockAgentKnowledgeBaseId();
210+
}
211+
212+
@Test
213+
void testBedrockAgentAgentId() {
214+
doTestBedrockAgentAgentId();
215+
}
216+
217+
@Test
218+
void testBedrockAgentDataSourceId() {
219+
doTestBedrockAgentDataSourceId();
220+
}
221+
222+
@Test
223+
void testBedrockRuntimeModelId() {
224+
doTestBedrockRuntimeModelId();
225+
}
226+
227+
@Test
228+
void testBedrockGuardrailId() {
229+
doTestBedrockGuardrailId();
230+
}
231+
232+
@Test
233+
void testBedrockAgentRuntimeAgentId() {
234+
doTestBedrockAgentRuntimeAgentId();
235+
}
236+
237+
// TODO: Enable testBedrockAgentRuntimeKnowledgeBaseId test after KnowledgeBaseId is supported in
238+
// OTEL BedrockAgentRuntime instrumentation
239+
// @Test
240+
// void testBedrockAgentRuntimeKnowledgeBaseId() {
241+
// doTestBedrockAgentRuntimeKnowledgeBaseId();
242+
// }
167243
}

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
@@ -58,6 +58,11 @@ public class SemanticConventionsConstants {
5858
public static final String AWS_QUEUE_URL = "aws.queue.url";
5959
public static final String AWS_QUEUE_NAME = "aws.queue.name";
6060
public static final String AWS_STREAM_NAME = "aws.stream.name";
61+
public static final String AWS_KNOWLEDGE_BASE_ID = "aws.bedrock.knowledge_base.id";
62+
public static final String AWS_DATA_SOURCE_ID = "aws.bedrock.data_source.id";
63+
public static final String AWS_AGENT_ID = "aws.bedrock.agent.id";
64+
public static final String AWS_GUARDRAIL_ID = "aws.bedrock.guardrail.id";
65+
public static final String GEN_AI_REQUEST_MODEL = "gen_ai.request.model";
6166

6267
// kafka
6368
public static final String MESSAGING_CLIENT_ID = "messaging.client_id";
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
plugins {
17+
`java-library`
18+
}
19+
20+
java {
21+
sourceCompatibility = JavaVersion.VERSION_11
22+
targetCompatibility = JavaVersion.VERSION_11
23+
}
24+
25+
dependencies {
26+
implementation("com.google.code.gson:gson:2.10.1")
27+
implementation("com.sparkjava:spark-core")
28+
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.3")
29+
}

0 commit comments

Comments
 (0)