Repository navigation
Commit 4ddeac2
[fix](metrics) Write a null label value as null in the Prometheus output of FE
### What problem does this PR solve?
Issue Number: #69907
Related PR: #69837
Problem Summary:
`escapeLabelValue` called `replace` on every label value, so a null one threw a NullPointerException, and nothing on the way to `/metrics` catches it: `DorisMetricRegistry.accept`, `MetricRepo.getMetric` and `MetricsAction` let it through, and the whole response fails. Label values can be null: a table warm-up job (`WARM UP COMPUTE GROUP <dst> WITH TABLE ...`) has no source cluster, so `CloudWarmUpJob` keeps its `srcClusterName` null, and the job registers `doris_fe_file_cache_warm_up_job_latest_start_time` each time it starts and `doris_fe_file_cache_warm_up_job_last_finish_time` when it is cancelled, both with `src_cluster_name` set to null. Neither series is ever removed, so in cloud mode the first table warm-up job to start made every scrape of the Master FE's `/metrics` fail until the FE restarted. The registry itself already accepts a null label value (`computeLabelId` maps it to an empty string). Before label values were escaped, the string concatenation wrote it as `null`.
`escapeLabelValue` now writes a null value as `null`, so the output is again unchanged for every value without a backslash, a double quote or a line feed.
### Release note
None
### Check List (For Author)
- Test: Unit Test
- `MetricsTest#testPrometheusVisitorWritesNullLabelValue`: a gauge and a labeled histogram with a null label value are written with `null`; without this fix the case fails with a NullPointerException.
- Behavior changed: No
- Does this need documentation: No
Co-Authored-By: Claude Opus 5.5 <[email protected]>1 parent 8a9f618 commit 4ddeac2
2 files changed
Lines changed: 28 additions & 2 deletions
File tree
- fe/fe-core/src
- main/java/org/apache/doris/metric
- test/java/org/apache/doris/metric
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
370 | | - | |
| 370 | + | |
| 371 | + | |
371 | 372 | | |
372 | | - | |
| 373 | + | |
373 | 374 | | |
374 | 375 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
381 | 406 | | |
382 | 407 | | |
383 | 408 | | |
| |||
0 commit comments