We are creating environment variable like this.
logger.info(marker, "Couchbase## initializeBuckets tracerConfig start time {}", LocalDateTime.now());
ThresholdLoggingTracerConfig.Builder tracer = ThresholdLoggingTracerConfig.builder()
.emitInterval(Duration.ofMillis(tracerConfig.getLong("emitInterval", 20000L)))
.kvThreshold(Duration.ofMillis(tracerConfig.getLong("kvThreshold", 20000L)))
.queryThreshold(Duration.ofMillis(tracerConfig.getLong("n1qlThreshold", 60000L)))
.sampleSize(tracerConfig.getInteger("sampleSize", 5)).searchThreshold(Duration.ofSeconds(60));
logger.info(marker, "Couchbase## initializeBuckets before environment time {}", LocalDateTime.now());
environment = ClusterEnvironment.builder()
.thresholdLoggingTracerConfig(tracer)
.retryStrategy(BestEffortRetryStrategy.INSTANCE)
.ioConfig(IoConfig.enableDnsSrv(false))
.timeoutConfig(TimeoutConfig.connectTimeout(Duration.ofMillis(
couchbaseConfig.getLong(CONNECT_TIMEOUT, CONNECT_TIMEOUT_DEFAULT_VALUE)))
.queryTimeout(Duration.ofMillis(couchbaseConfig.
getLong(QUERY_TIMEOUT, QUERY_TIMEOUT_DEFAULT_VALUE)))
.kvTimeout(Duration.ofMillis(couchbaseConfig.getLong(KV_TIMEOUT, KV_TIMEOUT_DEFAULT_VALUE))))
.build();
logger.info(marker, "Couchbase## initializeBuckets after environment time {}", LocalDateTime.now());
It takes around 6-8 seconds to crate environment environment variable. Even if we remove thresholdLoggingTracerConfig or use just below code to create default environment, it remains same.
environment = ClusterEnvironment.builder()
Is any better way to optimize this creation and also can you please help me to understand why it takes this much time to create environment.