refactor(telemetry): unify localStats/host/trafficManagement onto buildCanonicalMetrics (#3515)#3518
Conversation
…ldCanonicalMetrics (#3515) Follow-up to #3506: convert the last three serial telemetry branches (localStats, hostMetrics, trafficManagementStats) from hand-maintained { type, value, unit } lists onto the shared buildCanonicalMetrics() path, so all seven metric groups go through one normalizer. These three use distinct naming conventions, so canonicalTelemetryType is extended to reproduce them exactly: - localStats joins STRIP_GROUPS → bare leaf names (uptimeSeconds, heapFreeBytes…) - host/trafficManagement use a new PREFIX_GROUPS map → host/tm + PascalCase leaf (uptimeSeconds → hostUptimeSeconds, packetsInspected → tmPacketsInspected) Their type→unit entries are added to CANONICAL_TELEMETRY_UNITS (new LOCAL_STATS_UNITS / HOST_UNITS / TRAFFIC_MGMT_UNITS sub-maps), which is required before converting — buildCanonicalMetrics only emits leaves with a known unit. MQTT ingestion only processes device/environment/airQuality/power/health, so extending canonicalTelemetryType for these serial-only groups does not affect MQTT. The localStats checkAutoHeapManagement side-effect is preserved. Behavior-preserving; adds parity tests asserting each branch stores the same types/units/values as before (incl. genuine 0s). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review: refactor(telemetry): unify localStats/host/trafficManagement onto buildCanonicalMetrics
This is a clean, well-scoped refactor. The approach is sound and the PR achieves its goal of unifying all seven telemetry groups onto Positive
Minor observations
const PREFIX_GROUPS: Record<string, string> = {
host: 'host', // group name = prefix
trafficManagement: 'tm', // group name ≠ prefix
};The existing comment covers this, so it's not a blocker, but a brief inline note on the
The comment on line 95-96 correctly notes that
At the packet-log preview path (
humidity: -Infinity, // relativeHumidity canonical is 'humidity'; this is an unknown leaf anyway
SummaryNo blocking issues. The refactor correctly unifies the three serial telemetry branches, maintains behavioral parity, and the test coverage is solid. The minor observations above are all non-blocking nits or pre-existing issues outside the PR's scope. |
…s fields (review #3518) - Correct the NaN/Infinity test comment: humidity IS a known canonical type, excluded by the Number.isFinite guard, not for being unknown. - Note that host's prefix coincidentally equals its group name. - Exercise numPacketsRxBad / numTxDropped end-to-end in the localStats parity test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review: refactor(telemetry): unify localStats/host/trafficManagement onto buildCanonicalMetrics
This is a clean, well-scoped refactor. The approach is sound and the PR achieves its goal of unifying all seven telemetry groups onto Positive
Minor observations
const PREFIX_GROUPS: Record<string, string> = {
host: 'host', // group name = prefix
trafficManagement: 'tm', // group name ≠ prefix
};The existing comment covers this, so it's not a blocker, but a brief inline note on the
The comment on line 95-96 correctly notes that
At the packet-log preview path (
humidity: -Infinity, // relativeHumidity canonical is 'humidity'; this is an unknown leaf anywayThe comment says SummaryNo blocking issues. The refactor correctly unifies the three serial telemetry branches, maintains behavioral parity, and the test coverage is solid. The minor observations above are all non-blocking nits or pre-existing issues outside the PR's scope. |
Summary
Closes #3515. Follow-up to #3506 — converts the last three serial telemetry branches (
localStats,hostMetrics,trafficManagementStats) from hand-maintained{ type, value, unit }lists onto the sharedbuildCanonicalMetrics()path, so all seven metric groups now go through one normalizer.Not a bug fix — a consistency/maintainability item (these three have no
_<digit>fields). From the #3514 review.How the three differing conventions are preserved
localStatsuptimeSeconds,heapFreeBytes)STRIP_GROUPShosthost+PascalCase (hostUptimeSeconds,hostLoad1)PREFIX_GROUPStrafficManagementtm+PascalCase (tmPacketsInspected)PREFIX_GROUPSTheir type→unit entries are added to
CANONICAL_TELEMETRY_UNITS(newLOCAL_STATS_UNITS/HOST_UNITS/TRAFFIC_MGMT_UNITSsub-maps) — required before converting, sincebuildCanonicalMetricsonly emits leaves with a known unit (the parity caveat from the issue).Safety
mqttIngestion.tsonly processesdevice/environment/airQuality/power/health— it never callscanonicalTelemetryTypewith these three group names, so extending the normalizer for them is serial-only.checkAutoHeapManagement(heapFreeBytes)call is kept.0s.Tests
telemetryKeys.test.ts: STRIP for localStats, PREFIX for host/tm, and units for all new canonical types.meshtasticManager.telemetryCanonical.test.ts: end-to-end parity for all three branches.Full suite: 6576 passed, 0 failed.
🤖 Generated with Claude Code