Scheduling infrastructure for absolutely everyone.
perf: Add more specific spans to getBusyTimes (#17437)
Keith Williams6c5b12db57f8
diff --git a/packages/core/getBusyTimes.ts b/packages/core/getBusyTimes.tsindex 7b3db48ad26..c8c62c1ef98 100644--- a/packages/core/getBusyTimes.ts+++ b/packages/core/getBusyTimes.ts@@ -1,5 +1,6 @@import type { Booking, EventType } from "@prisma/client";import { Prisma } from "@prisma/client";+import * as Sentry from "@sentry/nextjs";import { getBusyCalendarTimes } from "@calcom/core/CalendarManager";import dayjs from "@calcom/dayjs";@@ -110,6 +111,7 @@ export async function getBusyTimes(params: {let bookings = params.currentBookings;if (!bookings) {+ const getBookingsForBusyTimesSpan = Sentry.startInactiveSpan({ name: "getBookingsForBusyTimes" });const bookingsSelect = Prisma.validator<Prisma.BookingSelect>()({id: true,uid: true,@@ -180,6 +182,8 @@ export async function getBusyTimes(params: {]);bookings = [...resultOne, ...resultTwo, ...(resultThree ?? [])];++ getBookingsForBusyTimesSpan.end();}const bookingSeatCountMap: { [x: string]: number } = {};@@ -249,6 +253,8 @@ export async function getBusyTimes(params: {}));+ const openSeatsDateRangesSpan = Sentry.startInactiveSpan({ name: "openSeatsDateRanges" });+const openSeatsDateRanges = Object.keys(bookingSeatCountMap).map((key) => {const [start, end] = key.split("<>");return {@@ -257,6 +263,8 @@ export async function getBusyTimes(params: {};});+ openSeatsDateRangesSpan.end();+if (rescheduleUid) {const originalRescheduleBooking = bookings.find((booking) => booking.uid === rescheduleUid);// calendar busy time from original rescheduled booking should not be blocked@@ -268,6 +276,7 @@ export async function getBusyTimes(params: {}}+ const finalizeBusyTimesSpan = Sentry.startInactiveSpan({ name: "finalizeBusyTimes" });const result = subtract(calendarBusyTimes.map((value) => ({...value,@@ -285,6 +294,8 @@ export async function getBusyTimes(params: {})));+ finalizeBusyTimesSpan.end();+/*// TODO: Disabled until we can filter Zoom events by date. Also this is adding too much latency.const videoBusyTimes = (await getBusyVideoTimes(credentials)).filter(notEmpty);