Skip to content

Open-source status page, incident response and uptime monitoring

🔥 improvment (#874)

Thibault Le Ouayf1457bb4afcd
diff --git a/apps/checker/cmd/main.go b/apps/checker/cmd/main.go
index 2a8461abc..f0f0551a1 100644
--- a/apps/checker/cmd/main.go
+++ b/apps/checker/cmd/main.go
@@ -260,8 +260,12 @@ func main() {
if err != nil {
return fmt.Errorf("unable to ping: %w", err)
}
+
r.Region = flyRegion
+
res = r
+ res.RequestId = req.RequestId
+ res.WorkspaceId = req.WorkspaceId
if err := tinybirdClient.SendEvent(ctx, res, dataSourceName); err != nil {
log.Ctx(ctx).Error().Err(err).Msg("failed to send event to tinybird")
}
diff --git a/apps/checker/ping.go b/apps/checker/ping.go
index 0424b4874..367ee8d01 100644
--- a/apps/checker/ping.go
+++ b/apps/checker/ping.go
@@ -49,15 +49,17 @@ type Timing struct {
}
type Response struct {
- Status int `json:"status,omitempty"`
- Latency int64 `json:"latency"`
- Body string `json:"body,omitempty"`
- Headers map[string]string `json:"headers,omitempty"`
- Time int64 `json:"time"`
- Timing Timing `json:"timing"`
- Error string `json:"error,omitempty"`
- Tags []string `json:"tags,omitempty"`
- Region string `json:"region"`
+ RequestId int64 `json:"requestId,omitempty"`
+ WorkspaceId int64 `json:"workspaceId,omitempty"`
+ Status int `json:"status,omitempty"`
+ Latency int64 `json:"latency"`
+ Body string `json:"body,omitempty"`
+ Headers map[string]string `json:"headers,omitempty"`
+ Time int64 `json:"time"`
+ Timing Timing `json:"timing"`
+ Error string `json:"error,omitempty"`
+ Tags []string `json:"tags,omitempty"`
+ Region string `json:"region"`
}
func Ping(ctx context.Context, client *http.Client, inputData request.CheckerRequest) (PingData, error) {
diff --git a/apps/checker/request/request.go b/apps/checker/request/request.go
index 972643fcd..6b54e75e1 100644
--- a/apps/checker/request/request.go
+++ b/apps/checker/request/request.go
@@ -59,9 +59,10 @@ type CheckerRequest struct {
}
type PingRequest struct {
- ID string `json:"id"`
- URL string `json:"url"`
- Method string `json:"method"`
- Body string `json:"body"`
- Headers map[string]string `json:"headers"`
+ RequestId int64 `json:"requestId"`
+ WorkspaceId int64 `json:"workspaceId"`
+ URL string `json:"url"`
+ Method string `json:"method"`
+ Body string `json:"body"`
+ Headers map[string]string `json:"headers"`
}
diff --git a/apps/server/src/v1/check/post.ts b/apps/server/src/v1/check/post.ts
index 43bc45114..950c4988f 100644
--- a/apps/server/src/v1/check/post.ts
+++ b/apps/server/src/v1/check/post.ts
@@ -45,7 +45,7 @@ const postRoute = createRoute({
export function registerPostCheck(api: typeof checkAPI) {
return api.openapi(postRoute, async (c) => {
const data = c.req.valid("json");
- const workspaceId = c.get("workspaceId");
+ const workspaceId = Number(c.get("workspaceId"));
const input = c.req.valid("json");
const { headers, regions, runCount, aggregated, ...rest } = data;
@@ -72,7 +72,7 @@ export function registerPostCheck(api: typeof checkAPI) {
},
method: "POST",
body: JSON.stringify({
- checkId: newCheck.id,
+ requestId: newCheck.id,
workspaceId: workspaceId,
url: input.url,
method: input.method,
@@ -195,7 +195,7 @@ export function registerPostCheck(api: typeof checkAPI) {
aggregatedResponse = AggregatedResult.parse({
dns: aggregatedDNS,
- connection: aggregatedConnect,
+ connect: aggregatedConnect,
tls: aggregatedTls,
firstByte: aggregatedFirst,
transfer: aggregatedTransfer,