Openstatus www.openstatus.dev

🪵 more logs (#1474)

* more logs

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

authored by

Thibault Le Ouay
autofix-ci[bot]
and committed by
GitHub
82902360 f3e7cf88

+17 -10
+8 -5
apps/workflows/src/checker/alerting.ts
··· 6 6 selectWorkspaceSchema, 7 7 } from "@openstatus/db/src/schema"; 8 8 9 + import { getLogger } from "@logtape/logtape"; 9 10 import type { Region } from "@openstatus/db/src/schema/constants"; 10 11 import { checkerAudit } from "../utils/audit-log"; 11 12 import { providerToFunction } from "./utils"; 13 + 14 + const logger = getLogger("api-server"); 12 15 13 16 export const triggerNotifications = async ({ 14 17 monitorId, ··· 90 93 .all(); 91 94 92 95 if ((smsSent[0]?.count ?? 0) > data.limits["sms-limit"]) { 93 - console.log( 96 + logger.warn( 94 97 `SMS quota exceeded for workspace ${notif.notification.workspaceId}`, 95 98 ); 96 99 continue; 97 100 } 98 101 } 99 - console.log( 102 + logger.info( 100 103 `💌 sending notification for ${monitorId} and chanel ${notif.notification.provider} for ${notifType}`, 101 104 ); 102 105 const monitor = selectMonitorSchema.parse(notif.monitor); ··· 107 110 cronTimestamp: cronTimestamp, 108 111 }); 109 112 } catch (_e) { 110 - console.log("notification trigger already exists dont send again"); 113 + logger.error("notification trigger already exists dont send again"); 111 114 continue; 112 115 } 113 116 switch (notifType) { ··· 202 205 set: { status, updatedAt: new Date() }, 203 206 }) 204 207 .returning(); 205 - console.log(`📈 upsertMonitorStatus for ${monitorId} in region ${region}`); 206 - console.log(`🤔 upsert monitor ${JSON.stringify(newData)}`); 208 + logger.info(`📈 upsertMonitorStatus for ${monitorId} in region ${region}`); 209 + logger.info("🤔 upsert monitor {*}", { ...newData }); 207 210 };
+9 -5
apps/workflows/src/cron/checker.ts
··· 17 17 import { db } from "../lib/db"; 18 18 19 19 import { getSentry } from "@hono/sentry"; 20 + import { getLogger } from "@logtape/logtape"; 20 21 import type { monitorPeriodicitySchema } from "@openstatus/db/src/schema/constants"; 21 22 import { 22 23 type httpPayloadSchema, ··· 29 30 export const isAuthorizedDomain = (url: string) => { 30 31 return url.includes(env().SITE_URL); 31 32 }; 33 + 34 + const logger = getLogger("api-server"); 32 35 33 36 const channelOptions = { 34 37 // Conservative 5-minute keepalive (gRPC best practice) ··· 89 92 ) 90 93 .all(); 91 94 92 - console.log(`Start cron for ${periodicity}`); 95 + logger.info(`Start cron for ${periodicity}`); 93 96 94 97 const monitors = z.array(selectMonitorSchema).safeParse(result); 95 98 const allResult = []; 96 99 if (!monitors.success) { 97 - console.error(`Error while fetching the monitors ${monitors.error.errors}`); 100 + logger.error(`Error while fetching the monitors ${monitors.error.errors}`); 98 101 throw new Error("Error while fetching the monitors"); 99 102 } 100 103 ··· 121 124 const r = regionDict[region as keyof typeof regionDict]; 122 125 123 126 if (!r) { 124 - console.error(`Invalid region ${region}`); 127 + logger.error(`Invalid region ${region}`); 125 128 continue; 126 129 } 127 130 if (r.deprecated) { 128 131 // Let's uncomment this when we are ready to remove deprecated regions 129 132 // We should not use deprecated regions anymore 130 - console.error(`Deprecated region ${region}`); 133 + logger.error(`Deprecated region ${region}`); 131 134 continue; 132 135 } 133 136 const response = createCronTask({ ··· 160 163 const success = allRequests.filter((r) => r.status === "fulfilled").length; 161 164 const failed = allRequests.filter((r) => r.status === "rejected").length; 162 165 163 - console.log( 166 + logger.info( 164 167 `End cron for ${periodicity} with ${allResult.length} jobs with ${success} success and ${failed} failed`, 165 168 ); 166 169 if (failed > 0) { 170 + logger.error("error with cron jobs"); 167 171 getSentry(c).captureMessage( 168 172 `sendCheckerTasks for ${periodicity} ended with ${failed} failed tasks`, 169 173 "error",