Skip to content

Add trace.project_name for Phoenix project routing#39

Draft
tangym wants to merge 3 commits into
mainfrom
yemingtang/trace-project-name
Draft

Add trace.project_name for Phoenix project routing#39
tangym wants to merge 3 commits into
mainfrom
yemingtang/trace-project-name

Conversation

@tangym

@tangym tangym commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds an optional project_name field to TraceConfig so 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_NAME in the environment before importing the target module. Phoenix's register() 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_provider set-once race — the target's register(auto_instrument=True) call still wins and sets up all OpenInference instrumentors normally.

Usage

trace:
  backend: phoenix
  group_by: session.id
  project_name: travel-planner-eval

Or set via environment: PHOENIX_PROJECT_NAME=my-eval p2m run --config ...

Changes

  • p2m/core/config_model.py: Add project_name field to TraceConfig
  • p2m/core/otel_session.py: Set env var before target import, restore after
  • p2m/stages/rollout.py: Pass project_name through to OTelTracedSession
  • CONFIG_REFERENCE.md: Document the new field
  • tests/test_framework_agnostic.py: Test env var propagation at import time

tangym added 3 commits May 11, 2026 18:23
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.
@tangym tangym marked this pull request as draft May 14, 2026 16:39
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