Skip to content

feat(logging): Add request_id to all log entries for correlation #2029

Description

@xilosada

Problem

Logs lack correlation IDs, making it hard to trace a request through the system:

INFO context_id=abc123 "Executing method"
INFO context_id=abc123 "WASM completed"
// Which request? Multiple concurrent requests have same context_id

Proposed Solution

  1. Generate request ID at entry point:
use uuid::Uuid;

async fn handle_request(...) {
    let request_id = Uuid::new_v4();
    let span = tracing::info_span!("request", %request_id, %context_id);
    
    async move {
        // All logs within this span include request_id
    }.instrument(span).await
}
  1. Propagate through async boundaries:
tokio::spawn(async move {
    // Inherit parent span
}.instrument(tracing::Span::current()));

Acceptance Criteria

  • All JSON-RPC requests have unique request_id
  • request_id appears in all related logs
  • Spans propagate through async tasks
  • Can filter logs by request_id

Estimated Effort: 2-4 hours

Priority: P1 (Quick Win)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions