tangled
alpha
login
or
join now
openstatus.dev
/
openstatus
5
fork
atom
Openstatus
www.openstatus.dev
5
fork
atom
overview
issues
pulls
pipelines
๐ otel
thibault.tngl.sh
1 year ago
4f8bf68f
09cc4de0
+15
-9
1 changed file
expand all
collapse all
unified
split
apps
web
src
app
api
checker
cron
_cron.ts
+15
-9
apps/web/src/app/api/checker/cron/_cron.ts
···
45
45
const parent = client.queuePath(
46
46
env.GCP_PROJECT_ID,
47
47
env.GCP_LOCATION,
48
48
-
periodicity,
48
48
+
periodicity
49
49
);
50
50
51
51
const timestamp = Date.now();
···
54
54
.select({ id: maintenance.id })
55
55
.from(maintenance)
56
56
.where(
57
57
-
and(lte(maintenance.from, new Date()), gte(maintenance.to, new Date())),
57
57
+
and(lte(maintenance.from, new Date()), gte(maintenance.to, new Date()))
58
58
)
59
59
.as("currentMaintenance");
60
60
···
63
63
.from(maintenancesToMonitors)
64
64
.innerJoin(
65
65
currentMaintenance,
66
66
-
eq(maintenancesToMonitors.maintenanceId, currentMaintenance.id),
66
66
+
eq(maintenancesToMonitors.maintenanceId, currentMaintenance.id)
67
67
);
68
68
69
69
const result = await db
···
73
73
and(
74
74
eq(monitor.periodicity, periodicity),
75
75
eq(monitor.active, true),
76
76
-
notInArray(monitor.id, currentMaintenanceMonitors),
77
77
-
),
76
76
+
notInArray(monitor.id, currentMaintenanceMonitors)
77
77
+
)
78
78
)
79
79
.all();
80
80
···
98
98
const monitorStatus = z.array(selectMonitorStatusSchema).safeParse(result);
99
99
if (!monitorStatus.success) {
100
100
console.error(
101
101
-
`Error while fetching the monitor status ${monitorStatus.error.errors}`,
101
101
+
`Error while fetching the monitor status ${monitorStatus.error.errors}`
102
102
);
103
103
continue;
104
104
}
···
137
137
const failed = allRequests.filter((r) => r.status === "rejected").length;
138
138
139
139
console.log(
140
140
-
`End cron for ${periodicity} with ${allResult.length} jobs with ${success} success and ${failed} failed`,
140
140
+
`End cron for ${periodicity} with ${allResult.length} jobs with ${success} success and ${failed} failed`
141
141
);
142
142
};
143
143
// timestamp needs to be in ms
···
176
176
timeout: row.timeout,
177
177
trigger: "cron",
178
178
otelConfig: row.otelEndpoint
179
179
-
? { endpoint: row.otelEndpoint, headers: row.otelHeaders }
179
179
+
? {
180
180
+
endpoint: row.otelEndpoint,
181
181
+
headers: JSON.parse(row.otelHeaders || ""),
182
182
+
}
180
183
: undefined,
181
184
};
182
185
}
···
192
195
timeout: row.timeout,
193
196
trigger: "cron",
194
197
otelConfig: row.otelEndpoint
195
195
-
? { endpoint: row.otelEndpoint, headers: row.otelHeaders }
198
198
+
? {
199
199
+
endpoint: row.otelEndpoint,
200
200
+
headers: JSON.parse(row.otelHeaders || ""),
201
201
+
}
196
202
: undefined,
197
203
};
198
204
}