File size: 2,611 Bytes
16c91c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/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()