feat: context-scoped multi-workspace routing (workspace() scope + routing exporter) - #68
Merged
Merged
Conversation
Member
Author
|
Verified end-to-end against staging: init() with a pablo-test key as default and a B-test key under alias "acme"; a bare span landed only in pablo-test, the workspace("acme")-scoped root+child trace landed only in B-test, and ClickHouse shows the stored spans carry only openinference.span.kind — the rius.workspace attribute never reached the wire. flush() reported delivery success for the fan-out. |
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.
RIUS-646. One process, many workspaces:
init(workspaces={alias: api_key})pluswith rius.workspace(alias):routes every span started in scope (observe, generations, sessions, and auto-instrumented spans, which inherit the OTel context) to that workspace's destination. Spans outside any scope keep using the default key.Design mirrors sessions end to end:
workspace(alias)context manager on an OTel context key (copy ofsession())WorkspaceSpanProcessorstamps a transientrius.workspaceattribute at span start (copy ofSessionSpanProcessor), and warns when a span starts under a different alias than its parent's stamp: one trace, one workspace (the backend derives the workspace from the key)RoutingSpanExportersits innermost in the export chain (masking and export-health wrap the fan-out), partitions each batch by the attribute, strips it via the same copy-on-write discipline asMaskingSpanExporter(it never reaches the wire), and forwards each partition to a lazily-built per-key OTLP exporter; flush delivery and shutdown fan outDecisions from the ticket, implemented:
rius.workspacejoinedPENDING_IDENTITY_ATTRIBUTES, so a partial-span snapshot routes to the same workspace its final span will (covered by test)client.register_workspace(alias, key)/ module-levelrius.register_workspacefor keys fetched at runtime;workspaces={}opts into routing with no static routes; re-registering an alias rotates its keyworkspace_exporter_factoryinjection point for tests, matching the repo's DI style12 new tests in tests/test_workspace.py; full suite 240 passed, ruff + mypy strict clean.