mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 19:16:53 +00:00
refactor/Optimize elastic search initialization
This commit is contained in:
parent
64c089e740
commit
66bbf50768
@ -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) ) {
|
||||
|
||||
@ -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._
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user