-
Notifications
You must be signed in to change notification settings - Fork 64
AWS SDK v1.11 Patch Migration #1117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
195ee97
added patched logic and updated README.md
anahatAWS 54e7c98
Added documentation and fixed spacing
anahatAWS cf3e176
added commands to run groovy tests and updated code for consistency
anahatAWS a71957d
added comments and attributions
anahatAWS d61133a
Merge branch 'aws-observability:main' into spi-1.11-patch
anahatAWS 83f1b82
Merge branch 'main' into spi-1.11-patch
thpierce 8998ec3
Resolve merge conflicts and update AdotAwsSdkTracingRequestHandler
anahatAWS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thpierce marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
...e/amazon/opentelemetry/javaagent/instrumentation/awssdk_v1_11/AwsBedrockResourceType.java
thpierce marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v1_11; | ||
|
||
import static software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v1_11.AwsExperimentalAttributes.AWS_AGENT_ID; | ||
import static software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v1_11.AwsExperimentalAttributes.AWS_DATA_SOURCE_ID; | ||
import static software.amazon.opentelemetry.javaagent.instrumentation.awssdk_v1_11.AwsExperimentalAttributes.AWS_KNOWLEDGE_BASE_ID; | ||
|
||
import io.opentelemetry.api.common.AttributeKey; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
|
||
enum AwsBedrockResourceType { | ||
AGENT_TYPE(AWS_AGENT_ID, RequestAccess::getAgentId), | ||
DATA_SOURCE_TYPE(AWS_DATA_SOURCE_ID, RequestAccess::getDataSourceId), | ||
KNOWLEDGE_BASE_TYPE(AWS_KNOWLEDGE_BASE_ID, RequestAccess::getKnowledgeBaseId); | ||
|
||
@SuppressWarnings("ImmutableEnumChecker") | ||
private final AttributeKey<String> keyAttribute; | ||
|
||
@SuppressWarnings("ImmutableEnumChecker") | ||
private final Function<Object, String> attributeValueAccessor; | ||
|
||
AwsBedrockResourceType( | ||
AttributeKey<String> keyAttribute, Function<Object, String> attributeValueAccessor) { | ||
this.keyAttribute = keyAttribute; | ||
this.attributeValueAccessor = attributeValueAccessor; | ||
} | ||
|
||
public AttributeKey<String> getKeyAttribute() { | ||
return keyAttribute; | ||
} | ||
|
||
public Function<Object, String> getAttributeValueAccessor() { | ||
return attributeValueAccessor; | ||
} | ||
|
||
public static AwsBedrockResourceType getRequestType(String requestClass) { | ||
return AwsBedrockResourceTypeMap.BEDROCK_REQUEST_MAP.get(requestClass); | ||
} | ||
|
||
public static AwsBedrockResourceType getResponseType(String responseClass) { | ||
return AwsBedrockResourceTypeMap.BEDROCK_RESPONSE_MAP.get(responseClass); | ||
} | ||
|
||
private static class AwsBedrockResourceTypeMap { | ||
private static final Map<String, AwsBedrockResourceType> BEDROCK_REQUEST_MAP = new HashMap<>(); | ||
private static final Map<String, AwsBedrockResourceType> BEDROCK_RESPONSE_MAP = new HashMap<>(); | ||
|
||
// Bedrock request/response mapping | ||
// We only support operations that are related to the resource and where the context contains | ||
// the AgentID/DataSourceID/KnowledgeBaseID. | ||
// AgentID | ||
private static final List<String> agentRequestClasses = | ||
Arrays.asList( | ||
"CreateAgentActionGroupRequest", | ||
"CreateAgentAliasRequest", | ||
"DeleteAgentActionGroupRequest", | ||
"DeleteAgentAliasRequest", | ||
"DeleteAgentRequest", | ||
"DeleteAgentVersionRequest", | ||
"GetAgentActionGroupRequest", | ||
"GetAgentAliasRequest", | ||
"GetAgentRequest", | ||
"GetAgentVersionRequest", | ||
"ListAgentActionGroupsRequest", | ||
"ListAgentAliasesRequest", | ||
"ListAgentKnowledgeBasesRequest", | ||
"ListAgentVersionsRequest", | ||
"PrepareAgentRequest", | ||
"UpdateAgentActionGroupRequest", | ||
"UpdateAgentAliasRequest", | ||
"UpdateAgentRequest"); | ||
private static final List<String> agentResponseClasses = | ||
Arrays.asList( | ||
"DeleteAgentAliasResult", | ||
"DeleteAgentResult", | ||
"DeleteAgentVersionResult", | ||
"PrepareAgentResult"); | ||
// DataSourceID | ||
private static final List<String> dataSourceRequestClasses = | ||
Arrays.asList("DeleteDataSourceRequest", "GetDataSourceRequest", "UpdateDataSourceRequest"); | ||
private static final List<String> dataSourceResponseClasses = | ||
Arrays.asList("DeleteDataSourceResult"); | ||
// KnowledgeBaseID | ||
private static final List<String> knowledgeBaseRequestClasses = | ||
Arrays.asList( | ||
"AssociateAgentKnowledgeBaseRequest", | ||
"CreateDataSourceRequest", | ||
"DeleteKnowledgeBaseRequest", | ||
"DisassociateAgentKnowledgeBaseRequest", | ||
"GetAgentKnowledgeBaseRequest", | ||
"GetKnowledgeBaseRequest", | ||
"ListDataSourcesRequest", | ||
"UpdateAgentKnowledgeBaseRequest"); | ||
private static final List<String> knowledgeBaseResponseClasses = | ||
Arrays.asList("DeleteKnowledgeBaseResult"); | ||
|
||
private AwsBedrockResourceTypeMap() {} | ||
|
||
static { | ||
// Populate the BEDROCK_REQUEST_MAP | ||
for (String agentRequestClass : agentRequestClasses) { | ||
BEDROCK_REQUEST_MAP.put(agentRequestClass, AwsBedrockResourceType.AGENT_TYPE); | ||
} | ||
for (String dataSourceRequestClass : dataSourceRequestClasses) { | ||
BEDROCK_REQUEST_MAP.put(dataSourceRequestClass, AwsBedrockResourceType.DATA_SOURCE_TYPE); | ||
} | ||
for (String knowledgeBaseRequestClass : knowledgeBaseRequestClasses) { | ||
BEDROCK_REQUEST_MAP.put( | ||
knowledgeBaseRequestClass, AwsBedrockResourceType.KNOWLEDGE_BASE_TYPE); | ||
} | ||
|
||
// Populate the BEDROCK_RESPONSE_MAP | ||
for (String agentResponseClass : agentResponseClasses) { | ||
BEDROCK_REQUEST_MAP.put(agentResponseClass, AwsBedrockResourceType.AGENT_TYPE); | ||
} | ||
for (String dataSourceResponseClass : dataSourceResponseClasses) { | ||
BEDROCK_REQUEST_MAP.put(dataSourceResponseClass, AwsBedrockResourceType.DATA_SOURCE_TYPE); | ||
} | ||
for (String knowledgeBaseResponseClass : knowledgeBaseResponseClasses) { | ||
BEDROCK_REQUEST_MAP.put( | ||
knowledgeBaseResponseClass, AwsBedrockResourceType.KNOWLEDGE_BASE_TYPE); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.