#!/usr/bin/env python3 """ Debug script to see Phoenix spans column structure. """ import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) import phoenix as px import pandas as pd def debug_spans_structure(): """Debug the structure of Phoenix spans.""" print("šŸ” Debugging Phoenix Spans Structure") print("=" * 50) try: client = px.Client() print("āœ… Phoenix connected successfully") except Exception as e: print(f"āŒ Phoenix connection failed: {e}") return try: spans_df = client.get_spans_dataframe() print(f"šŸ“Š Found {len(spans_df)} spans in Phoenix") if len(spans_df) == 0: print("āš ļø No spans found. Run your agent first to create spans.") return print(f"\nšŸ“‹ Available Columns ({len(spans_df.columns)} total):") for i, col in enumerate(spans_df.columns): print(f" {i+1:2d}. {col}") print(f"\nšŸ” Sample Data (first span):") sample_span = spans_df.iloc[0] for col in spans_df.columns: value = sample_span.get(col) if value is not None: value_str = str(value)[:100] + "..." if len(str(value)) > 100 else str(value) print(f" {col}: {value_str}") # Look for input/output related columns input_cols = [col for col in spans_df.columns if 'input' in col.lower()] output_cols = [col for col in spans_df.columns if 'output' in col.lower()] print(f"\nšŸŽÆ Input-related columns: {input_cols}") print(f"šŸŽÆ Output-related columns: {output_cols}") # Look for span ID columns id_cols = [col for col in spans_df.columns if 'id' in col.lower()] print(f"šŸŽÆ ID-related columns: {id_cols}") # Look for columns that might contain task IDs print(f"\nšŸ” Searching for task IDs in spans...") task_id_sample = "8e867cd7-cff9-4e6c-867a-ff5ddc2550be" for col in spans_df.columns: if spans_df[col].dtype == 'object': # String-like columns try: matches = spans_df[spans_df[col].astype(str).str.contains(task_id_sample, na=False, case=False)] if len(matches) > 0: print(f" āœ… Found task ID in column '{col}': {len(matches)} matches") except: pass except Exception as e: print(f"āŒ Error debugging spans: {e}") import traceback traceback.print_exc() if __name__ == "__main__": debug_spans_structure()