aws / aws/bedrock-agentcore-sdk-python

Add user identity (enduser.id) attribute to OpenTelemetry

オープン
#592 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
761
フォーク
147
平均マージ
1日 23時間
マージ済み PR(30日)
7

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、InvokeAgentRuntime と gen_ai 実行における OpenTelemetry span の作成を追跡し、次に BedrockAgentCoreApp の request 処理と AgentCore Identity/Auth ヘッダーを調査します。利用可能な identity コンテキストを OpenTelemetry の enduser.id 規約と比較します。root span と downstream span が、明示的に指定されたユーザーメタデータを含め、要求された identity を一貫して公開すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, python
領域
authentication, observability
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。