Skip to main content
Monitor your sandbox’s agent performance in real-time with execution metrics. Track uptime, execution counts, error rates, and per-endpoint statistics to optimize your workloads and troubleshoot issues.

Overview

HopX provides agent performance metrics to monitor sandbox execution performance:
  • Agent Metrics: Agent performance metrics including uptime, execution counts, error rates, and per-endpoint statistics
Both get_metrics_snapshot() and get_agent_metrics() return agent performance metrics. They provide the same data structure.

Agent Metrics Snapshot

Get a snapshot of current agent performance metrics:

Agent Performance Metrics

Get detailed agent performance metrics:

Monitoring Agent Performance

Monitor agent metrics over time to track performance:

Metrics Structure

Agent Metrics Response

Both get_metrics_snapshot() and get_agent_metrics() return the same structure:

Field Descriptions

  • uptime_seconds: Agent uptime in seconds
  • total_executions: Total number of code executions processed
  • active_executions: Currently running executions
  • error_count: Total number of errors encountered
  • requests_total: Per-endpoint request counts
  • avg_duration_ms: Average request duration by endpoint (milliseconds)
  • p95_duration_ms: 95th percentile request duration by endpoint (milliseconds)

Use Cases

Monitoring Execution Performance

Monitor agent performance during code execution:

Performance Analysis

Analyze agent performance to identify bottlenecks:

Best Practices

Monitor metrics before and after operations to track execution performance and identify bottlenecks or error patterns.
Use agent metrics to identify frequently used endpoints and optimize your code patterns accordingly.
Metrics are snapshots, not continuous monitoring. For real-time streaming metrics, use the monitoring endpoint with SSE.
Check agent version before using agent metrics. Use sandbox.get_agent_info() to verify v3.1.0+ support.

API Reference

Python SDK

  • sandbox.get_metrics_snapshot() - Get agent performance metrics snapshot
  • sandbox.get_agent_metrics() - Get agent performance metrics (same as get_metrics_snapshot)

JavaScript SDK

  • sandbox.getMetricsSnapshot() - Get agent performance metrics snapshot
  • sandbox.getAgentMetrics() - Get agent performance metrics (same as getMetricsSnapshot)

API Endpoints

  • GET /metrics/snapshot - Get agent performance metrics snapshot

Next Steps