fix: handle numeric JSON values from Gen2 Miniserver endpoints - #98
Merged
Conversation
Gen2 Miniservers (firmware 16.x) return numeric values without quotes
for counter endpoints like contextswitches, ints, comints, and
contextswitchesi — e.g. `"value": 123456` instead of `"value": "123"`.
The xml_attr JSON branch only matched string values ("value": "..."),
so these counters silently returned empty strings, causing blank rows
in `lox status --diag` and missing OTLP metrics.
Fixes:
- xml_attr: handle both quoted and unquoted JSON values
- extract_lox_value (OTLP): try as_f64() before as_str() so numeric
JSON values are picked up for gauge/counter recording
- Diagnostics display: skip interrupt/ctx-switch rows when the
endpoint returns no data (instead of showing blank lines)
Adds 3 new tests: xml_attr_json_numeric_value,
xml_attr_json_numeric_last_field, extract_lox_value_json_numeric.
Adds 12 new tests to prevent future regressions when the Miniserver returns non-string JSON values: xml_attr tests (8 new): - json_float_value, json_negative_value, json_zero_value - json_bool_value, json_null_value - all_diagnostic_response_formats (exercises every diag endpoint in both Gen1 XML and Gen2 JSON-numeric format) extract_lox_value tests (4 new): - json_numeric_float, json_numeric_zero - all_diagnostic_formats (covers every OTLP-exported endpoint)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #98 +/- ##
==========================================
+ Coverage 24.88% 24.97% +0.08%
==========================================
Files 16 16
Lines 4629 4649 +20
==========================================
+ Hits 1152 1161 +9
- Misses 3477 3488 +11
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lox status --diagshowed blank values for context switches, interrupts, comm interrupts, and ctx switches (idle) on Gen2 Miniservers (firmware 16.x)xml_attrJSON branch only matched string values ("value": "text"), but Gen2 returns numeric counters without quotes ("value": 123456)lox otel serve/push—extract_lox_valueusedas_str()which skips numeric JSON values, so OTLP metrics for these endpoints were silently droppedFixed
xml_attr: handle both quoted string and unquoted numeric/bool/null JSON valuesextract_lox_value(OTLP): tryas_f64()beforeas_str()for JSON valuesRegression tests added (12 new)
xml_attr: float, negative, zero, bool, null, and a comprehensive test exercising all diagnostic endpoints in both Gen1 XML and Gen2 JSON-numeric formatsextract_lox_value: numeric float, numeric zero, and a comprehensive test covering every OTLP-exported endpointTotal: 287 tests (194 unit + 93 integration)
Test plan
cargo fmt --check— cleancargo clippy -- -D warnings— cleancargo build --release— passescargo test— 287 tests passlox status --diagon Gen2 Miniserver shows interrupt/ctx-switch valueslox otel pushexportsloxone.system.interruptsetc. as metrics