feat(util-genai): event log → trace converter, passthrough & total_tokens#55
Merged
Merged
Conversation
…l_tokens Introduce the event log → OTel span tree converter for @loongsuite/otel-util-genai (published as 0.1.0-beta.9), turning loongsuite-pilot event logs into ARMS GenAI-compliant traces. - convertEventLogToTrace / convertEventLogToReadableSpans: rebuild ENTRY→AGENT→STEP→LLM/TOOL span trees from flat event logs; honor upstream trace_id / parent_span_id, response.id merge, and 1-level subagent nesting. - ARMS GenAI common attributes (agent.name / user.id / session.id) on every span. - ConvertOptions.passthroughKeys: allowlist to copy custom event fields onto spans (turn-level broadcast + LLM/TOOL per-record override, fill-only so converter-managed attributes are never overwritten). - gen_ai.usage.total_tokens now prefers the upstream-reported value and falls back to input+output only when absent or unusable (incl. total=0 guard). - Rename package to @loongsuite/otel-util-genai; update docs and add EVENT_LOG_TO_TRACE_SPEC.md. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
CI's `npm audit --audit-level=high` failed on vite 8.0.x (GHSA-fx2h-pf6j-xcff, GHSA-v6wh-96g9-6wx3), pulled transitively via vitest. `npm audit fix` bumps vite to 8.1.4 (lockfile-only, non-breaking). Remaining advisories are moderate (@opentelemetry/core via optional sdk-trace-base) and do not fail the gate. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Introduces the event log → OTel span tree converter for
@loongsuite/otel-util-genai(published as0.1.0-beta.9), turning loongsuite-pilot event logs into ARMS GenAI-compliant traces. This is the first time the converter lands in the repo (previously the package only shipped the handler/span utilities).convertEventLogToTrace/convertEventLogToReadableSpansrebuildENTRY→AGENT→STEP→LLM/TOOLspan trees from flat event logs; honor upstreamtrace_id/parent_span_id,response.idmerge, and 1-level subagent nesting.gen_ai.agent.name/gen_ai.user.id/gen_ai.session.idwritten on every span kind.ConvertOptions.passthroughKeys: allowlist to copy custom event fields onto spans — turn-level broadcast + LLM/TOOL per-record override, fill-only so converter-managed attributes are never overwritten.gen_ai.usage.total_tokens: now prefers the upstream-reported value; falls back toinput + outputonly when absent or unusable (incl.total=0guard). AGENT aggregation only sums reported totals when every token-bearing response reports one, else falls back.@loongsuite/otel-util-genai; docs updated; addsEVENT_LOG_TO_TRACE_SPEC.md.Test plan
npm run build(tsc) — cleannpm test— 18 files / 203 tests passing (incl. newpassthrough.test.ts,total-tokens.test.ts)npm publish --dry-run— tarball contains onlydist/**+ LICENSE + READMEpassthroughKeysin loongsuite-pilot (separate change)🤖 Generated with Claude Code