Merge pull request #5152 from GogoVega/improve-telemetry

Import `got` module only once when sending metrics
This commit is contained in:
Nick O'Leary
2025-06-06 09:44:51 +01:00
committed by GitHub

View File

@@ -6,6 +6,9 @@ const cronosjs = require('cronosjs')
const METRICS_DIR = path.join(__dirname, 'metrics')
const INITIAL_PING_DELAY = 1000 * 60 * 30 // 30 minutes from startup
/** @type {import("got").Got | undefined} */
let got
let runtime
let scheduleTask
@@ -48,11 +51,13 @@ async function report () {
}
// If enabled, gather metrics
const metrics = await gather()
console.log(JSON.stringify(metrics, null, 2))
// Post metrics to endpoint - handle any error silently
const { got } = await import('got')
if (!got) {
got = (await import('got')).got
}
runtime.log.debug('Sending telemetry')
const response = await got.post('https://telemetry.nodered.org/ping', {
json: metrics,