moaead opened a new pull request, #3998: URL: https://github.com/apache/hertzbeat/pull/3998
## What's changed? Fix inconsistent key generation for metrics in `metricsTimeoutMonitorMap` that caused incomplete monitoring task execution. ### Problem When a job has multiple metrics using Prometheus protocol, all metrics were stored with the same key (`job.getId()`) in the timeout monitor map, causing later metrics to overwrite earlier ones. This resulted in: - Only the last metric being tracked for timeout monitoring - Earlier metrics' execution being silently discarded when they completed - Incomplete monitoring results (e.g., Flink on YARN showing only 1 of multiple expected tasks) ### Root Cause In `dispatchMetricsTask()`, Prometheus metrics used `String.valueOf(job.getId())` as the map key, while non-Prometheus metrics correctly used `job.getId() + "-" + metrics.getName()`. The `dispatchCollectData()` method for single metrics retrieval used the latter format, causing a mismatch. ### Solution Use consistent key format `job.getId() + "-" + metrics.getName()` for all metrics types, ensuring each metric has a unique key in the timeout monitor map. ### Changes - `CommonDispatcher.java:dispatchMetricsTask()` - Removed conditional key generation, now uses consistent format for all metrics - `CommonDispatcher.java:dispatchCollectData(List)` - Updated to use consistent key format for retrieval Fixes #3995 ## Checklist - [x] I have read the [Contributing Guide](https://hertzbeat.apache.org/docs/community/code_style_and_quality_guide) - [x] I have written the necessary doc or comment. - [x] I have added the necessary unit tests and all cases have passed. ## Add or update API - [ ] I have added the necessary [e2e tests](https://github.com/apache/hertzbeat/tree/master/e2e) and all cases have passed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
