All skills
github avatar

/phoenix-tracing

@4214189 official
by githubgithub/awesome-copilot40k stars
5,040

OpenInference semantic conventions and instrumentation for Phoenix AI observability. Use when implementing LLM tracing, creating custom spans, or deploying to production.

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/phoenix-tracing

This session only. Nothing lands on disk.

referencesinstrumentation-manual-python.md

≈1.3k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Manual Instrumentation (Python)

Add custom spans using decorators or context managers for fine-grained tracing control.

Setup

pip install arize-phoenix-otel
from phoenix.otel import register
tracer_provider = register(project_name="my-app")
tracer = tracer_provider.get_tracer(__name__)

Quick Reference

Span Kind Decorator Use Case
CHAIN @tracer.chain Orchestration, workflows, pipelines
RETRIEVER @tracer.retriever Vector search, document retrieval
TOOL @tracer.tool External API calls, function execution
AGENT @tracer.agent Multi-step reasoning, planning
LLM @tracer.llm LLM API calls (manual only)
EMBEDDING @tracer.embedding Embedding generation
RERANKER @tracer.reranker Document re-ranking
GUARDRAIL @tracer.guardrail Safety checks, content moderation
EVALUATOR @tracer.evaluator LLM evaluation, quality checks

Decorator Approach (Recommended)

Use for: Full function instrumentation, automatic I/O capture

@tracer.chain
def rag_pipeline(query: str) -> str:
    docs = retrieve_documents(query)
    ranked = rerank(docs, query)
    return generate_response(ranked, query)

@tracer.retriever
def retrieve_documents(query: str) -> list[dict]:
    results = vector_db.search(query, top_k=5)
    return [{"content": doc.text, "score": doc.score} for doc in results]

@tracer.tool
def get_weather(city: str) -> str:
    response = requests.get(f"https://api.weather.com/{city}")
    return response.json()["weather"]

Custom span names:

@tracer.chain(name="rag-pipeline-v2")
def my_workflow(query: str) -> str:
    return process(query)

Context Manager Approach

Use for: Partial function instrumentation, custom attributes, dynamic control

from opentelemetry.trace import Status, StatusCode
import json

def retrieve_with_metadata(query: str):
    with tracer.start_as_current_span(
        "vector_search",
        openinference_span_kind="retriever"
    ) as span:
        span.set_attribute("input.value", query)

        results = vector_db.search(query, top_k=5)

        documents = [
            {
                "document.id": doc.id,
                "document.content": doc.text,
                "document.score": doc.score
            }
            for doc in results
        ]
        span.set_attribute("retrieval.documents", json.dumps(documents))
        span.set_status(Status(StatusCode.OK))

        return documents

Capturing Input/Output

Always capture I/O for evaluation-ready spans.

Automatic I/O Capture (Decorators)

Decorators automatically capture input arguments and return values:

@tracer.chain
def handle_query(user_input: str) -> str:
    result = agent.generate(user_input)
    return result.text

# Automatically captures:
# - input.value: user_input
# - output.value: result.text
# - input.mime_type / output.mime_type: auto-detected

Manual I/O Capture (Context Manager)

Use set_input() and set_output() for simple I/O capture:

from opentelemetry.trace import Status, StatusCode

def handle_query(user_input: str) -> str:
    with tracer.start_as_current_span(
        "query.handler",
        openinference_span_kind="chain"
    ) as span:
        span.set_input(user_input)

        result = agent.generate(user_input)

        span.set_output(result.text)
        span.set_status(Status(StatusCode.OK))

        return result.text

What gets captured:

{
  "input.value": "What is 2+2?",
  "input.mime_type": "text/plain",
  "output.value": "2+2 equals 4.",
  "output.mime_type": "text/plain"
}

Why this matters:

  • Phoenix evaluators require input.value and output.value
  • Phoenix UI displays I/O prominently for debugging
  • Enables exporting data for fine-tuning datasets

Custom I/O with Additional Metadata

Use set_attribute() for custom attributes alongside I/O:

def process_query(query: str):
    with tracer.start_as_current_span(
        "query.process",
        openinference_span_kind="chain"
    ) as span:
        # Standard I/O
        span.set_input(query)

        # Custom metadata
        span.set_attribute("input.length", len(query))

        result = llm.generate(query)

        # Standard output
        span.set_output(result.text)

        # Custom metadata
        span.set_attribute("output.tokens", result.usage.total_tokens)
        span.set_status(Status(StatusCode.OK))

        return result

See Also

  • Span attributes: span-chain.md, span-retriever.md, span-tool.md, span-llm.md, span-agent.md, span-embedding.md, span-reranker.md, span-guardrail.md, span-evaluator.md
  • Auto-instrumentation: instrumentation-auto-python.md for framework integrations
  • API docs: https://docs.arize.com/phoenix/tracing/manual-instrumentation

Source: SKILL.md on GitHub

No alerts9d4 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    The phoenix-tracing skill provides comprehensive documentation and implementation guides for instrumenting LLM applications with Phoenix and OpenInference semantic conventions. It covers setup, manual and auto-instrumentation, and production best practices for both Python and TypeScript, with a strong focus on secure data handling and PII masking.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: LOW · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 4214189. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 months ago
Other metadata
compatibility
Requires Phoenix server. Python skills need arize-phoenix-otel; TypeScript skills need @arizeai/phoenix-otel.
metadata
{
  "author": "oss@arize.com",
  "version": "1.0.0",
  "languages": "Python, TypeScript"
}
  • Python
  • TypeScript
  • phoenix
  • tracing
  • openinference
  • llm-observability
  • instrumentation
  • otel
  • arize

README badge

README badge for github/awesome-copilot/phoenix-tracing

Instruments LLM applications with OpenInference tracing in Phoenix, supporting auto-instrumentation of frameworks like OpenAI and LangChain or custom manual spans. Covers setup, span types (LLM calls, retrievers, agents, evaluators), production deployment with PII masking, and feedback annotation in Python and TypeScript.

Generated from the current SKILL.md.

Does this skill work with both Python and TypeScript?
Yes. The skill provides separate setup, instrumentation, and production guides for both Python (arize-phoenix-otel) and TypeScript (@arizeai/phoenix-otel).
What do I need to install to use this skill?
For Python: arize-phoenix-otel package. For TypeScript: @arizeai/phoenix-otel package. Both require a running Phoenix server endpoint.
Can I auto-instrument frameworks like OpenAI or LangChain?
Yes. The skill includes instrumentation-auto-{lang} references that cover auto-instrumentation for supported frameworks in both languages.
How do I track custom spans for my own operations?
Use the instrumentation-manual-{lang} references to create custom spans with decorators (Python) or wrappers (TypeScript), then refer to span-{type} files for the appropriate attribute schema.
Does this skill cover production deployment concerns?
Yes. The production-{lang} references address batch processing, PII masking, and deployment patterns for production environments.

Generated from the current SKILL.md. These answers refresh after source changes.