feat: session ids — a scoped withSession() plus an init-level default - #22
Merged
Merged
Conversation
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.
TypeScript twin of glassflow/rius-sdk-python#61 — same surface, same wire contract: the caller mints a session id and the SDK stamps it as OpenInference
session.idon every span, which the sink reads into the first-classSessionIdcolumn, falling back toTraceIdwhen absent.API
The scope rides OTel context (nests, unwinds on a throw, follows async continuations), overrides the init-level default, and the innermost scope wins.
Design points
Same as the Python PR, condensed: stamped on every span at
onStartby a span processor (the sink derives per-span with a TraceId fallback, and pending snapshots are built at start from the identity allowlist, whichsession.idjoins);session.idonly, notgen_ai.conversation.id; no process-wide auto-generation — a generated id exists only inside an explicit scope. The processor is added before the pending processor so the snapshot sees the attribute.The semconv parity fixture is regenerated from the Python branch (19 constants, +
SESSION_ID), so the parity workflow stays green when both PRs land. Merge order: the Python PR first — this fixture asserts a constant Pythonmaindoesn't have yet.12 new tests (scoping, nesting, UUID minting + callback handoff, return passthrough, init default + env var, override precedence, pending snapshot); 220 passing, typecheck/lint/build clean.