aws / aws/bedrock-agentcore-sdk-python
Add user identity (enduser.id) attribute to OpenTelemetry
- Lenguaje dominante
- Python
- Estrellas
- 761
- Forks
- 147
- Merge medio
- 1 d 23 h
- PR fusionados (30 d)
- 7
Descripción
### Feature Description
Currently, the OpenTelemetry (OTel) traces and spans generated during AgentCore invocation (`InvokeAgentRuntime` / `gen_ai` execution) capture telemetry metrics and session identifiers, but do not consistently populate user identity in the span attributes.
We request adding support to automatically populate user identity (or allow passing custom user identity metadata) onto OTel span attributes, following the OpenTelemetry Semantic Conventions for user attributes (`enduser.id`).
---
### Use Case & Impact
1. **User-level Observability & Debugging**: When troubleshooting agent execution failures or slow agent runs in observability platforms (e.g., Datadog, Grafana, Dynatrace, OpenSearch), SREs and developers need to trace issues back to specific end-users.
2. **Auditability & Compliance**: Enterprise compliance standards often require linking LLM invocations and tool calls directly to the initiating user identity.
3. **Usage Attribution & Quotas**: Facilitates per-user telemetry tracking, token usage analytics, and user-level rate limiting.
---
### Proposed Solution
- **Standard Attribute**: Set the span attribute `enduser.id` on root invocation spans and downstream tool/model execution spans according to the [OpenTelemetry Semantic Conventions for User Attributes](https://opentelemetry.io/docs/specs/semconv/general/attributes/#user-attributes).
- **Configuration / Propagation**:
- Extract the user ID automatically from Inbound Authentication JWT tokens (e.g., Cognito `sub` or custom claim) if passed via AgentCore Identity/Auth headers.
- Expose a mechanism in `BedrockAgentCoreApp` or request context context/metadata to explicitly inject `user_id` when initializing or handling incoming requests.
---
### Example / Expected Behavior
When an agent invocation span is generated, the resulting OpenTelemetry span attributes should include:
```json
{
"gen_ai.system": "aws.bedrock",
"enduser.id": "usr_987654321",
"session.id": "session_12345"
}
Guía de contribución
Línea de trabajo
Comienza rastreando la creación de spans de OpenTelemetry para InvokeAgentRuntime y la ejecución de gen_ai; después, inspecciona el manejo de requests de BedrockAgentCoreApp y los headers de Identity/Auth de AgentCore. Compara el contexto de identidad disponible con la convención enduser.id de OpenTelemetry; se considera terminado cuando los spans raíz y posteriores exponen de forma consistente la identidad solicitada, incluidos los metadatos de usuario proporcionados explícitamente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- aws, python
- Área
- authentication, observability
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100