Comprehensive telemetry system for monitoring agent performance, tracking metrics, and optimizing AI workflows.
The Telemetry system provides minimal, privacy-focused usage tracking for PraisonAI Agents. It collects only anonymous metrics about feature usage, with no personal data, prompts, or responses tracked. Telemetry is enabled by default but can be easily disabled via environment variables.
Note: Telemetry is included by default and automatically enabled unless disabled.
2
Simple Example
Create simple_agent_example.py:
Copy
from praisonaiagents import Agent, Task, PraisonAIAgents# Create a simple agent - telemetry is automatically enabledagent = Agent( name="Assistant", role="Helper", goal="Assist with tasks", instructions="You are a helpful assistant.")# Create a tasktask = Task( description="Write a haiku about AI", expected_output="A three-line haiku poem", agent=agent)# Create and run workflow - telemetry tracks automaticallyworkflow = PraisonAIAgents(agents=[agent], tasks=[task])result = workflow.start()print(result)
3
Check Telemetry (Optional)
Access telemetry metrics programmatically:
Copy
from praisonaiagents.telemetry import get_telemetry# Get the telemetry instancetelemetry = get_telemetry()# Check metrics (stored in memory)metrics = telemetry.get_metrics()print(f"Agent executions: {metrics['agent_executions']}")print(f"Task completions: {metrics['task_completions']}")print(f"Tool calls: {metrics['tool_calls']}")print(f"Errors: {metrics['errors']}")
4
Disable Telemetry (Optional)
To disable telemetry, set any of these environment variables before running:
# Set any of these before running your codeexport PRAISONAI_TELEMETRY_DISABLED=trueexport PRAISONAI_DISABLE_TELEMETRY=trueexport DO_NOT_TRACK=true # Universal standard
from praisonaiagents.telemetry import get_telemetry# Get the global telemetry instancetelemetry = get_telemetry()# Check if telemetry is enabledif telemetry.enabled: print("Telemetry is active")# Get current metricsmetrics = telemetry.get_metrics()print(f"Total agent executions: {metrics['agent_executions']}")print(f"Total task completions: {metrics['task_completions']}")print(f"Total tool calls: {metrics['tool_calls']}")print(f"Total errors: {metrics['errors']}")# Get session infoprint(f"Session ID: {telemetry.session_id}")print(f"Environment: {telemetry._environment}")
PraisonAI telemetry includes built-in PostHog support for anonymous analytics:
Copy
# PostHog integration is automatic when available# Metrics are sent anonymously with session IDs only# No configuration needed - it just works# To verify PostHog is available:try: import posthog print("PostHog integration available")except ImportError: print("PostHog not installed - metrics stored locally only")
Telemetry is designed to be minimal and privacy-focused
No personal data, prompts, or responses are ever collected
Always respect user preferences for tracking
Use environment variables for easy opt-out
Performance Impact
Telemetry has minimal overhead
Metrics are stored in memory only (no network calls in current version)
Automatic integration means no extra code needed
PostHog integration (when available) uses async mode to prevent blocking
Development vs Production
Copy
# Development - verbose metricsimport osos.environ['LOGLEVEL'] = 'DEBUG'# Production - disable if neededos.environ['PRAISONAI_TELEMETRY_DISABLED'] = 'true'
PraisonAI telemetry is designed to be minimal, privacy-focused, and helpful. It collects only anonymous usage metrics to help improve the framework while respecting user privacy. Telemetry can be easily disabled at any time.
Assistant
Responses are generated using AI and may contain mistakes.