Dynamic tracing-metadata usage attribution + fix Tracing Agents nav - #222
Merged
Conversation
Usage attribution: - Tracing sessions accept a free-form metadata bag (sibling of agent), sanitized at ingest, flowing through recordUsageEvent -> usage_daily as a new dimension keyed by its canonical serialization. - Mongo/SQLite: usage_daily gains metadata/metadataKey; unique dims index bumped to v3 (adds metadataKey, same migration pattern as the earlier agentKey v1->v2 bump). - spend/report and analytics/usage group_by[_entity] accept metadata.<key> for dynamic grouping, validated against an allowlist regex before it ever reaches a query. - agent-sdk 0.9.4 dependency bump (already published) to pick up TracingConfig.metadata support; console's own internal-agent tracing sink (agentService.ts) now forwards it too. Tracing UI: - Agents sub-nav item (Overview/Sessions/Threads/Agents) replaces the old per-agent-name directory that was rendered directly into the sidebar; new /dashboard/tracing/agents list page (reuses the existing /api/tracing/agents directory endpoint). Full suite green: 3207/3207 tests, tsc, eslint. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7LsJcWXZ2D9ZmhEWx1UVL
Local npm 11 relocks omit some optional platform packages (e.g. @emnapi/runtime, @emnapi/core) that npm 10 -- what node:22's Docker image actually ships -- expects to find, so `npm ci` inside the Dockerfile build fails even though the lockfile looks consistent locally. Known trap (hit v1.0.73-saas previously); npx npm@10 install --package-lock-only is the fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7LsJcWXZ2D9ZmhEWx1UVL
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
metadatabag (sibling ofagent), sanitized at ingest, flowing throughrecordUsageEvent→usage_dailyas a new dynamic attribution dimension (canonical-serialization keyed, sogroup_by/group_by_entity=metadata.<key>works without a schema change per key).usage_daily: newmetadata/metadataKeyfields, unique-dims index bumped to v3 (same migration pattern as the earlier agentKey v1→v2 bump — old index dropped, new one created on boot).spend/reportandanalytics/usagegroup_by[_entity]acceptmetadata.<key>, validated against an allowlist regex (/^[a-zA-Z0-9_]{1,40}$/) before it reaches any query.agent-sdkbumped to 0.9.4 (already published to npm) forTracingConfig.metadata; console's own internal-agent tracing sink (agentService.ts) now forwards it too, closing a gap where console's own agents couldn't use the new dimension./dashboard/tracing/agentslist page, replacing the old design that rendered every individual agent name directly into the sidebar.Test plan
npx tsc --noEmit— cleannpx eslinton touched files — cleannpx vitest run— 3207/3207 passed (4 pre-existing skips), including dual-backend (Mongo+SQLite)incrementUsageDailyparity and tracing-stream ingest testsnpm ci --dry-run— lockfile consistent with@cognipeer/agent-sdk@0.9.4🤖 Generated with Claude Code
https://claude.ai/code/session_01R7LsJcWXZ2D9ZmhEWx1UVL