Commit 8a707a2e authored by Yauheni Lesnikau's avatar Yauheni Lesnikau
Browse files

customize elastic latency logging, ignore health logging, increase version of spring boot;

parent b636187a
Pipeline #45978 failed with stages
in 59 seconds
This diff is collapsed.
......@@ -36,11 +36,15 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.main.basedir>${project.parent.basedir}</project.main.basedir>
<springboot.version>2.1.7.RELEASE</springboot.version>
<osdu.corelibazure.version>0.9.0-rc1</osdu.corelibazure.version>
<osdu.corelibazure.version>0.9.0</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.9.0</osdu.oscorecommon.version>
<osdu.search-core.version>0.10.0-SNAPSHOT</osdu.search-core.version>
<spatial4j.version>0.7</spatial4j.version>
<jts-io-common.version>1.15.0</jts-io-common.version>
<reactor-netty.version>1.0.7</reactor-netty.version>
<reactor-core.version>3.4.6</reactor-core.version>
<jackson-dataformat-xml.version>2.11.4</jackson-dataformat-xml.version>
<spring-boot.version>2.1.18.RELEASE</spring-boot.version>
<azure.appservice.resourcegroup />
<azure.appservice.plan />
<azure.appservice.appname />
......@@ -49,6 +53,13 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- Inherit managed dependencies from core-lib-azure -->
<dependency>
<groupId>org.opengroup.osdu</groupId>
......@@ -148,12 +159,12 @@
<!-- Azure dependencies -->
<dependency>
<groupId>com.microsoft.azure</groupId>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-active-directory-spring-boot-starter</artifactId>
<groupId>com.azure.spring</groupId>
<artifactId>azure-spring-boot-starter-active-directory</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -164,6 +175,22 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
<version>${reactor-netty.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>${reactor-core.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>${jackson-dataformat-xml.version}</version>
</dependency>
</dependencies>
<build>
......
package org.opengroup.osdu.search.provider.azure.config;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "elastic.latency.log")
@Getter
@Setter
@ToString
public class ElasticLoggingConfig {
private Boolean enabled;
private Long threshold;
}
......@@ -48,6 +48,7 @@ import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.search.*;
import org.opengroup.osdu.search.policy.service.IPolicyService;
import org.opengroup.osdu.search.policy.service.PartitionPolicyStatusService;
import org.opengroup.osdu.search.provider.azure.config.ElasticLoggingConfig;
import org.opengroup.osdu.search.service.IFieldMappingTypeService;
import org.opengroup.osdu.search.provider.interfaces.IProviderHeaderService;
import org.opengroup.osdu.search.util.AggregationParserUtil;
......@@ -84,6 +85,10 @@ abstract class QueryBase {
@Autowired
private ISortParserUtil sortParserUtil;
@Autowired
private ElasticLoggingConfig elasticLoggingConfig;
static final String AGGREGATION_NAME = "agg";
private static final String GEO_SHAPE_INDEXED_TYPE = "geo_shape";
// if returnedField contains property matching from excludes than query result will NOT include that property
......@@ -354,8 +359,10 @@ abstract class QueryBase {
throw new AppException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Search error", "Error processing search request", e);
} finally {
Long latency = System.currentTimeMillis() - startTime;
String request = elasticSearchRequest != null ? elasticSearchRequest.source().toString() : searchRequest.toString();
this.log.info(String.format("elastic latency: %s | elastic request-payload: %s", latency, request));
if (elasticLoggingConfig.getEnabled() || latency > elasticLoggingConfig.getThreshold()) {
String request = elasticSearchRequest != null ? elasticSearchRequest.source().toString() : searchRequest.toString();
this.log.info(String.format("elastic latency: %s | elastic request-payload: %s", latency, request));
}
this.auditLog(searchRequest, searchResponse);
}
}
......
......@@ -14,7 +14,7 @@
package org.opengroup.osdu.search.provider.azure.security;
import com.microsoft.azure.spring.autoconfigure.aad.AADAppRoleStatelessAuthenticationFilter;
import com.azure.spring.autoconfigure.aad.AADAppRoleStatelessAuthenticationFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
......
......@@ -51,6 +51,7 @@ AGGREGATION_SIZE=1000
logging.slf4jlogger.enabled=true
logging.transaction.enabled=true
logging.mdccontext.enabled=true
logging.ignore.servlet.paths=/actuator/health
#TenantFactory Configuration
tenantFactoryImpl.required=true
......@@ -64,6 +65,8 @@ elastic.cache.expiration=${ELASTIC_CACHE_EXPIRATION}
elastic.cache.maxSize=${MAX_CACHE_VALUE_SIZE}
group.cache.expiration=5
group.cache.maxSize=1000
elastic.latency.log.enabled=false
elastic.latency.log.threshold=200
# Redis
redis.port=6380
......
......@@ -28,7 +28,7 @@ import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import java.util.*;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
......
......@@ -53,6 +53,7 @@ import org.opengroup.osdu.core.common.model.search.SpatialFilter;
import org.opengroup.osdu.search.config.SearchConfigurationProperties;
import org.opengroup.osdu.search.logging.AuditLogger;
import org.opengroup.osdu.search.service.FieldMappingTypeService;
import org.opengroup.osdu.search.provider.azure.config.ElasticLoggingConfig;
import org.opengroup.osdu.search.provider.interfaces.IProviderHeaderService;
import org.opengroup.osdu.search.util.AggregationParserUtil;
import org.opengroup.osdu.search.util.CrossTenantUtils;
......@@ -146,6 +147,9 @@ public class QueryServiceImplTest {
@Spy
private IAggregationParserUtil aggregationParserUtil = new AggregationParserUtil(properties);
@Mock
private ElasticLoggingConfig elasticLoggingConfig;
@InjectMocks
private QueryServiceImpl sut;
......@@ -157,6 +161,8 @@ public class QueryServiceImplTest {
doReturn(client).when(elasticClientHandler).createRestClient();
doReturn(spatialFilter).when(searchRequest).getSpatialFilter();
doReturn(fieldName).when(spatialFilter).getField();
when(elasticLoggingConfig.getEnabled()).thenReturn(false);
when(elasticLoggingConfig.getThreshold()).thenReturn(200L);
// doReturn(searchResponse).when(client).search(any(), any(RequestOptions.class));
// doReturn(searchHits).when(searchResponse).getHits();
// doReturn(hitFields).when(searchHit).getSourceAsMap();
......
......@@ -37,6 +37,7 @@ import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.search.*;
import org.opengroup.osdu.search.cache.CursorCache;
import org.opengroup.osdu.search.logging.AuditLogger;
import org.opengroup.osdu.search.provider.azure.config.ElasticLoggingConfig;
import org.opengroup.osdu.search.provider.interfaces.IProviderHeaderService;
import org.opengroup.osdu.search.util.CrossTenantUtils;
import org.opengroup.osdu.search.util.ElasticClientHandler;
......@@ -45,12 +46,8 @@ import java.util.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class ScrollQueryServiceImplTest {
......@@ -93,6 +90,8 @@ public class ScrollQueryServiceImplTest {
@Mock
private CrossTenantUtils crossTenantUtils;
@Mock
private ElasticLoggingConfig elasticLoggingConfig;
@InjectMocks
private ScrollQueryServiceImpl sut;
......@@ -103,6 +102,8 @@ public class ScrollQueryServiceImplTest {
doReturn(indexName).when(crossTenantUtils).getIndexName(any());
doReturn(cursorSettings).when(cursorCache).get(anyString());
doReturn(client).when(elasticClientHandler).createRestClient();
when(elasticLoggingConfig.getEnabled()).thenReturn(false);
when(elasticLoggingConfig.getThreshold()).thenReturn(200L);
}
@Test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment