Skip to content

Dynamic tracing-metadata usage attribution + fix Tracing Agents nav - #222

Merged
anilguleroglu merged 2 commits into
mainfrom
feat/dynamic-metadata-attribution
Aug 17, 2026
Merged

Dynamic tracing-metadata usage attribution + fix Tracing Agents nav#222
anilguleroglu merged 2 commits into
mainfrom
feat/dynamic-metadata-attribution

Conversation

@anilguleroglu

Copy link
Copy Markdown
Collaborator

Summary

  • Tracing sessions accept a free-form metadata bag (sibling of agent), sanitized at ingest, flowing through recordUsageEventusage_daily as a new dynamic attribution dimension (canonical-serialization keyed, so group_by/group_by_entity=metadata.<key> works without a schema change per key).
  • Mongo/SQLite usage_daily: new metadata/metadataKey fields, 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/report and analytics/usage group_by[_entity] accept metadata.<key>, validated against an allowlist regex (/^[a-zA-Z0-9_]{1,40}$/) before it reaches any query.
  • agent-sdk bumped to 0.9.4 (already published to npm) for TracingConfig.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.
  • Tracing sub-nav: added an "Agents" tab (Overview/Sessions/Threads/Agents) and a new /dashboard/tracing/agents list page, replacing the old design that rendered every individual agent name directly into the sidebar.

Test plan

  • npx tsc --noEmit — clean
  • npx eslint on touched files — clean
  • Full suite: npx vitest run — 3207/3207 passed (4 pre-existing skips), including dual-backend (Mongo+SQLite) incrementUsageDaily parity and tracing-stream ingest tests
  • npm ci --dry-run — lockfile consistent with @cognipeer/agent-sdk@0.9.4
  • Visual check of the new Agents nav/page in a browser (Chrome extension wasn't connected during this session — please eyeball it before/after merge)

🤖 Generated with Claude Code

https://claude.ai/code/session_01R7LsJcWXZ2D9ZmhEWx1UVL

anilguleroglu and others added 2 commits August 17, 2026 14:12
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
@anilguleroglu
anilguleroglu merged commit fb71bda into main Aug 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant