Skip to content

Remove unused code blocks for Bedrock Agent instrumentation #159

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,70 +50,6 @@ internal class AWSServiceHelper
{ "DataSourceId", AWSSemanticConventions.AttributeAWSBedrockDataSourceId },
};

// for Bedrock Agent operations, we map each supported operation to one resource: Agent, DataSource, or KnowledgeBase
internal static List<string> BedrockAgentAgentOps = new List<string>
{
"CreateAgentActionGroup",
"CreateAgentAlias",
"DeleteAgentActionGroup",
"DeleteAgentAlias",
"DeleteAgent",
"DeleteAgentVersion",
"GetAgentActionGroup",
"GetAgentAlias",
"GetAgent",
"GetAgentVersion",
"ListAgentActionGroups",
"ListAgentAliases",
"ListAgentKnowledgeBases",
"ListAgentVersions",
"PrepareAgent",
"UpdateAgentActionGroup",
"UpdateAgentAlias",
"UpdateAgent",
};

internal static List<string> BedrockAgentKnowledgeBaseOps = new List<string>
{
"AssociateAgentKnowledgeBase",
"CreateDataSource",
"DeleteKnowledgeBase",
"DisassociateAgentKnowledgeBase",
"GetAgentKnowledgeBase",
"GetKnowledgeBase",
"ListDataSources",
"UpdateAgentKnowledgeBase",
};

internal static List<string> BedrockAgentDataSourceOps = new List<string>
{
"DeleteDataSource",
"GetDataSource",
"UpdateDataSource",
};

internal static IReadOnlyDictionary<string, string> OperationNameToResourceMap()
{
var operationClassMap = new Dictionary<string, string>();

foreach (var op in BedrockAgentKnowledgeBaseOps)
{
operationClassMap[op] = "KnowledgeBaseId";
}

foreach (var op in BedrockAgentDataSourceOps)
{
operationClassMap[op] = "DataSourceId";
}

foreach (var op in BedrockAgentAgentOps)
{
operationClassMap[op] = "AgentId";
}

return operationClassMap;
}

internal static string GetAWSServiceName(IRequestContext requestContext)
=> Utils.RemoveAmazonPrefixFromServiceName(requestContext.ServiceMetaData.ServiceId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,26 +252,6 @@ private static void AddResponseSpecificInformation(Activity activity, IResponseC
}
}

private static void AddBedrockAgentResponseAttribute(Activity activity, AmazonWebServiceResponse response, string parameter)
{
var responseObject = response.GetType().GetProperty(Utils.RemoveSuffix(parameter, "Id"));
if (responseObject != null)
{
var attributeObject = responseObject.GetValue(response);
if (attributeObject != null)
{
var property = attributeObject.GetType().GetProperty(parameter);
if (property != null)
{
if (AWSServiceHelper.ParameterAttributeMap.TryGetValue(parameter, out var attribute))
{
activity.SetTag(attribute, property.GetValue(attributeObject));
}
}
}
}
}

private static void AddStatusCodeToActivity(Activity activity, int status_code)
{
activity.SetTag(AWSSemanticConventions.AttributeHttpStatusCode, status_code);
Expand Down
Loading