Skip to main content
Watch a run as it happens, replay it afterwards, and read back its token usage. This page covers session monitoring and resource usage on both Browserbase and local browsers.

Browserbase session monitoring

On Browserbase, the API and dashboard give you live views, recordings, and session metadata.
Browserbase Session Observability

Live session visibility

Browserbase provides real-time visibility into your automation sessions: Session dashboard features
  • Real-time browser screen recording and replay
  • Network request monitoring with detailed timing
  • JavaScript console logs and error tracking
  • CPU and memory usage metrics
  • Session status and duration tracking
Session management & API access

Session analytics & insights

Real-time monitoring

Monitor live session status, resource usage, and geographic distribution. Scale and manage concurrent sessions with real-time insights.

Session recordings

Review complete session recordings with frame-by-frame playback. Analyze network requests and debug browser interactions visually.

API management

Programmatically access session data, automate lifecycle management, and integrate with monitoring systems through the Browserbase API.

Usage monitoring

Track resource consumption, session duration, and API usage. Get detailed breakdowns of costs and utilization across your automation.

Session monitoring & filtering

Query and monitor sessions by status and metadata:
Tag every session with userMetadata on browserbase.launch() so you can slice these queries by workflow, customer, or deployment.

Local environment monitoring

For local development, Stagehand provides performance monitoring and resource tracking capabilities directly on your machine.

Performance tracking

Resource usage monitoring

When running locally, monitor system resource usage and browser performance:

Speed and cost tuning

Monitor token usage, costs, and speed. Set up automated alerting for critical failures. Implement cost tracking across different environments. Use session analytics to optimize automation workflows.

Real-time metrics & monitoring

Basic usage tracking

Monitor your automation’s resource usage in real-time by calling the metrics method:

Understanding metrics data

The metrics object provides a detailed breakdown by Stagehand operation:
Example metrics output:
Cached input tokens are reported separately so you can see how much of your prompt spend was served from your provider’s prompt cache. This is distinct from Stagehand’s own server-side result cache, which avoids the inference call entirely.

Operation history

Metrics give you the totals. When you want the sequence of what happened, build the timeline yourself from the log callback: every act, observe, and extract emits records with their structured data already attached. There is no history accessor on the Stagehand instance.
The records you capture depend on the level. Raise it to debug for the fullest timeline; the default is info and above.
On Browserbase, the session replay dashboard gives you the same timeline visually, including the network and console activity that never reaches a log callback.

Tracing

Stagehand emits OpenTelemetry spans for every operation and for every log record, and propagates W3C trace context across the SDK and runtime boundary. Point it at your own OTLP collector to see full traces alongside the rest of your system.
Spans are tagged with a span type: operation spans wrap act, observe, and extract, and record exceptions and error status; log spans carry the structured data from each log record. Traces are sampled at 100%.

Best practices

  • Track session success rates and failure patterns
  • Monitor resource usage and scaling requirements
  • Set up automated alerting for critical failures
  • Implement cost tracking across different environments
  • Use session analytics to optimize automation workflows
  • Compare Browserbase vs local execution times
  • Monitor token usage and inference costs across models
  • Track geographic performance differences
  • Identify bottlenecks in automation workflows
  • Optimize for cost-effectiveness and speed
  • Track session distribution across regions
  • Monitor concurrent session limits and scaling
  • Analyze failure patterns and common error scenarios
  • Use session recordings for root cause analysis
  • Implement custom metadata for workflow categorization
  • Integrate session APIs with monitoring dashboards
  • Set up automated notifications for session failures
  • Track SLA compliance and performance benchmarks
  • Monitor resource costs and usage patterns
  • Use analytics data for capacity planning and optimization

Next steps

Caching

Cut token spend and latency by serving repeated act, observe, and extract calls from the server-side cache.

Logging

Configure logging levels, custom loggers, and file-based session logging.