Repository navigation
Read Nezha v2 monitor names for the latency rows - #2
Open
Hansen1018 wants to merge 2 commits into
Open
Hansen1018 wants to merge 2 commits into
Hansen1018 wants to merge 2 commits into
Conversation
Nezha v2 renamed the service fields: model.ServiceInfos is serialised with the JSON tags "monitor_id" / "monitor_name" (model/service_history_api.go, v2.0.0 onwards). Nezha v1 sent them as "service_id" / "service_name". The adapter read the v1 spelling, so on a v2 panel every latency row had an undefined name and an undefined id: the rows showed a bare colour dash, and all points collapsed onto one series in the chart. Both spellings are read now, with the v1 names kept as a fallback.
Author
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.


🔖 Type of Change
Affected Area
What
The latency rows on a Nezha v2 panel have no name: each row shows only the colour dash, and every point collapses onto a single chart series.
Why
Nezha v2 renamed the two fields the dashboard sends.
model.ServiceInfosis serialised with the JSON tagsmonitor_id/monitor_name(model/service_history_api.go, v2.0.0 onwards); Nezha v1 sent them asservice_id/service_name.The adapter read the v1 spelling only, so against a v2 panel every entry came back with
name === undefinedandid === undefined: the row label rendered as an empty string next to the colour dash, andid: undefinedmade every task share one key, so the chart drew all points as a single series instead of one line per monitor.Both spellings are read now, with the v1 names kept as a fallback for v1 panels. Nothing else changes: no styles, no layout, no new fields.
Verification
pnpm checkpasses: typecheck, 219 tests, and the i18n check.tests/nezha-ping.test.tscovers the v2 payload, the v1 payload and the per-task point split.pnpm buildand checked on a Nezha v2.4.1 panel: the four latency rows now carry their monitor names (China Telecom - Hebei, China Unicom - Langfang (Hebei), China Mobile - Hebei, China Telecom - Shenzhen (Guangdong)), and the chart draws one line per monitor.