[KYUUBI #4563] [Improvement] Format error log output in case of metrics json file not found

### _Why are the changes needed?_

Before
```log
2023-03-20 10:02:04.718 ERROR org.apache.kyuubi.metrics.JsonReporterService: Error writing metrics to json file/pathi/metrics/report.json
```

After
```log
2023-03-20 10:02:04.718 ERROR org.apache.kyuubi.metrics.JsonReporterService: Error writing metrics to json file: /path/metrics/report.json
```

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #4563 from zwangsheng/fix/format_json_file_not_found_error.

Closes #4563

7b37616a3 [Binjie Yang] Update kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/JsonReporterService.scala
daace3598 [zwangsheng] [Improvement] Format error log output in case of metrics json file not found

Lead-authored-by: zwangsheng <2213335496@qq.com>
Co-authored-by: Binjie Yang <52876270+zwangsheng@users.noreply.github.com>
Signed-off-by: liangbowen <liangbowen@gf.com.cn>
This commit is contained in:
zwangsheng 2023-03-23 18:01:16 +08:00 committed by liangbowen
parent e39bddab91
commit cb962304e5

View File

@ -65,7 +65,7 @@ class JsonReporterService(registry: MetricRegistry)
Files.setPosixFilePermissions(tmpPath, PosixFilePermissions.fromString("rwxr--r--"))
Files.move(tmpPath, reportPath, StandardCopyOption.REPLACE_EXISTING)
} catch {
case NonFatal(e) => error("Error writing metrics to json file" + reportPath, e)
case NonFatal(e) => error(s"Error writing metrics to json file: $reportPath", e)
} finally {
if (writer != null) writer.close()
}