Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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(
Expand All @@ -36,6 +36,7 @@ class GatewayServiceLogEventDao implements LogEventDao {
this.grpcContextBuilder = grpcContextBuilder;
this.requestBuilder = requestBuilder;
this.logEventConverter = logEventConverter;
this.serviceConfig = serviceConfig;

this.gatewayServiceStub =
GatewayServiceGrpc.newFutureStub(
Expand All @@ -60,7 +61,8 @@ private Single<LogEventsResponse> makeRequest(
.call(
() ->
this.gatewayServiceStub
.withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS)
.withDeadlineAfter(
serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS)
.getLogEvents(request)));
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -22,6 +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_CLIENT_TIMEOUT = "gateway.service.timeout";

private final String serviceName;
private final int servicePort;
Expand All @@ -33,6 +35,7 @@ class DefaultGraphQlServiceConfig implements GraphQlServiceConfig {
private final int attributeServicePort;
private final String gatewayServiceHost;
private final int gatewayServicePort;
private final Duration gatewayServiceTimeout;

DefaultGraphQlServiceConfig(Config untypedConfig) {
this.serviceName = untypedConfig.getString(SERVICE_NAME_CONFIG);
Expand All @@ -46,6 +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);
// fallback timeout: 10s
this.gatewayServiceTimeout =
untypedConfig.hasPath(GATEWAY_SERVICE_CLIENT_TIMEOUT)
? untypedConfig.getDuration(GATEWAY_SERVICE_CLIENT_TIMEOUT)
: Duration.ofSeconds(10);
}

@Override
Expand Down Expand Up @@ -98,6 +106,11 @@ public int getGatewayServicePort() {
return this.gatewayServicePort;
}

@Override
public Duration getGatewayServiceTimeout() {
return gatewayServiceTimeout;
}

private <T> Optional<T> optionallyGet(Supplier<T> valueSupplier) {
try {
return Optional.ofNullable(valueSupplier.get());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
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;
import javax.inject.Singleton;
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;
import org.hypertrace.gateway.service.v1.span.SpansResponse;

@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,
Expand All @@ -34,6 +37,7 @@ class GatewayServiceSpanDao implements SpanDao {
this.spanConverter = spanConverter;
this.spanLogEventDao = spanLogEventDao;
this.gatewayServiceStub = gatewayServiceFutureStub;
this.serviceConfig = serviceConfig;
}

@Override
Expand All @@ -54,7 +58,8 @@ private Single<SpansResponse> makeRequest(GraphQlRequestContext context, SpansRe
.call(
() ->
this.gatewayServiceStub
.withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS)
.withDeadlineAfter(
serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS)
.getSpans(request)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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;
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;
Expand All @@ -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,
Expand All @@ -32,6 +33,7 @@ class SpanLogEventDao {
this.grpcContextBuilder = grpcContextBuilder;
this.spanLogEventRequestBuilder = spanLogEventRequestBuilder;
this.spanLogEventResponseConverter = spanLogEventResponseConverter;
this.serviceConfig = serviceConfig;
}

/**
Expand Down Expand Up @@ -73,7 +75,8 @@ private Single<LogEventsResponse> makeRequest(
.call(
() ->
this.gatewayServiceStub
.withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS)
.withDeadlineAfter(
serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS)
.getLogEvents(request)));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.hypertrace.core.graphql.spi.config;

import java.time.Duration;
import java.util.Optional;

public interface GraphQlServiceConfig {
Expand All @@ -23,4 +24,6 @@ public interface GraphQlServiceConfig {
String getGatewayServiceHost();

int getGatewayServicePort();

Duration getGatewayServiceTimeout();
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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(
Expand All @@ -36,6 +37,7 @@ class GatewayServiceTraceDao implements TraceDao {
this.grpcContextBuilder = grpcContextBuilder;
this.requestBuilder = requestBuilder;
this.traceConverter = traceConverter;
this.serviceConfig = serviceConfig;

this.gatewayServiceStub =
GatewayServiceGrpc.newFutureStub(
Expand All @@ -61,7 +63,8 @@ private Single<TracesResponse> makeRequest(GraphQlRequestContext context, Traces
.call(
() ->
this.gatewayServiceStub
.withDeadlineAfter(DEFAULT_DEADLINE_SEC, SECONDS)
.withDeadlineAfter(
serviceConfig.getGatewayServiceTimeout().toMillis(), MILLISECONDS)
.getTraces(request)));
}
}