Add trace.project_name for Phoenix project routing#39
Draft
tangym wants to merge 3 commits into
Draft
Conversation
Add an optional project_name field to TraceConfig. When set, p2m sets PHOENIX_PROJECT_NAME in the environment before importing the target module, so Phoenix's register() routes spans to a named project instead of 'default'. The env var is restored after import.
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
Adds an optional
project_namefield toTraceConfigso users can route OTel spans to a named Phoenix project instead of"default".Motivation
When running multiple evals, all traces land in Phoenix's default project. This makes it hard to organize and filter traces by evaluation run or agent.
Implementation
Option B from the design discussion: p2m sets
PHOENIX_PROJECT_NAMEin the environment before importing the target module. Phoenix'sregister()reads this env var automatically, routing spans to the named project. The env var is restored after import to avoid side effects.This avoids the OTel
set_tracer_providerset-once race — the target'sregister(auto_instrument=True)call still wins and sets up all OpenInference instrumentors normally.Usage
Or set via environment:
PHOENIX_PROJECT_NAME=my-eval p2m run --config ...Changes
p2m/core/config_model.py: Addproject_namefield toTraceConfigp2m/core/otel_session.py: Set env var before target import, restore afterp2m/stages/rollout.py: Passproject_namethrough toOTelTracedSessionCONFIG_REFERENCE.md: Document the new fieldtests/test_framework_agnostic.py: Test env var propagation at import time