From 70aeb2cfb5cb189bbd460d6f19041eedeb842fc4 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 20 Aug 2024 16:42:13 +0200 Subject: [PATCH] Delete also the former index when restarting event metrics (#5111) Co-authored-by: Simon Dumas --- .../elasticsearch/EventMetricsProjection.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/EventMetricsProjection.scala b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/EventMetricsProjection.scala index 3d7788fa96..a4d2aa4c5a 100644 --- a/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/EventMetricsProjection.scala +++ b/delta/plugins/elasticsearch/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/elasticsearch/EventMetricsProjection.scala @@ -81,11 +81,12 @@ object EventMetricsProjection { for { shouldRestart <- Env[IO].get("RESET_EVENT_METRICS").map(_.getOrElse("false").toBoolean) - _ <- IO.whenA(shouldRestart)( - logger.warn("Resetting event metrics as the env RESET_EVENT_METRICS is set") >> projections.reset( - projectionMetadata.name - ) - ) + _ <- IO.whenA(shouldRestart) { + client.deleteIndex(index) >> + logger.warn("Resetting event metrics as the env RESET_EVENT_METRICS is set") >> projections.reset( + projectionMetadata.name + ) + } metricsProjection <- apply(sink, supervisor, metrics, createIndex) } yield (metricsProjection)