From bc3f4dd032a744f8ca9d66587cfef6842e5f3fa7 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 10 Apr 2026 09:33:14 +0400 Subject: [PATCH] update include timings --- apps/api/src/routes/pings.ts | 10 ++++++++-- apps/monitor/src/runner.rs | 12 ++++++++++++ apps/monitor/src/types.rs | 3 +++ apps/shared/db.ts | 5 ++++- apps/web/src/views/detail.ejs | 10 ++++++++++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/apps/api/src/routes/pings.ts b/apps/api/src/routes/pings.ts index dfa060d..7786567 100644 --- a/apps/api/src/routes/pings.ts +++ b/apps/api/src/routes/pings.ts @@ -132,7 +132,7 @@ export const ingest = new Elysia() `; const [ping] = await sql` - INSERT INTO pings (monitor_id, checked_at, scheduled_at, jitter_ms, status_code, latency_ms, up, important, error, meta, region, run_id, cert_expiry_days, cert_issuer, response_size) + INSERT INTO pings (monitor_id, checked_at, scheduled_at, jitter_ms, status_code, latency_ms, up, important, error, meta, region, run_id, cert_expiry_days, cert_issuer, response_size, dns_ms, tcp_ms, tls_ms) VALUES ( ${body.monitor_id}, ${checkedAt ?? sql`now()`}, @@ -148,7 +148,10 @@ export const ingest = new Elysia() ${body.run_id ?? null}, ${body.cert_expiry_days ?? null}, ${body.cert_issuer ?? null}, - ${body.response_size ?? null} + ${body.response_size ?? null}, + ${body.dns_ms ?? null}, + ${body.tcp_ms ?? null}, + ${body.tls_ms ?? null} ) RETURNING * `; @@ -200,6 +203,9 @@ export const ingest = new Elysia() cert_expiry_days: t.Optional(t.Nullable(t.Number())), cert_issuer: t.Optional(t.Nullable(t.String())), response_size: t.Optional(t.Nullable(t.Number())), + dns_ms: t.Optional(t.Nullable(t.Number())), + tcp_ms: t.Optional(t.Nullable(t.Number())), + tls_ms: t.Optional(t.Nullable(t.Number())), meta: t.Optional(t.Any()), region: t.Optional(t.Nullable(t.String())), run_id: t.Optional(t.Nullable(t.String())), diff --git a/apps/monitor/src/runner.rs b/apps/monitor/src/runner.rs index b36e6ed..59c98c1 100644 --- a/apps/monitor/src/runner.rs +++ b/apps/monitor/src/runner.rs @@ -121,6 +121,9 @@ pub async fn fetch_and_run( cert_expiry_days: None, cert_issuer: None, response_size: None, + dns_ms: None, + tcp_ms: None, + tls_ms: None, meta: None, region: Some(region_owned.to_string()), run_id: Some(run_id_owned.clone()), @@ -198,6 +201,9 @@ async fn run_check(monitor: &Monitor, scheduled_at: Option, region: &str cert_expiry_days: None, cert_issuer: None, response_size: None, + dns_ms: None, + tcp_ms: None, + tls_ms: None, meta: None, region: Some(region.to_string()), run_id: Some(run_id.to_string()), @@ -216,6 +222,9 @@ async fn run_check(monitor: &Monitor, scheduled_at: Option, region: &str cert_expiry_days: None, cert_issuer: None, response_size: None, + dns_ms: None, + tcp_ms: None, + tls_ms: None, meta: None, region: Some(region.to_string()), run_id: Some(run_id.to_string()), @@ -267,6 +276,9 @@ async fn run_check(monitor: &Monitor, scheduled_at: Option, region: &str cert_expiry_days: cr.cert_expiry_days, cert_issuer: cr.cert_issuer, response_size: Some(cr.body.len()), + dns_ms: Some(cr.dns_ms), + tcp_ms: Some(cr.tcp_ms), + tls_ms: Some(cr.tls_ms), meta: Some(meta), region: Some(region.to_string()), run_id: Some(run_id.to_string()), diff --git a/apps/monitor/src/types.rs b/apps/monitor/src/types.rs index 8b27535..b1260ef 100644 --- a/apps/monitor/src/types.rs +++ b/apps/monitor/src/types.rs @@ -51,6 +51,9 @@ pub struct PingResult { pub cert_expiry_days: Option, pub cert_issuer: Option, pub response_size: Option, + pub dns_ms: Option, + pub tcp_ms: Option, + pub tls_ms: Option, pub meta: Option, pub region: Option, pub run_id: Option, diff --git a/apps/shared/db.ts b/apps/shared/db.ts index 31b22ee..2b64b49 100644 --- a/apps/shared/db.ts +++ b/apps/shared/db.ts @@ -62,7 +62,10 @@ export async function migrate(sql: any) { run_id TEXT, cert_expiry_days INTEGER, cert_issuer TEXT, - response_size INTEGER + response_size INTEGER, + dns_ms INTEGER, + tcp_ms INTEGER, + tls_ms INTEGER ) `; await sql`CREATE INDEX IF NOT EXISTS idx_pings_monitor ON pings(monitor_id, checked_at DESC)`; diff --git a/apps/web/src/views/detail.ejs b/apps/web/src/views/detail.ejs index 0748dc6..a3580f5 100644 --- a/apps/web/src/views/detail.ejs +++ b/apps/web/src/views/detail.ejs @@ -373,6 +373,16 @@ if (ping.cert_expiry_days != null) html += `
Cert expiry
${ping.cert_expiry_days} days
`; if (ping.cert_issuer) html += `
Cert issuer
${escapeHtml(ping.cert_issuer)}
`; if (ping.response_size != null) html += `
Response size
${ping.response_size >= 1024 ? (ping.response_size / 1024).toFixed(1) + ' KB' : ping.response_size + ' B'}
`; + if (ping.dns_ms != null || ping.tcp_ms != null || ping.tls_ms != null) { + html += `
Timing
`; + const parts = []; + if (ping.dns_ms != null) parts.push('DNS ' + ping.dns_ms + 'ms'); + if (ping.tcp_ms != null) parts.push('TCP ' + ping.tcp_ms + 'ms'); + if (ping.tls_ms != null) parts.push('TLS ' + ping.tls_ms + 'ms'); + parts.push('HTTP ' + (ping.latency_ms || 0) + 'ms'); + html += parts.join(' / '); + html += `
`; + } if (ping.important) html += `
Important
Yes
`; html += '';