-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtelemetry_minimal.py
More file actions
53 lines (45 loc) · 1.38 KB
/
telemetry_minimal.py
File metadata and controls
53 lines (45 loc) · 1.38 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
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
"""
Minimal example showing telemetry integration with agents.
"""
import os
# Uncomment to disable telemetry
# os.environ['PRAISONAI_TELEMETRY_DISABLED'] = 'true'
from praisonaiagents import Agent, Task, PraisonAIAgents
from praisonaiagents.telemetry import get_telemetry
# Create a simple agent
agent = Agent(
name="Calculator",
role="Math Expert",
goal="Perform calculations",
instructions="You are a helpful math expert."
)
# Create a task
task = Task(
description="Calculate 2 + 2",
expected_output="The sum",
agent=agent
)
# Create and run workflow
workflow = PraisonAIAgents(
agents=[agent],
tasks=[task],
process="sequential"
)
print("Running workflow with telemetry...")
result = workflow.start()
print(f"Result: {result}")
# Check telemetry metrics
telemetry = get_telemetry()
if telemetry.enabled:
metrics = telemetry.get_metrics()
print(f"\nTelemetry metrics collected:")
print(f"- Agent executions: {metrics['metrics']['agent_executions']}")
print(f"- Task completions: {metrics['metrics']['task_completions']}")
print(f"- Errors: {metrics['metrics']['errors']}")
print(f"- Session ID: {metrics['session_id']}")
else:
print("\nTelemetry is disabled")
print("\nTo disable telemetry, set any of these environment variables:")
print("- PRAISONAI_TELEMETRY_DISABLED=true")
print("- DO_NOT_TRACK=true")