From c34f15d4971f028c8b9336d5b3d16df17c43db46 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Fri, 28 Aug 2020 09:48:50 +0200 Subject: [PATCH] participant-integration-api: Create the metrics CSV directory. (#7253) It turns out that if you give the CSV reporter a non-existent directory, it crashes. I did not expect this. This constructs the directory so you don't have to worry about that. CHANGELOG_BEGIN CHANGELOG_END --- .../main/scala/platform/configuration/MetricsReporter.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ledger/participant-integration-api/src/main/scala/platform/configuration/MetricsReporter.scala b/ledger/participant-integration-api/src/main/scala/platform/configuration/MetricsReporter.scala index 81219000b0d..62c206e55e1 100644 --- a/ledger/participant-integration-api/src/main/scala/platform/configuration/MetricsReporter.scala +++ b/ledger/participant-integration-api/src/main/scala/platform/configuration/MetricsReporter.scala @@ -4,7 +4,7 @@ package com.daml.platform.configuration import java.net.{InetSocketAddress, URI} -import java.nio.file.{Path, Paths} +import java.nio.file.{Files, Path, Paths} import com.codahale.metrics import com.codahale.metrics.{MetricRegistry, ScheduledReporter} @@ -26,10 +26,12 @@ object MetricsReporter { } final case class Csv(directory: Path) extends MetricsReporter { - override def register(registry: MetricRegistry): ScheduledReporter = + override def register(registry: MetricRegistry): ScheduledReporter = { + Files.createDirectories(directory) metrics.CsvReporter .forRegistry(registry) .build(directory.toFile) + } } final case class Graphite(address: InetSocketAddress, prefix: Option[String] = None)