feat: Add distributed tracing for booking flow correlation (1)#22186
feat: Add distributed tracing for booking flow correlation (1)#22186Udit-takkar wants to merge 39 commits intomainfrom
Conversation
- Create centralized tracing library with trace context management - Integrate tracing into core booking flow components - Add trace context propagation to webhook scheduling and execution - Enhance payment processing with trace correlation - Add comprehensive debugging examples and Axiom queries - Maintain backward compatibility with existing logging Co-Authored-By: udit@cal.com <udit222001@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
✅ No security or compliance issues detected. Reviewed everything up to 447ee7d. Security Overview
Detected Code ChangesThe diff is too large to display a summary of code changes. Reply to this PR with |
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (07/08/25)1 reviewer was added to this PR based on Keith Williams's automation. |
…g logger - Enhance TraceContext to include event-specific context (eventTypeSlug, userInfo) - Update DistributedTracing.getTracingLogger to include event context in prefix - Replace all loggerWithEventDetails usages with tracingLogger in handleNewBooking.ts - Add traceId to frontend error display for user support - Maintain backward compatibility while improving observability Co-Authored-By: udit@cal.com <udit222001@gmail.com>
…files - Add trace context support to ensureAvailableUsers, validateBookingTimeIsNotOutOfBounds, validateEventLength - Update seated booking reschedule functions to use distributed tracing - Ensure all booking flow components support trace context propagation - Maintain backward compatibility while enhancing observability Co-Authored-By: udit@cal.com <udit222001@gmail.com>
- Update defaultResponder to extract and include traceId in error responses - Add distributed tracing to api/book/event endpoint with trace context - Include traceId in error data when booking API throws exceptions - Enable frontend to display traceId as Reference ID for user support Co-Authored-By: udit@cal.com <udit222001@gmail.com>
- Modified handleNewBooking to merge passed traceContext with additional properties instead of creating new one - Fixed type error in defaultResponder.ts by adding proper type checking for traceId - Ensures same traceId flows through entire booking process as requested by user Co-Authored-By: udit@cal.com <udit222001@gmail.com>
- Add bookingUid and userId to getTracingLogger prefixes for better context - Update createLoggerWithEventDetails to accept existing trace context parameter - Allow reusing existing trace contexts instead of always creating new ones - Maintain same traceId throughout booking flow while adding event-specific details Co-Authored-By: udit@cal.com <udit222001@gmail.com>
Co-Authored-By: udit@cal.com <udit222001@gmail.com>
…tor approach Co-Authored-By: udit@cal.com <udit222001@gmail.com>
ccb4c2b to
b4639e2
Compare
There was a problem hiding this comment.
cubic found 19 issues across 26 files. Review them in cubic.dev
React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.
packages/features/bookings/lib/handleNewBooking/validateEventLength.ts
Outdated
Show resolved
Hide resolved
packages/features/bookings/Booker/components/BookEventForm/BookEventForm.tsx
Outdated
Show resolved
Hide resolved
…ipt error Co-Authored-By: udit@cal.com <udit222001@gmail.com>
| // These used to come from headers but now we're passing them as params | ||
| hostname?: string; | ||
| forcedSlug?: string; | ||
| traceContext?: TraceContext; |
There was a problem hiding this comment.
This is called by API v1, web app etc. so making it optional for now. In a follow up PR this would also become required after some testing
|
This PR is being marked as stale due to inactivity. |
feat: Add distributed tracing for booking flow correlation
Part of #22969
Follow up:-
distributedTracerSummary
This PR implements distributed tracing for Cal.com's booking flow to improve observability and debugging capabilities beyond the current per-request ID system. The implementation adds trace context propagation across multiple booking operations including calendar events, payment processing, webhook execution, and scheduled reminders.
Key Changes:
packages/lib/tracing.ts) - Centralized trace context management with hierarchical spanshandleNewBooking.tsBenefits over current request ID system:
Review & Testing Checklist for Human
Recommended test plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TD %% Main booking flow handleNewBooking["packages/features/bookings/lib/handleNewBooking.ts"]:::major-edit tracing["packages/lib/tracing.ts"]:::major-edit EventManager["packages/lib/EventManager.ts"]:::major-edit %% Webhook flow scheduleTrigger["packages/features/webhooks/lib/scheduleTrigger.ts"]:::major-edit handleWebhookScheduledTriggers["packages/features/webhooks/lib/handleWebhookScheduledTriggers.ts"]:::major-edit handleWebhookTrigger["packages/features/bookings/lib/handleWebhookTrigger.ts"]:::minor-edit %% Payment flow handlePaymentSuccess["packages/lib/payment/handlePaymentSuccess.ts"]:::minor-edit %% Seat booking flow handleSeats["packages/features/bookings/lib/handleSeats/handleSeats.ts"]:::major-edit scheduleNoShowTriggers["packages/features/bookings/lib/handleNewBooking/scheduleNoShowTriggers.ts"]:::minor-edit %% Reminder flow scheduleMandatoryReminder["packages/features/ee/workflows/lib/reminders/scheduleMandatoryReminder.ts"]:::minor-edit reminderScheduler["packages/features/ee/workflows/lib/reminders/reminderScheduler.ts"]:::minor-edit %% Documentation debuggingExamples["examples/distributed-tracing-debugging.md"]:::major-edit axiomQueries["examples/axiom-tracing-queries.md"]:::major-edit %% Flow connections handleNewBooking --> tracing handleNewBooking --> EventManager handleNewBooking --> scheduleTrigger handleNewBooking --> handleSeats scheduleTrigger --> handleWebhookScheduledTriggers handleWebhookScheduledTriggers --> handleWebhookTrigger handleNewBooking --> handlePaymentSuccess handleSeats --> scheduleMandatoryReminder handleNewBooking --> scheduleNoShowTriggers scheduleMandatoryReminder --> reminderScheduler %% Legend subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end %% Styling classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Implementation approach:
Axiom integration:
Link to Devin run: https://app.devin.ai/sessions/d494fd7f104f4339a390e492f94bd47a
Requested by: @Udit-takkar