From bd37a8b786055e22b117a1634574d7ea497e8729 Mon Sep 17 00:00:00 2001 From: Prashant Pandey Date: Fri, 9 Jul 2021 22:04:07 +0530 Subject: [PATCH 1/3] Added config for gateway gRPC client deadline --- .../log/event/dao/GatewayServiceLogEventDao.java | 10 ++++++---- .../graphql/service/DefaultGraphQlServiceConfig.java | 8 ++++++++ .../core/graphql/span/dao/GatewayServiceSpanDao.java | 9 +++++++-- .../core/graphql/span/dao/SpanDaoModule.java | 1 + .../core/graphql/span/dao/SpanLogEventDao.java | 11 ++++++----- .../core/graphql/spi/config/GraphQlServiceConfig.java | 2 ++ .../graphql/trace/dao/GatewayServiceTraceDao.java | 11 +++++++---- 7 files changed, 37 insertions(+), 15 deletions(-) diff --git a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java index 6d43f005..3c3d4693 100644 --- a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java +++ b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java @@ -19,11 +19,11 @@ @Singleton class GatewayServiceLogEventDao implements LogEventDao { - private static final int DEFAULT_DEADLINE_SEC = 10; private final GatewayServiceFutureStub gatewayServiceStub; private final GrpcContextBuilder grpcContextBuilder; private final GatewayServiceLogEventsRequestBuilder requestBuilder; private final GatewayServiceLogEventsResponseConverter logEventConverter; + private final GraphQlServiceConfig serviceConfig; @Inject GatewayServiceLogEventDao( @@ -36,11 +36,12 @@ class GatewayServiceLogEventDao implements LogEventDao { this.grpcContextBuilder = grpcContextBuilder; this.requestBuilder = requestBuilder; this.logEventConverter = logEventConverter; + this.serviceConfig = serviceConfig; this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - channelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + channelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); } @@ -60,7 +61,8 @@ private Single makeRequest( .call( () -> this.gatewayServiceStub - .withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS) + .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), + SECONDS) .getLogEvents(request))); } } diff --git a/hypertrace-core-graphql-service/src/main/java/org/hypertrace/core/graphql/service/DefaultGraphQlServiceConfig.java b/hypertrace-core-graphql-service/src/main/java/org/hypertrace/core/graphql/service/DefaultGraphQlServiceConfig.java index dcdbc398..5113a4d4 100644 --- a/hypertrace-core-graphql-service/src/main/java/org/hypertrace/core/graphql/service/DefaultGraphQlServiceConfig.java +++ b/hypertrace-core-graphql-service/src/main/java/org/hypertrace/core/graphql/service/DefaultGraphQlServiceConfig.java @@ -22,6 +22,7 @@ class DefaultGraphQlServiceConfig implements GraphQlServiceConfig { 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 final String serviceName; private final int servicePort; @@ -33,6 +34,7 @@ class DefaultGraphQlServiceConfig implements GraphQlServiceConfig { private final int attributeServicePort; private final String gatewayServiceHost; private final int gatewayServicePort; + private final int gatewayServiceClientDeadline; DefaultGraphQlServiceConfig(Config untypedConfig) { this.serviceName = untypedConfig.getString(SERVICE_NAME_CONFIG); @@ -46,6 +48,7 @@ class DefaultGraphQlServiceConfig implements GraphQlServiceConfig { this.attributeServicePort = untypedConfig.getInt(ATTRIBUTE_SERVICE_PORT_PROPERTY); this.gatewayServiceHost = untypedConfig.getString(GATEWAY_SERVICE_HOST_PROPERTY); this.gatewayServicePort = untypedConfig.getInt(GATEWAY_SERVICE_PORT_PROPERTY); + gatewayServiceClientDeadline = untypedConfig.getInt(GATEWAY_SERVICE_RPC_CLIENT_DEADLINE); } @Override @@ -98,6 +101,11 @@ public int getGatewayServicePort() { return this.gatewayServicePort; } + @Override + public int getGatewayServiceRPCClientDeadline() { + return gatewayServiceClientDeadline; + } + private Optional optionallyGet(Supplier valueSupplier) { try { return Optional.ofNullable(valueSupplier.get()); diff --git a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java index ca9d4444..511111ba 100644 --- a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java +++ b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java @@ -8,6 +8,7 @@ import org.hypertrace.core.graphql.context.GraphQlRequestContext; import org.hypertrace.core.graphql.span.request.SpanRequest; import org.hypertrace.core.graphql.span.schema.SpanResultSet; +import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig; import org.hypertrace.core.graphql.utils.grpc.GrpcContextBuilder; import org.hypertrace.gateway.service.GatewayServiceGrpc.GatewayServiceFutureStub; import org.hypertrace.gateway.service.v1.span.SpansRequest; @@ -15,15 +16,17 @@ @Singleton class GatewayServiceSpanDao implements SpanDao { - private static final int DEFAULT_DEADLINE_SEC = 10; + private final GatewayServiceFutureStub gatewayServiceStub; private final GrpcContextBuilder grpcContextBuilder; private final GatewayServiceSpanRequestBuilder requestBuilder; private final GatewayServiceSpanConverter spanConverter; private final SpanLogEventDao spanLogEventDao; + private final GraphQlServiceConfig serviceConfig; @Inject GatewayServiceSpanDao( + GraphQlServiceConfig serviceConfig, GatewayServiceFutureStub gatewayServiceFutureStub, GrpcContextBuilder grpcContextBuilder, GatewayServiceSpanRequestBuilder requestBuilder, @@ -34,6 +37,7 @@ class GatewayServiceSpanDao implements SpanDao { this.spanConverter = spanConverter; this.spanLogEventDao = spanLogEventDao; this.gatewayServiceStub = gatewayServiceFutureStub; + this.serviceConfig = serviceConfig; } @Override @@ -54,7 +58,8 @@ private Single makeRequest(GraphQlRequestContext context, SpansRe .call( () -> this.gatewayServiceStub - .withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS) + .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), + SECONDS) .getSpans(request))); } } diff --git a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanDaoModule.java b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanDaoModule.java index 77b03d12..36aff948 100644 --- a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanDaoModule.java +++ b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanDaoModule.java @@ -32,6 +32,7 @@ public class SpanDaoModule extends AbstractModule { protected void configure() { bind(SpanDao.class).to(GatewayServiceSpanDao.class); requireBinding(GatewayServiceFutureStub.class); + requireBinding(GraphQlServiceConfig.class); requireBinding(CallCredentials.class); requireBinding(GraphQlServiceConfig.class); requireBinding(GrpcContextBuilder.class); diff --git a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java index 88ecac95..a40cadc8 100644 --- a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java +++ b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java @@ -7,6 +7,7 @@ import javax.inject.Inject; import org.hypertrace.core.graphql.context.GraphQlRequestContext; import org.hypertrace.core.graphql.span.request.SpanRequest; +import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig; import org.hypertrace.core.graphql.utils.grpc.GrpcContextBuilder; import org.hypertrace.gateway.service.GatewayServiceGrpc.GatewayServiceFutureStub; import org.hypertrace.gateway.service.v1.log.events.LogEventsRequest; @@ -15,15 +16,15 @@ class SpanLogEventDao { - private static final int DEFAULT_DEADLINE_SEC = 10; - private final GatewayServiceFutureStub gatewayServiceStub; private final GrpcContextBuilder grpcContextBuilder; private final SpanLogEventRequestBuilder spanLogEventRequestBuilder; private final SpanLogEventResponseConverter spanLogEventResponseConverter; + private final GraphQlServiceConfig serviceConfig; @Inject SpanLogEventDao( + GraphQlServiceConfig serviceConfig, GatewayServiceFutureStub gatewayServiceFutureStub, GrpcContextBuilder grpcContextBuilder, SpanLogEventRequestBuilder spanLogEventRequestBuilder, @@ -32,11 +33,10 @@ class SpanLogEventDao { this.grpcContextBuilder = grpcContextBuilder; this.spanLogEventRequestBuilder = spanLogEventRequestBuilder; this.spanLogEventResponseConverter = spanLogEventResponseConverter; + this.serviceConfig = serviceConfig; } /** - * - * *
    *
  • 1. Fetch log event attributes from {@code gqlRequest} *
  • 2. Build log event request using attribute and spanIds as filter @@ -73,7 +73,8 @@ private Single makeRequest( .call( () -> this.gatewayServiceStub - .withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS) + .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), + SECONDS) .getLogEvents(request))); } } diff --git a/hypertrace-core-graphql-spi/src/main/java/org/hypertrace/core/graphql/spi/config/GraphQlServiceConfig.java b/hypertrace-core-graphql-spi/src/main/java/org/hypertrace/core/graphql/spi/config/GraphQlServiceConfig.java index 26bace29..14e1e03a 100644 --- a/hypertrace-core-graphql-spi/src/main/java/org/hypertrace/core/graphql/spi/config/GraphQlServiceConfig.java +++ b/hypertrace-core-graphql-spi/src/main/java/org/hypertrace/core/graphql/spi/config/GraphQlServiceConfig.java @@ -23,4 +23,6 @@ public interface GraphQlServiceConfig { String getGatewayServiceHost(); int getGatewayServicePort(); + + int getGatewayServiceRPCClientDeadline(); } diff --git a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java index e28031e5..a9bdc997 100644 --- a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java +++ b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java @@ -19,11 +19,12 @@ @Singleton class GatewayServiceTraceDao implements TraceDao { - private static final int DEFAULT_DEADLINE_SEC = 10; + private final GatewayServiceFutureStub gatewayServiceStub; private final GrpcContextBuilder grpcContextBuilder; private final GatewayServiceTraceRequestBuilder requestBuilder; private final GatewayServiceTraceConverter traceConverter; + private final GraphQlServiceConfig serviceConfig; @Inject GatewayServiceTraceDao( @@ -36,11 +37,12 @@ class GatewayServiceTraceDao implements TraceDao { this.grpcContextBuilder = grpcContextBuilder; this.requestBuilder = requestBuilder; this.traceConverter = traceConverter; + this.serviceConfig = serviceConfig; this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - channelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + channelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); } @@ -61,7 +63,8 @@ private Single makeRequest(GraphQlRequestContext context, Traces .call( () -> this.gatewayServiceStub - .withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS) + .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), + SECONDS) .getTraces(request))); } } From 2c88a4f6e9034e77b2d6eded73544d9ae5f4f904 Mon Sep 17 00:00:00 2001 From: Prashant Pandey Date: Fri, 9 Jul 2021 22:38:53 +0530 Subject: [PATCH 2/3] Spotless apply --- .../graphql/log/event/dao/GatewayServiceLogEventDao.java | 8 ++++---- .../core/graphql/span/dao/GatewayServiceSpanDao.java | 4 ++-- .../hypertrace/core/graphql/span/dao/SpanLogEventDao.java | 6 ++++-- .../core/graphql/trace/dao/GatewayServiceTraceDao.java | 8 ++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java index 3c3d4693..aea11f34 100644 --- a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java +++ b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java @@ -40,8 +40,8 @@ class GatewayServiceLogEventDao implements LogEventDao { this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - channelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + channelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); } @@ -61,8 +61,8 @@ private Single makeRequest( .call( () -> this.gatewayServiceStub - .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), - SECONDS) + .withDeadlineAfter( + serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) .getLogEvents(request))); } } diff --git a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java index 511111ba..740647da 100644 --- a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java +++ b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java @@ -58,8 +58,8 @@ private Single makeRequest(GraphQlRequestContext context, SpansRe .call( () -> this.gatewayServiceStub - .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), - SECONDS) + .withDeadlineAfter( + serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) .getSpans(request))); } } diff --git a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java index a40cadc8..65c6aab1 100644 --- a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java +++ b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java @@ -37,6 +37,8 @@ class SpanLogEventDao { } /** + * + * *
      *
    • 1. Fetch log event attributes from {@code gqlRequest} *
    • 2. Build log event request using attribute and spanIds as filter @@ -73,8 +75,8 @@ private Single makeRequest( .call( () -> this.gatewayServiceStub - .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), - SECONDS) + .withDeadlineAfter( + serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) .getLogEvents(request))); } } diff --git a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java index a9bdc997..bdced166 100644 --- a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java +++ b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java @@ -41,8 +41,8 @@ class GatewayServiceTraceDao implements TraceDao { this.gatewayServiceStub = GatewayServiceGrpc.newFutureStub( - channelRegistry.forAddress( - serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) + channelRegistry.forAddress( + serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort())) .withCallCredentials(credentials); } @@ -63,8 +63,8 @@ private Single makeRequest(GraphQlRequestContext context, Traces .call( () -> this.gatewayServiceStub - .withDeadlineAfter(serviceConfig.getGatewayServiceRPCClientDeadline(), - SECONDS) + .withDeadlineAfter( + serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) .getTraces(request))); } } From 5ced14a975e9f165f6eca93f78832d39ce300cbf Mon Sep 17 00:00:00 2001 From: Prashant Pandey Date: Sat, 10 Jul 2021 00:28:31 +0530 Subject: [PATCH 3/3] Changed gateway-service client timeout unit to java.time.Duration and added fallback configuration --- .../log/event/dao/GatewayServiceLogEventDao.java | 4 ++-- .../service/DefaultGraphQlServiceConfig.java | 15 ++++++++++----- .../graphql/span/dao/GatewayServiceSpanDao.java | 4 ++-- .../core/graphql/span/dao/SpanLogEventDao.java | 4 ++-- .../graphql/spi/config/GraphQlServiceConfig.java | 3 ++- .../graphql/trace/dao/GatewayServiceTraceDao.java | 4 ++-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java index aea11f34..68bd5642 100644 --- a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java +++ b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventDao.java @@ -1,6 +1,6 @@ package org.hypertrace.core.graphql.log.event.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) .getLogEvents(request))); } } diff --git a/hypertrace-core-graphql-service/src/main/java/org/hypertrace/core/graphql/service/DefaultGraphQlServiceConfig.java b/hypertrace-core-graphql-service/src/main/java/org/hypertrace/core/graphql/service/DefaultGraphQlServiceConfig.java index 5113a4d4..e3171a03 100644 --- a/hypertrace-core-graphql-service/src/main/java/org/hypertrace/core/graphql/service/DefaultGraphQlServiceConfig.java +++ b/hypertrace-core-graphql-service/src/main/java/org/hypertrace/core/graphql/service/DefaultGraphQlServiceConfig.java @@ -1,6 +1,7 @@ package org.hypertrace.core.graphql.service; import com.typesafe.config.Config; +import java.time.Duration; import java.util.Optional; import java.util.function.Supplier; import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig; @@ -22,7 +23,7 @@ class DefaultGraphQlServiceConfig implements GraphQlServiceConfig { 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 final String serviceName; private final int servicePort; @@ -34,7 +35,7 @@ class DefaultGraphQlServiceConfig implements GraphQlServiceConfig { private final int attributeServicePort; private final String gatewayServiceHost; private final int gatewayServicePort; - private final int gatewayServiceClientDeadline; + private final Duration gatewayServiceTimeout; DefaultGraphQlServiceConfig(Config untypedConfig) { this.serviceName = untypedConfig.getString(SERVICE_NAME_CONFIG); @@ -48,7 +49,11 @@ class DefaultGraphQlServiceConfig implements GraphQlServiceConfig { this.attributeServicePort = untypedConfig.getInt(ATTRIBUTE_SERVICE_PORT_PROPERTY); this.gatewayServiceHost = untypedConfig.getString(GATEWAY_SERVICE_HOST_PROPERTY); this.gatewayServicePort = untypedConfig.getInt(GATEWAY_SERVICE_PORT_PROPERTY); - gatewayServiceClientDeadline = 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); } @Override @@ -102,8 +107,8 @@ public int getGatewayServicePort() { } @Override - public int getGatewayServiceRPCClientDeadline() { - return gatewayServiceClientDeadline; + public Duration getGatewayServiceTimeout() { + return gatewayServiceTimeout; } private Optional optionallyGet(Supplier valueSupplier) { diff --git a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java index 740647da..67a5f9d9 100644 --- a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java +++ b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanDao.java @@ -1,6 +1,6 @@ package org.hypertrace.core.graphql.span.dao; -import static java.util.concurrent.TimeUnit.SECONDS; +import static java.util.concurrent.TimeUnit.MILLISECONDS; import io.reactivex.rxjava3.core.Single; import javax.inject.Inject; @@ -59,7 +59,7 @@ private Single makeRequest(GraphQlRequestContext context, SpansRe () -> this.gatewayServiceStub .withDeadlineAfter( - serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) + serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS) .getSpans(request))); } } diff --git a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java index 65c6aab1..f714ddec 100644 --- a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java +++ b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/SpanLogEventDao.java @@ -1,6 +1,6 @@ package org.hypertrace.core.graphql.span.dao; -import static java.util.concurrent.TimeUnit.SECONDS; +import static java.util.concurrent.TimeUnit.MILLISECONDS; import io.reactivex.rxjava3.core.Single; import java.util.Map; @@ -76,7 +76,7 @@ private Single makeRequest( () -> this.gatewayServiceStub .withDeadlineAfter( - serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) + serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS) .getLogEvents(request))); } } diff --git a/hypertrace-core-graphql-spi/src/main/java/org/hypertrace/core/graphql/spi/config/GraphQlServiceConfig.java b/hypertrace-core-graphql-spi/src/main/java/org/hypertrace/core/graphql/spi/config/GraphQlServiceConfig.java index 14e1e03a..310666f7 100644 --- a/hypertrace-core-graphql-spi/src/main/java/org/hypertrace/core/graphql/spi/config/GraphQlServiceConfig.java +++ b/hypertrace-core-graphql-spi/src/main/java/org/hypertrace/core/graphql/spi/config/GraphQlServiceConfig.java @@ -1,5 +1,6 @@ package org.hypertrace.core.graphql.spi.config; +import java.time.Duration; import java.util.Optional; public interface GraphQlServiceConfig { @@ -24,5 +25,5 @@ public interface GraphQlServiceConfig { int getGatewayServicePort(); - int getGatewayServiceRPCClientDeadline(); + Duration getGatewayServiceTimeout(); } diff --git a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java index bdced166..e1f55c62 100644 --- a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java +++ b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceDao.java @@ -1,6 +1,6 @@ package org.hypertrace.core.graphql.trace.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; @@ -64,7 +64,7 @@ private Single makeRequest(GraphQlRequestContext context, Traces () -> this.gatewayServiceStub .withDeadlineAfter( - serviceConfig.getGatewayServiceRPCClientDeadline(), SECONDS) + serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS) .getTraces(request))); } }