refactor/Optimize elastic search initialization

This commit is contained in:
Marko Milić 2023-10-27 09:21:54 +02:00
parent 64c089e740
commit 66bbf50768
2 changed files with 2 additions and 2 deletions

View File

@ -11,7 +11,7 @@ import scala.concurrent.Future
object ElasticsearchMetrics extends APIMetrics {
val es = new elasticsearchMetrics
lazy val es = new elasticsearchMetrics
override def saveMetric(userId: String, url: String, date: Date, duration: Long, userName: String, appName: String, developerEmail: String, consumerId: String, implementedByPartialFunction: String, implementedInVersion: String, verb: String, httpCode: Option[Int], correlationId: String): Unit = {
if (APIUtil.getPropsAsBoolValue("allow_elasticsearch", false) && APIUtil.getPropsAsBoolValue("allow_elasticsearch_metrics", false) ) {

View File

@ -242,7 +242,7 @@ class elasticsearchMetrics extends elasticsearch {
if (esIndex.contains(",")) throw new RuntimeException("Props error: es.metrics.index can not be a list")
val props = ElasticProperties(s"http://$esHost:${esPortTCP.toInt}")
val client = ElasticClient(JavaClient(props))
lazy val client = ElasticClient(JavaClient(props))
// we must import the dsl
import com.sksamuel.elastic4s.ElasticDsl._