From cb962304e538e660aabef2fe6bc2f224746d0ed8 Mon Sep 17 00:00:00 2001 From: zwangsheng <2213335496@qq.com> Date: Thu, 23 Mar 2023 18:01:16 +0800 Subject: [PATCH] [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 --- .../scala/org/apache/kyuubi/metrics/JsonReporterService.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/JsonReporterService.scala b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/JsonReporterService.scala index cb0ef7404..7b172fc1e 100644 --- a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/JsonReporterService.scala +++ b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/JsonReporterService.scala @@ -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() }