Telemetry Module
The Telemetry Module provides comprehensive monitoring and observability features for PraisonAI agents.Installation
Import
Telemetry features require installation with the telemetry extra:
pip install praisonaiagents[telemetry]Functions
get_telemetry
Retrieves the current telemetry instance.MinimalTelemetry: The global telemetry instance. Always returns an instance (neverNone). Check.enabledto see if telemetry is active.
enable_telemetry
Programmatically enables telemetry. If an environment opt-out variable is set, this call is a no-op.None
Precedence: Explicit environment opt-out always wins over programmatic calls. Setting
DO_NOT_TRACK=true (or any *_DISABLED flag) makes enable_telemetry() a no-op. Otherwise, telemetry is off by default until enable_telemetry() is called or an opt-in env var is exported.disable_telemetry
Programmatically disables telemetry. Instrumentation hooks stop installing after this call.None
Example:
Classes
MinimalTelemetry
A lightweight telemetry collector that captures essential metrics only.record_metric
Records a custom metric.name(str): Metric namevalue(Union[int, float]): Metric valueunit(str, optional): Unit of measurementlabels(Dict[str, str], optional): Additional labels for the metric
record_event
Records a custom event.name(str): Event nameattributes(Dict[str, Any], optional): Event attributes
TelemetryCollector
Full-featured telemetry collector with advanced capabilities.service_name(str, optional): Name of the service. Defaults to “praisonai”service_version(str, optional): Service versionexport_endpoint(str, optional): OpenTelemetry export endpointexport_interval(int, optional): Export interval in secondsenable_traces(bool, optional): Enable trace collection. Defaults to Trueenable_metrics(bool, optional): Enable metrics collection. Defaults to Trueenable_logs(bool, optional): Enable log collection. Defaults to True
start_span
Starts a new telemetry span for tracing.name(str): Span namekind(str, optional): Span kind (“internal”, “client”, “server”). Defaults to “internal”attributes(Dict[str, Any], optional): Span attributes
record_agent_execution
Records agent execution metrics.agent_name(str): Name of the agentduration(float): Execution duration in secondsstatus(str): Execution status (“success”, “failure”, “partial”)error(str, optional): Error message if failedmetadata(Dict[str, Any], optional): Additional metadata
record_tool_usage
Records tool usage metrics.tool_name(str): Name of the toolagent_name(str): Name of the agent using the toolduration(float): Tool execution durationsuccess(bool): Whether the tool execution was successfulparameters(Dict[str, Any], optional): Tool parameters (if include_prompts is enabled)
export_metrics
Manually triggers metric export.shutdown
Gracefully shuts down the telemetry collector.Environment Variables
Telemetry behavior is controlled by these environment variables: Opt-in (enables telemetry when set totrue):
PRAISONAI_TELEMETRY_ENABLED=truePRAISONAI_PERFORMANCE_ENABLED=true
PRAISONAI_TELEMETRY_DISABLED=truePRAISONAI_DISABLE_TELEMETRY=truePRAISONAI_PERFORMANCE_DISABLED=trueDO_NOT_TRACK=true
env opt-out > programmatic override > cached env-default
Privacy and Security
- No PII by Default: Telemetry does not collect personally identifiable information
- Opt-in for Content: Prompt and result content is only collected if explicitly enabled
- Local First: Telemetry data stays local unless an export endpoint is configured
- Minimal by Default: Default configuration collects only essential metrics
Example: Complete Telemetry Setup
Integration with Observability Platforms
For OpenTelemetry, Langfuse, and Prometheus integrations, see the Observability documentation.Best Practices
- Start Minimal: Begin with minimal telemetry and increase as needed
- Respect Privacy: Never enable prompt/result collection without user consent
- Monitor Performance: Use telemetry to identify bottlenecks and optimize
- Set Up Alerts: Configure alerts for critical metrics
- Regular Reviews: Periodically review collected metrics for insights
- Graceful Shutdown: Always call shutdown() in production applications

