aws / aws/bedrock-agentcore-sdk-python

Add user identity (enduser.id) attribute to OpenTelemetry

Ouverte
#592 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
enhancement
Langage dominant
Python
Étoiles
761
Forks
147
Merge moyen
1 j 23 h
PR mergées (30 j)
7

Description

### 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"
}

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par suivre la création des spans OpenTelemetry pour InvokeAgentRuntime et l’exécution de gen_ai, puis examinez la gestion des requests de BedrockAgentCoreApp et les headers Identity/Auth de AgentCore. Comparez le contexte d’identité disponible avec la convention OpenTelemetry enduser.id ; le travail est considéré comme terminé lorsque les spans racine et en aval exposent systématiquement l’identité demandée, y compris les métadonnées utilisateur fournies explicitement.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
aws, python
Domaine
authentication, observability
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.