Skip to content

Commit d229f67

Browse files
authored
Celestial agents demo setup (#210)
*Description of changes:* Add OTEL resource attributes to group agent services into Application, Team and Tier. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent b3664c7 commit d229f67

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

cdk/agents/lib/pet-clinic-agents-stack.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,34 @@ class PetClinicAgentsStack extends Stack {
8080
});
8181

8282
// Deploy nutrition agent with optional environment variable
83+
const nutritionAgentName = 'nutrition_agent';
8384
const nutritionAgentProps = {
84-
AgentName: 'nutrition_agent',
85+
AgentName: nutritionAgentName,
8586
ImageUri: nutritionAgentImage.imageUri,
8687
ExecutionRole: agentCoreRole.roleArn,
87-
Entrypoint: 'nutrition_agent.py'
88+
Entrypoint: 'nutrition_agent.py',
89+
EnvironmentVariables: {
90+
OTEL_RESOURCE_ATTRIBUTES: `service.name=${nutritionAgentName},deployment.environment=bedrock-agentcore:default,Application=Audit,Team=AnalyticsTeam,Tier=Tier-4,aws.application_signals.metric_resource_keys=Application&Team&Tier`,
91+
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS: 'sqlalchemy,psycopg2,pymysql,sqlite3,aiopg,asyncpg,mysql_connector,system_metrics,google-genai'
92+
}
8893
};
8994

9095
if (props?.nutritionServiceUrl) {
91-
nutritionAgentProps.EnvironmentVariables = {
92-
NUTRITION_SERVICE_URL: props.nutritionServiceUrl,
93-
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS: 'sqlalchemy,psycopg2,pymysql,sqlite3,aiopg,asyncpg,mysql_connector,system_metrics,google-genai'
94-
};
95-
} else {
96-
nutritionAgentProps.EnvironmentVariables = {
97-
OTEL_PYTHON_DISABLED_INSTRUMENTATIONS: 'sqlalchemy,psycopg2,pymysql,sqlite3,aiopg,asyncpg,mysql_connector,system_metrics,google-genai'
98-
};
96+
nutritionAgentProps.EnvironmentVariables.NUTRITION_SERVICE_URL = props.nutritionServiceUrl;
9997
}
10098

10199
const nutritionAgent = new BedrockAgentCoreDeployer(this, 'NutritionAgent', nutritionAgentProps);
102100

103101
// Deploy primary agent
102+
const petClinicAgentName = 'pet_clinic_agent'
104103
const primaryAgent = new BedrockAgentCoreDeployer(this, 'PrimaryAgent', {
105-
AgentName: 'pet_clinic_agent',
104+
AgentName: petClinicAgentName,
106105
ImageUri: primaryAgentImage.imageUri,
107106
ExecutionRole: agentCoreRole.roleArn,
108107
Entrypoint: 'pet_clinic_agent.py',
109108
EnvironmentVariables: {
110-
NUTRITION_AGENT_ARN: nutritionAgent.agentArn
109+
NUTRITION_AGENT_ARN: nutritionAgent.agentArn,
110+
OTEL_RESOURCE_ATTRIBUTES: `service.name=${petClinicAgentName},deployment.environment=bedrock-agentcore:default,Application=Audit,Team=AnalyticsTeam,Tier=Tier-4,aws.application_signals.metric_resource_keys=Application&Team&Tier`
111111
}
112112
});
113113

@@ -118,4 +118,4 @@ class PetClinicAgentsStack extends Stack {
118118
}
119119
}
120120

121-
module.exports = { PetClinicAgentsStack };
121+
module.exports = { PetClinicAgentsStack };

data_test/test_cases/otel_resource_attributes_test_cases.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@
103103
"Tier": "Tier-1"
104104
},
105105
"time_range_minutes": 60
106+
},
107+
{
108+
"test_case_id": "bedrock_nutrition_agent_otel_attributes_validation",
109+
"test_scenario": "Resource Grouping Validation",
110+
"description": "Validate OTEL resource attributes for nutrition_agent",
111+
"service_name": "nutrition_agent",
112+
"environment": "ENVIRONMENT_NAME_PLACEHOLDER",
113+
"expected_resource_attributes": {
114+
"Application": "Audit",
115+
"Team": "AnalyticsTeam",
116+
"Tier": "Tier-4"
117+
},
118+
"time_range_minutes": 60
106119
}
107120
]
108121
}

0 commit comments

Comments
 (0)