From 7e1f250aba6b102dc22c1ba4300e86219ffeb766 Mon Sep 17 00:00:00 2001 From: Prashant Pandey Date: Fri, 9 Jul 2021 22:04:31 +0530 Subject: [PATCH 1/6] Added config for gateway gRPC client deadline --- hypertrace-core-graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypertrace-core-graphql b/hypertrace-core-graphql index 5d48c7b2..bd37a8b7 160000 --- a/hypertrace-core-graphql +++ b/hypertrace-core-graphql @@ -1 +1 @@ -Subproject commit 5d48c7b2b1330bf140112095d6fa6157d494e265 +Subproject commit bd37a8b786055e22b117a1634574d7ea497e8729 From 2f11a3a35497c77822fb176b38df739ffc4d2dc0 Mon Sep 17 00:00:00 2001 From: Prashant Pandey Date: Fri, 9 Jul 2021 22:05:10 +0530 Subject: [PATCH 2/6] Added config for gateway gRPC client deadline --- .../graphql/entity/dao/GatewayBaselineDao.java | 9 ++++++--- .../graphql/entity/dao/GatewayServiceEntityDao.java | 10 ++++++---- .../explorer/dao/GatewayServiceExplorerDao.java | 10 ++++++---- .../graphql/service/DefaultGraphQlServiceConfig.java | 3 +++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java index 9cb0507d..44637cdb 100644 --- a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java +++ b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java @@ -40,6 +40,7 @@ class GatewayBaselineDao implements BaselineDao { private final Converter, Set> aggregationConverter; private final Converter, Set> seriesConverter; + private final GraphQlServiceConfig serviceConfig; @Inject GatewayBaselineDao( @@ -52,11 +53,12 @@ class GatewayBaselineDao implements BaselineDao { this.grpcContextBuilder = grpcContextBuilder; this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - grpcChannelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + grpcChannelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); this.seriesConverter = seriesConverter; this.aggregationConverter = aggregationConverter; + this.serviceConfig = serviceConfig; } @Override @@ -127,7 +129,8 @@ private Single makeRequest( .callInContext( () -> this.gatewayServiceStub - .withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS) + .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), + SECONDS) .getBaselineForEntities(request))); } } diff --git a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java index 6b135bcb..33b17b72 100644 --- a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java +++ b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java @@ -20,12 +20,12 @@ @Singleton class GatewayServiceEntityDao implements EntityDao { - private static final int DEFAULT_DEADLINE_SEC = 10; private final GatewayServiceFutureStub gatewayServiceStub; private final GraphQlGrpcContextBuilder grpcContextBuilder; private final GatewayServiceEntityRequestBuilder requestBuilder; private final GatewayServiceEntityConverter entityConverter; private final BaselineDao baselineDao; + private final GraphQlServiceConfig serviceConfig; @Inject GatewayServiceEntityDao( @@ -40,11 +40,12 @@ class GatewayServiceEntityDao implements EntityDao { this.requestBuilder = requestBuilder; this.entityConverter = entityConverter; this.baselineDao = baselineDao; + this.serviceConfig = serviceConfig; this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - grpcChannelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + grpcChannelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); } @@ -77,7 +78,8 @@ private Single makeRequest( .callInContext( () -> this.gatewayServiceStub - .withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS) + .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), + SECONDS) .getEntities(request))); } } diff --git a/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java b/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java index 6ded3f98..b75e8336 100644 --- a/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java +++ b/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java @@ -18,11 +18,11 @@ @Singleton class GatewayServiceExplorerDao implements ExplorerDao { - private static final int DEFAULT_DEADLINE_SEC = 10; private final GatewayServiceFutureStub gatewayServiceStub; private final GraphQlGrpcContextBuilder grpcContextBuilder; private final GatewayServiceExploreRequestBuilder requestBuilder; private final GatewayServiceExploreResponseConverter responseConverter; + private final GraphQlServiceConfig serviceConfig; @Inject GatewayServiceExplorerDao( @@ -35,11 +35,12 @@ class GatewayServiceExplorerDao implements ExplorerDao { this.grpcContextBuilder = grpcContextBuilder; this.requestBuilder = requestBuilder; this.responseConverter = responseConverter; + this.serviceConfig = serviceConfig; this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - grpcChannelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + grpcChannelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); } @@ -60,7 +61,8 @@ private Single makeRequest( .callInContext( () -> this.gatewayServiceStub - .withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS) + .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), + SECONDS) .explore(request))); } } diff --git a/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java b/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java index 8dd1c49a..a7ffa8af 100644 --- a/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java +++ b/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java @@ -24,6 +24,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { private static final String GATEWAY_SERVICE_HOST_PROPERTY = "gateway.service.host"; private static final String GATEWAY_SERVICE_PORT_PROPERTY = "gateway.service.port"; + private static final String GATEWAY_SERVICE_RPC_CLIENT_DEADLINE = "gateway.service.deadline"; private static final String ENTITY_SERVICE_HOST_PROPERTY = "entity.service.host"; private static final String ENTITY_SERVICE_PORT_PROPERTY = "entity.service.port"; @@ -41,6 +42,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { int attributeServicePort; String gatewayServiceHost; int gatewayServicePort; + int gatewayServiceRPCClientDeadline; String entityServiceHost; int entityServicePort; String configServiceHost; @@ -62,6 +64,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { this.entityServicePort = untypedConfig.getInt(ENTITY_SERVICE_PORT_PROPERTY); this.configServiceHost = untypedConfig.getString(CONFIG_SERVICE_HOST_PROPERTY); this.configServicePort = untypedConfig.getInt(CONFIG_SERVICE_PORT_PROPERTY); + this.gatewayServiceRPCClientDeadline = untypedConfig.getInt(GATEWAY_SERVICE_RPC_CLIENT_DEADLINE); } private Optional optionallyGet(Supplier valueSupplier) { From ce6283ece168a4ac2b22686bdb829750bc0d1e17 Mon Sep 17 00:00:00 2001 From: Prashant Pandey Date: Fri, 9 Jul 2021 22:34:18 +0530 Subject: [PATCH 3/6] Spotless apply --- .../hypertrace/graphql/entity/dao/GatewayBaselineDao.java | 8 ++++---- .../graphql/entity/dao/GatewayServiceEntityDao.java | 8 ++++---- .../graphql/explorer/dao/GatewayServiceExplorerDao.java | 8 ++++---- .../graphql/service/DefaultGraphQlServiceConfig.java | 3 ++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java index 44637cdb..23325e8e 100644 --- a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java +++ b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java @@ -53,8 +53,8 @@ class GatewayBaselineDao implements BaselineDao { this.grpcContextBuilder = grpcContextBuilder; this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - grpcChannelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + grpcChannelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); this.seriesConverter = seriesConverter; this.aggregationConverter = aggregationConverter; @@ -129,8 +129,8 @@ private Single makeRequest( .callInContext( () -> this.gatewayServiceStub - .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), - SECONDS) + .withDeadlineAfter( + serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) .getBaselineForEntities(request))); } } diff --git a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java index 33b17b72..14d5d473 100644 --- a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java +++ b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java @@ -44,8 +44,8 @@ class GatewayServiceEntityDao implements EntityDao { this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - grpcChannelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + grpcChannelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); } @@ -78,8 +78,8 @@ private Single makeRequest( .callInContext( () -> this.gatewayServiceStub - .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), - SECONDS) + .withDeadlineAfter( + serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) .getEntities(request))); } } diff --git a/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java b/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java index b75e8336..a9c26f41 100644 --- a/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java +++ b/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java @@ -39,8 +39,8 @@ class GatewayServiceExplorerDao implements ExplorerDao { this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - grpcChannelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + grpcChannelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); } @@ -61,8 +61,8 @@ private Single makeRequest( .callInContext( () -> this.gatewayServiceStub - .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), - SECONDS) + .withDeadlineAfter( + serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) .explore(request))); } } diff --git a/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java b/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java index a7ffa8af..24f339ff 100644 --- a/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java +++ b/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java @@ -64,7 +64,8 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { this.entityServicePort = untypedConfig.getInt(ENTITY_SERVICE_PORT_PROPERTY); this.configServiceHost = untypedConfig.getString(CONFIG_SERVICE_HOST_PROPERTY); this.configServicePort = untypedConfig.getInt(CONFIG_SERVICE_PORT_PROPERTY); - this.gatewayServiceRPCClientDeadline = untypedConfig.getInt(GATEWAY_SERVICE_RPC_CLIENT_DEADLINE); + this.gatewayServiceRPCClientDeadline = + untypedConfig.getInt(GATEWAY_SERVICE_RPC_CLIENT_DEADLINE); } private Optional optionallyGet(Supplier valueSupplier) { From 6c5027543e289242946c81e6486447cde248e7fa Mon Sep 17 00:00:00 2001 From: Prashant Pandey Date: Sat, 10 Jul 2021 00:28:31 +0530 Subject: [PATCH 4/6] Changed gateway-service client timeout unit to java.time.Duration and added fallback configuration --- hypertrace-core-graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypertrace-core-graphql b/hypertrace-core-graphql index bd37a8b7..5ced14a9 160000 --- a/hypertrace-core-graphql +++ b/hypertrace-core-graphql @@ -1 +1 @@ -Subproject commit bd37a8b786055e22b117a1634574d7ea497e8729 +Subproject commit 5ced14a975e9f165f6eca93f78832d39ce300cbf From acb14fe34135a4613e1856cd3c404ebed4d47276 Mon Sep 17 00:00:00 2001 From: Prashant Pandey Date: Sat, 10 Jul 2021 00:28:47 +0530 Subject: [PATCH 5/6] Changed gateway-service client timeout unit to java.time.Duration and added fallback configuration --- .../graphql/entity/dao/GatewayBaselineDao.java | 4 ++-- .../graphql/entity/dao/GatewayServiceEntityDao.java | 4 ++-- .../explorer/dao/GatewayServiceExplorerDao.java | 4 ++-- .../graphql/service/DefaultGraphQlServiceConfig.java | 12 ++++++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java index 23325e8e..b8d11512 100644 --- a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java +++ b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayBaselineDao.java @@ -1,7 +1,7 @@ package org.hypertrace.graphql.entity.dao; import static io.reactivex.rxjava3.core.Single.zip; -import static java.util.concurrent.TimeUnit.SECONDS; +import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.hypertrace.core.graphql.common.utils.CollectorUtils.flatten; import io.grpc.CallCredentials; @@ -130,7 +130,7 @@ private Single makeRequest( () -> this.gatewayServiceStub .withDeadlineAfter( - serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) + serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS) .getBaselineForEntities(request))); } } diff --git a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java index 14d5d473..d7eccc97 100644 --- a/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java +++ b/hypertrace-graphql-entity-schema/src/main/java/org/hypertrace/graphql/entity/dao/GatewayServiceEntityDao.java @@ -1,6 +1,6 @@ package org.hypertrace.graphql.entity.dao; -import static java.util.concurrent.TimeUnit.SECONDS; +import static java.util.concurrent.TimeUnit.MILLISECONDS; import io.grpc.CallCredentials; import io.reactivex.rxjava3.core.Single; @@ -79,7 +79,7 @@ private Single makeRequest( () -> this.gatewayServiceStub .withDeadlineAfter( - serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) + serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS) .getEntities(request))); } } diff --git a/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java b/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java index a9c26f41..7e7edce4 100644 --- a/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java +++ b/hypertrace-graphql-explorer-schema/src/main/java/org/hypertrace/graphql/explorer/dao/GatewayServiceExplorerDao.java @@ -1,6 +1,6 @@ package org.hypertrace.graphql.explorer.dao; -import static java.util.concurrent.TimeUnit.SECONDS; +import static java.util.concurrent.TimeUnit.MILLISECONDS; import io.grpc.CallCredentials; import io.reactivex.rxjava3.core.Single; @@ -62,7 +62,7 @@ private Single makeRequest( () -> this.gatewayServiceStub .withDeadlineAfter( - serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) + serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS) .explore(request))); } } diff --git a/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java b/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java index 24f339ff..23958887 100644 --- a/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java +++ b/hypertrace-graphql-service/src/main/java/org/hypertrace/graphql/service/DefaultGraphQlServiceConfig.java @@ -1,6 +1,7 @@ package org.hypertrace.graphql.service; import com.typesafe.config.Config; +import java.time.Duration; import java.util.Optional; import java.util.function.Supplier; import lombok.Value; @@ -24,7 +25,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { private static final String GATEWAY_SERVICE_HOST_PROPERTY = "gateway.service.host"; private static final String GATEWAY_SERVICE_PORT_PROPERTY = "gateway.service.port"; - private static final String GATEWAY_SERVICE_RPC_CLIENT_DEADLINE = "gateway.service.deadline"; + private static final String GATEWAY_SERVICE_CLIENT_TIMEOUT = "gateway.service.timeout"; private static final String ENTITY_SERVICE_HOST_PROPERTY = "entity.service.host"; private static final String ENTITY_SERVICE_PORT_PROPERTY = "entity.service.port"; @@ -42,7 +43,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { int attributeServicePort; String gatewayServiceHost; int gatewayServicePort; - int gatewayServiceRPCClientDeadline; + Duration gatewayServiceTimeout; String entityServiceHost; int entityServicePort; String configServiceHost; @@ -64,8 +65,11 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { this.entityServicePort = untypedConfig.getInt(ENTITY_SERVICE_PORT_PROPERTY); this.configServiceHost = untypedConfig.getString(CONFIG_SERVICE_HOST_PROPERTY); this.configServicePort = untypedConfig.getInt(CONFIG_SERVICE_PORT_PROPERTY); - this.gatewayServiceRPCClientDeadline = - untypedConfig.getInt(GATEWAY_SERVICE_RPC_CLIENT_DEADLINE); + // fallback timeout: 10s + this.gatewayServiceTimeout = + untypedConfig.hasPath(GATEWAY_SERVICE_CLIENT_TIMEOUT) + ? untypedConfig.getDuration(GATEWAY_SERVICE_CLIENT_TIMEOUT) + : Duration.ofSeconds(10); } private Optional optionallyGet(Supplier valueSupplier) { From ea26c183713298c6a027abf4e1f1c7f76ccc21a6 Mon Sep 17 00:00:00 2001 From: Prashant Pandey Date: Sat, 10 Jul 2021 12:26:58 +0530 Subject: [PATCH 6/6] Update submodule ref: hypertrace-core-graphql --- hypertrace-core-graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypertrace-core-graphql b/hypertrace-core-graphql index 5ced14a9..2b889a00 160000 --- a/hypertrace-core-graphql +++ b/hypertrace-core-graphql @@ -1 +1 @@ -Subproject commit 5ced14a975e9f165f6eca93f78832d39ce300cbf +Subproject commit 2b889a0071a28c481386eac7d6f506464c3bd2c4