diff --git a/hypertrace-core-graphql b/hypertrace-core-graphql index 5d48c7b2..2b889a00 160000 --- a/hypertrace-core-graphql +++ b/hypertrace-core-graphql @@ -1 +1 @@ -Subproject commit 5d48c7b2b1330bf140112095d6fa6157d494e265 +Subproject commit 2b889a0071a28c481386eac7d6f506464c3bd2c4 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..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; @@ -40,6 +40,7 @@ class GatewayBaselineDao implements BaselineDao { private final Converter, Set> aggregationConverter; private final Converter, Set> seriesConverter; + private final GraphQlServiceConfig serviceConfig; @Inject GatewayBaselineDao( @@ -57,6 +58,7 @@ class GatewayBaselineDao implements BaselineDao { .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.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 6b135bcb..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; @@ -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,6 +40,7 @@ class GatewayServiceEntityDao implements EntityDao { this.requestBuilder = requestBuilder; this.entityConverter = entityConverter; this.baselineDao = baselineDao; + this.serviceConfig = serviceConfig; this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( @@ -77,7 +78,8 @@ private Single makeRequest( .callInContext( () -> this.gatewayServiceStub - .withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS) + .withDeadlineAfter( + 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 6ded3f98..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; @@ -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,6 +35,7 @@ class GatewayServiceExplorerDao implements ExplorerDao { this.grpcContextBuilder = grpcContextBuilder; this.requestBuilder = requestBuilder; this.responseConverter = responseConverter; + this.serviceConfig = serviceConfig; this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( @@ -60,7 +61,8 @@ private Single makeRequest( .callInContext( () -> this.gatewayServiceStub - .withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS) + .withDeadlineAfter( + 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 8dd1c49a..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,6 +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_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"; @@ -41,6 +43,7 @@ class DefaultGraphQlServiceConfig implements HypertraceGraphQlServiceConfig { int attributeServicePort; String gatewayServiceHost; int gatewayServicePort; + Duration gatewayServiceTimeout; String entityServiceHost; int entityServicePort; String configServiceHost; @@ -62,6 +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); + // 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) {