Overview
Lasso uses structured logging to provide comprehensive visibility into request routing, circuit breaker state transitions, and operational events. All logs follow a consistent JSON format for easy parsing and aggregation.RequestContext Lifecycle
RequestContext is a stateless struct that threads through the entire request pipeline, capturing all routing decisions and timing data.Context Structure
Context Creation
Context created at the start of each request:Context Updates
Context updated at each pipeline stage:Structured Log Schema
All completed requests emit a structuredrpc.request.completed event.
Complete Event Example
Error Event Example
Field Descriptions
Routing section:| Field | Type | Description |
|---|---|---|
candidate_providers | array | Providers considered (format: "provider_id:protocol") |
selected_provider | object | Provider chosen for execution |
selection_reason | string | Why this provider was selected |
retries | integer | Number of retry attempts (0 = first try succeeded) |
circuit_breaker_state | string | CB state when request was made |
"fastest_method_latency"- Lowest latency for this method (fastest strategy)"static_priority"- Config priority (priority strategy)"load_balanced_rotation"- Load balancing (load_balanced strategy)"latency_weighted_selection"- Weighted random (latency_weighted strategy)
| Field | Type | Description |
|---|---|---|
selection_latency_ms | integer | Provider selection duration |
upstream_latency_ms | integer | Time from sending request to receiving response |
end_to_end_latency_ms | integer | Total request duration |
| Field | Type | Description |
|---|---|---|
status | string | "success" or "error" |
result_type | string | Type of result (success only) |
result_size_bytes | integer | Byte size of result (success only) |
error | object | Error details (error only) |
TelemetryLogger
TelemetryLogger bridges telemetry events to structured logs for production debugging.Attached Handlers
| Event | Log Level | Description |
|---|---|---|
[:lasso, :failover, :fast_fail] | WARNING | Provider failover triggered |
[:lasso, :failover, :circuit_open] | WARNING | Circuit breaker blocked request |
[:lasso, :failover, :degraded_mode] | WARNING | Entered degraded mode |
[:lasso, :failover, :degraded_success] | INFO | Recovered via degraded mode |
[:lasso, :failover, :exhaustion] | ERROR | All providers exhausted |
[:lasso, :request, :slow] | WARNING | Request took >2000ms |
[:lasso, :request, :very_slow] | ERROR | Request took >4000ms |
[:lasso, :circuit_breaker, :open] | WARNING | Circuit breaker opened |
[:lasso, :circuit_breaker, :close] | INFO | Circuit breaker closed |
[:lasso, :circuit_breaker, :half_open] | INFO | Circuit breaker half-open |
[:lasso, :circuit_breaker, :proactive_recovery] | INFO | Proactive recovery attempt |
Example Log Outputs
Failover event:Configuration
Enable/disable specific log categories:Telemetry Event Schemas
Circuit Breaker Events
All circuit breaker events use consistent metadata:| Reason | Description |
|---|---|
:failure_threshold_exceeded | Opened due to consecutive failures |
:reopen_due_to_failure | Re-opened from half_open after failure |
:recovered | Closed after successful recovery |
:attempt_recovery | Transitioning to half_open to test recovery |
:proactive_recovery | Timer-based recovery attempt |
:manual_open / :manual_close | Manual intervention |
Failover Events
Request Timing Events
Privacy & Redaction
Error Message Truncation
Error messages limited to prevent logging unbounded responses:No Secrets in Logs
- Provider URLs: Not logged (only provider IDs)
- API Keys: Never exposed
- Client IPs: Not logged by default
- Request parameters: Only presence flag (
params_present: true/false)
Sampling
Reduce log volume in high-traffic scenarios:- Random sampling: Each request independently sampled
- Client metadata unaffected: Sampling only affects server logs
- Rate: Float between 0.0 (none) and 1.0 (all)
Configuration Reference
Complete Configuration
Log Parsing & Analysis
Extract Timing Data
Filter by Provider
Calculate Success Rate
Identify Slow Methods
Performance Characteristics
Overhead Breakdown
| Operation | Overhead | Notes |
|---|---|---|
| Context creation | <1ms | Single struct allocation |
| Timing markers | <0.1ms | System.monotonic_time/0 |
| Log emission | <5ms | Async logger, sampling |
| Total (without metadata) | ~8ms | End-to-end overhead |
Memory Usage
- RequestContext struct: ~200 bytes per request
- Process dictionary storage: ~200 bytes (until response sent)
- Peak usage: <1KB per in-flight request
Summary
Lasso’s logging system provides:- Structured JSON logs for easy parsing and aggregation
- RequestContext lifecycle tracking all routing decisions
- TelemetryLogger for operational events (failovers, circuit breakers)
- Privacy-first with error truncation and no secrets in logs
- Sampling support for high-traffic scenarios
- Low overhead (<8ms per request, <1KB per in-flight request)
- Telemetry integration for custom monitoring