-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_auto_telemetry_final.py
More file actions
40 lines (31 loc) · 1.48 KB
/
test_auto_telemetry_final.py
File metadata and controls
40 lines (31 loc) · 1.48 KB
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
#!/usr/bin/env python3
"""
Final test of automatic telemetry.
"""
print("Step 1: Import praisonaiagents...")
from praisonaiagents import Agent, Task, PraisonAIAgents, get_telemetry
print("\nStep 2: Check if telemetry is initialized...")
telemetry = get_telemetry()
print(f" Telemetry enabled: {telemetry.enabled}")
print(f" PostHog available: {telemetry._posthog is not None}")
print("\nStep 3: Check if Agent class is instrumented...")
print(f" Agent.__init__.__name__: {Agent.__init__.__name__}")
print("\nStep 4: Create an agent...")
agent = Agent(name="Test", role="Test", goal="Test", instructions="Test")
print(f" agent.chat wrapped: {hasattr(agent.chat, '__wrapped__')}")
print("\nStep 5: Create and run a simple workflow...")
task = Task(description="Say hello", expected_output="A greeting", agent=agent)
workflow = PraisonAIAgents(agents=[agent], tasks=[task], process="sequential")
# Check workflow instrumentation
print(f" workflow.execute_task wrapped: {hasattr(workflow.execute_task, '__wrapped__')}")
result = workflow.start()
print(f"\nResult: {result}")
print("\nStep 6: Check metrics...")
metrics = telemetry.get_metrics()
print(f" Metrics: {metrics['metrics']}")
if metrics['metrics']['agent_executions'] > 0:
print("\n✅ Automatic telemetry is working!")
else:
print("\n❌ Automatic telemetry is NOT working")
print("\nPossible reason: The auto_instrument_all() in __init__.py might be")
print("running before the telemetry module's lazy initialization completes.")