Skip to content

Commit 97100fb

Browse files
heiskrCopilot
andauthored
Emit heap/RSS gauges on every healthcheck hit (#60227)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent eca7b0e commit 97100fb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/frame/middleware/healthcheck.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import express from 'express'
22
import { noCacheControl } from './cache-control'
3+
import statsd from '@/observability/lib/statsd'
34

45
const router = express.Router()
56

@@ -12,6 +13,12 @@ const router = express.Router()
1213
router.get('/', function healthcheck(req, res) {
1314
noCacheControl(res)
1415

16+
const mem = process.memoryUsage()
17+
statsd.gauge('memory_heap_used', mem.heapUsed, ['event:healthcheck'])
18+
statsd.gauge('memory_heap_total', mem.heapTotal, ['event:healthcheck'])
19+
statsd.gauge('memory_rss', mem.rss, ['event:healthcheck'])
20+
statsd.gauge('memory_external', mem.external, ['event:healthcheck'])
21+
1522
res.sendStatus(200)
1623
})
1724

0 commit comments

Comments
 (0)