Skip to main content

Arize Phoenix / OpenInference `TraceSource` adapter for whatifd. Phase D of the v0.2 plan.

Project description

whatifd-phoenix

Arize Phoenix / OpenInference TraceSource adapter for whatifd.

Phase D of the v0.2 plan. Implements whatifd.adapters.TraceSource against an OpenInference span-iterator surface — Phoenix's native span shape — so callers can wire any Phoenix client variant (or any OpenInference-emitting tracer) without the adapter pinning a specific Phoenix SDK version.

Install

uv pip install whatifd-phoenix              # adapter only
uv pip install whatifd-phoenix[live]        # + arize-phoenix-client

The base install gives you the Protocol surface; the [live] extra pulls arize-phoenix-client for live integration. The adapter is API-agnostic beyond the span-iterator shape, so you can use any Phoenix client variant by writing a small spans_provider adapter.

Usage

from arize.phoenix.client import Client
from whatifd_phoenix import PhoenixTraceSource

client = Client(endpoint="http://localhost:6006")

def spans_provider():
    # Cardinal #9 (orchestration, not compute) note: avoid
    # `df.iterrows()` — it's pandas-backed row iteration that pulls
    # NumPy buffers per row. Prefer the streaming form below
    # (`itertuples` returns lightweight named tuples) or, better,
    # iterate a list-of-dicts response directly if your Phoenix
    # client surface offers one.
    spans = client.query_spans(query=...).to_dict(orient="records")
    yield from spans

def classify(spans):
    # Cohort classification has access to ALL spans of a trace
    # (root + children), so a tag set on a tool span is reachable.
    if any(s.get("attributes.tag.failed") for s in spans):
        return "failure"
    return "baseline"

source = PhoenixTraceSource(
    spans_provider=spans_provider,
    cohort_classifier=classify,
    max_traces=40,
)

for raw in source.iter_traces():
    print(raw.trace_id, raw.cohort)

Why span-iterator-shaped (not Phoenix-Client-shaped)

Phoenix's Python client API has shifted across versions (arize-phoenixarize-phoenix-client; methods on Client have churned between major versions). Pinning a specific Client shape in this adapter would force a sync-with-Phoenix-release cycle on every Phoenix major bump.

The span-iterator shape is the stable API: OpenInference span attributes are an open standard, and downstream consumers (Phoenix, but also custom OTLP collectors) emit this shape. Wiring is a ~5-line spans_provider callable that you control.

OpenInference attributes the adapter reads

Attribute Used for
context.trace_id Grouping spans into traces. Required.
parent_id Identifying the root span (parent-less).
openinference.span.kind Fallback root identification.
input.value Wrapped as Sensitive[str]RawTrace.user_message.
output.value Wrapped as Sensitive[str]RawTrace.original_response.
All other attributes Pass through to RawTrace.metadata (NOT wrapped).

Spans without context.trace_id are silently dropped (logged at DEBUG level). Other malformed spans are best-effort: missing input or output values render as empty Sensitive[""], which downstream guards surface as a structured failure rather than crashing the run.

Cardinal alignment

  • #5 Sensitive[T] at the boundary: input.value and output.value are wrapped. Other attributes pass through unwrapped because they carry tooling state (model name, latency, tool calls), not user content. The conformance test pins this contract.
  • #9 orchestration, not compute: no DataFrames, no NumPy in the hot path. Spans arrive as dicts; the adapter groups by trace_id and emits.
  • #10 statistical claims: cluster_key_support returns an empty available_keys tuple. v0.2 does NOT mine cluster keys from OpenInference attributes (e.g., user.id, session.id) because those weren't predeclared at experiment design time. v0.3+ may add explicit per-attribute opt-in.

Status

Surface v0.2 Notes
Protocol shape (TraceSource) Conformance test against the parent repo's harness.
Span grouping by trace_id Pinned by TestSpanGrouping.
Root span identification Parent-less + OpenInference kind fallback.
Recorded-cassette smoke (live Phoenix) ❌ — v0.3 Awaiting Phoenix HTTP-cassette infrastructure parity with whatifd-langfuse.
Cluster keys from user.id / session.id ❌ — v0.3+ Cardinal #10 requires predeclaration; opt-in landed alongside cluster bootstrap.

License

Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whatifd_phoenix-0.3.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whatifd_phoenix-0.3.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file whatifd_phoenix-0.3.0.tar.gz.

File metadata

  • Download URL: whatifd_phoenix-0.3.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for whatifd_phoenix-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d5feedea51bd227b350a2a6351854cefdaf710eb379df531231803cdf6a20d80
MD5 e01868e6ce62554fadb22ae750d0c6c3
BLAKE2b-256 3c3144ec2e46d80bf5eaf0ba98cf4a0dbdd6970f6f0400bf2e001a0a281e94db

See more details on using hashes here.

Provenance

The following attestation bundles were made for whatifd_phoenix-0.3.0.tar.gz:

Publisher: release.yml on victoralfred/whatifd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file whatifd_phoenix-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for whatifd_phoenix-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c653870a12c348096ed2961d4e00526d5ab4909c8e9110664838b16df4cdd92
MD5 fa2536e182db9351dab0b092d08aab97
BLAKE2b-256 45cd413402c29e95680e0523918461d4a6e1922ecfd16a7e8c5ccd27e1c01a3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for whatifd_phoenix-0.3.0-py3-none-any.whl:

Publisher: release.yml on victoralfred/whatifd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page