diff --git a/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/DefaultResultSetRequestBuilder.java b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/DefaultResultSetRequestBuilder.java index fc9b3b43..cebff7ae 100644 --- a/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/DefaultResultSetRequestBuilder.java +++ b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/DefaultResultSetRequestBuilder.java @@ -20,6 +20,8 @@ import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; import org.hypertrace.core.graphql.common.schema.results.ResultSet; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperatorArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.LimitArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.OffsetArgument; @@ -89,6 +91,11 @@ public Single> build( .deserializeObjectList(arguments, orderArgumentClass) .orElse(Collections.emptyList()); + LogicalFilterOperator logicalFilterOperator = + this.argumentDeserializer + .deserializePrimitive(arguments, LogicalFilterOperatorArgument.class) + .orElse(LogicalFilterOperator.AND); + List requestedFilters = this.argumentDeserializer .deserializeObjectList(arguments, FilterArgument.class) @@ -114,6 +121,7 @@ public Single> build( offset, timeRange, orders, + logicalFilterOperator, filters, this.getAttributeQueryableFields(selectionSet), spaceId)) @@ -128,6 +136,7 @@ public Single> build( int offset, TimeRangeArgument timeRange, List> orderArguments, + LogicalFilterOperator logicalFilterOperator, Collection> filterArguments, Stream attributeQueryableFields, Optional spaceId) { @@ -145,6 +154,7 @@ public Single> build( limit, offset, orderArguments, + logicalFilterOperator, filterArguments, spaceId)); } @@ -184,6 +194,7 @@ public Single> build( limit, 0, List.of(), + LogicalFilterOperator.AND, filters, Optional.empty())); } @@ -206,6 +217,7 @@ public Single> rebuildWithAddition originalRequest.limit(), originalRequest.offset(), originalRequest.orderArguments(), + originalRequest.logicalFilterOperator(), mergedFilters, originalRequest.spaceId())); } @@ -251,6 +263,7 @@ private static class DefaultResultSetRequest int limit; int offset; List> orderArguments; + LogicalFilterOperator logicalFilterOperator; Collection> filterArguments; Optional spaceId; } diff --git a/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/ResultSetRequest.java b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/ResultSetRequest.java index 46418045..e6d339c7 100644 --- a/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/ResultSetRequest.java +++ b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/ResultSetRequest.java @@ -5,6 +5,7 @@ import java.util.Optional; import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; public interface ResultSetRequest extends ContextualRequest { @@ -24,5 +25,7 @@ public interface ResultSetRequest extends ContextualReq Collection> filterArguments(); + LogicalFilterOperator logicalFilterOperator(); + Optional spaceId(); } diff --git a/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/ResultSetRequestBuilder.java b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/ResultSetRequestBuilder.java index 3a6ea9bd..e8047930 100644 --- a/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/ResultSetRequestBuilder.java +++ b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/request/ResultSetRequestBuilder.java @@ -11,6 +11,7 @@ import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument; import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.context.GraphQlRequestContext; @@ -35,6 +36,7 @@ Single> build( int offset, TimeRangeArgument timeRange, List> orderArguments, + LogicalFilterOperator logicalFilterOperator, Collection> filterArguments, Stream attributeQueryableFields, Optional spaceId); diff --git a/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/schema/results/arguments/filter/LogicalFilterOperator.java b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/schema/results/arguments/filter/LogicalFilterOperator.java new file mode 100644 index 00000000..91847af7 --- /dev/null +++ b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/schema/results/arguments/filter/LogicalFilterOperator.java @@ -0,0 +1,11 @@ +package org.hypertrace.core.graphql.common.schema.results.arguments.filter; + +import graphql.annotations.annotationTypes.GraphQLName; + +@GraphQLName(LogicalFilterOperator.TYPE_NAME) +public enum LogicalFilterOperator { + AND, + OR; + + static final String TYPE_NAME = "LogicalFilterOperator"; +} diff --git a/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/schema/results/arguments/filter/LogicalFilterOperatorArgument.java b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/schema/results/arguments/filter/LogicalFilterOperatorArgument.java new file mode 100644 index 00000000..406120dd --- /dev/null +++ b/hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/schema/results/arguments/filter/LogicalFilterOperatorArgument.java @@ -0,0 +1,8 @@ +package org.hypertrace.core.graphql.common.schema.results.arguments.filter; + +import org.hypertrace.core.graphql.deserialization.PrimitiveArgument; + +public interface LogicalFilterOperatorArgument extends PrimitiveArgument { + + String ARGUMENT_NAME = "logicalOperator"; +} diff --git a/hypertrace-core-graphql-common-schema/src/test/java/org/hypertrace/core/graphql/common/request/DefaultResultSetRequestBuilderTest.java b/hypertrace-core-graphql-common-schema/src/test/java/org/hypertrace/core/graphql/common/request/DefaultResultSetRequestBuilderTest.java index 84828b34..b29779fc 100644 --- a/hypertrace-core-graphql-common-schema/src/test/java/org/hypertrace/core/graphql/common/request/DefaultResultSetRequestBuilderTest.java +++ b/hypertrace-core-graphql-common-schema/src/test/java/org/hypertrace/core/graphql/common/request/DefaultResultSetRequestBuilderTest.java @@ -17,6 +17,7 @@ import org.hypertrace.core.graphql.attributes.AttributeModel; import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperatorArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.LimitArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.OffsetArgument; @@ -94,6 +95,9 @@ void canBuildRequest() { .thenReturn(Optional.of(List.of(this.mockFilterArgument))); when(this.mockArgumentDeserializer.deserializePrimitive(any(), eq(SpaceArgument.class))) .thenReturn(Optional.of(this.mockSpace)); + when(this.mockArgumentDeserializer.deserializePrimitive( + any(), eq(LogicalFilterOperatorArgument.class))) + .thenReturn(Optional.empty()); ResultSetRequest request = this.requestBuilder diff --git a/hypertrace-core-graphql-gateway-service-utils/src/main/java/org/hypertrace/core/graphql/utils/gateway/FilterConverter.java b/hypertrace-core-graphql-gateway-service-utils/src/main/java/org/hypertrace/core/graphql/utils/gateway/FilterConverter.java index fcc66305..6436a8cd 100644 --- a/hypertrace-core-graphql-gateway-service-utils/src/main/java/org/hypertrace/core/graphql/utils/gateway/FilterConverter.java +++ b/hypertrace-core-graphql-gateway-service-utils/src/main/java/org/hypertrace/core/graphql/utils/gateway/FilterConverter.java @@ -9,12 +9,16 @@ import javax.inject.Inject; import org.hypertrace.core.graphql.common.request.AttributeAssociation; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; +import org.hypertrace.core.graphql.common.utils.BiConverter; import org.hypertrace.core.graphql.common.utils.Converter; import org.hypertrace.gateway.service.v1.common.Filter; import org.hypertrace.gateway.service.v1.common.Operator; class FilterConverter - implements Converter>, Filter> { + implements Converter>, Filter>, + BiConverter< + Collection>, LogicalFilterOperator, Filter> { private final AttributeExpressionConverter attributeExpressionConverter; private final OperatorConverter operatorConverter; @@ -32,6 +36,12 @@ class FilterConverter @Override public Single convert(Collection> filters) { + return this.convert(filters, LogicalFilterOperator.AND); + } + + @Override + public Single convert( + Collection> filters, LogicalFilterOperator operator) { if (filters.isEmpty()) { return Single.just(Filter.getDefaultInstance()); } @@ -42,11 +52,21 @@ public Single convert(Collection> f .map( filterList -> Filter.newBuilder() - .setOperator(Operator.AND) + .setOperator(this.convertLogicalOperator(operator)) .addAllChildFilter(filterList) .build()); } + private Operator convertLogicalOperator(LogicalFilterOperator logicalFilterOperator) { + switch (logicalFilterOperator) { + case OR: + return Operator.OR; + case AND: + default: + return Operator.AND; + } + } + private Single buildFilter(AttributeAssociation filter) { return zip( this.attributeExpressionConverter.convert( diff --git a/hypertrace-core-graphql-gateway-service-utils/src/main/java/org/hypertrace/core/graphql/utils/gateway/GatewayUtilsModule.java b/hypertrace-core-graphql-gateway-service-utils/src/main/java/org/hypertrace/core/graphql/utils/gateway/GatewayUtilsModule.java index 78fa0750..7c731126 100644 --- a/hypertrace-core-graphql-gateway-service-utils/src/main/java/org/hypertrace/core/graphql/utils/gateway/GatewayUtilsModule.java +++ b/hypertrace-core-graphql-gateway-service-utils/src/main/java/org/hypertrace/core/graphql/utils/gateway/GatewayUtilsModule.java @@ -14,6 +14,7 @@ import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterOperatorType; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderDirection; import org.hypertrace.core.graphql.common.utils.BiConverter; @@ -58,6 +59,13 @@ protected void configure() { new TypeLiteral< Converter>, Filter>>() {})) .to(FilterConverter.class); + bind(Key.get( + new TypeLiteral< + BiConverter< + Collection>, + LogicalFilterOperator, + Filter>>() {})) + .to(FilterConverter.class); bind(Key.get(new TypeLiteral>() {})) .to(ColumnIdentifierConverter.class); diff --git a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsRequestBuilder.java b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsRequestBuilder.java index 2c051529..238fab18 100644 --- a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsRequestBuilder.java +++ b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsRequestBuilder.java @@ -7,10 +7,13 @@ import java.util.List; import java.util.Set; import javax.inject.Inject; +import lombok.RequiredArgsConstructor; import org.hypertrace.core.graphql.common.request.AttributeAssociation; import org.hypertrace.core.graphql.common.request.AttributeRequest; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; +import org.hypertrace.core.graphql.common.utils.BiConverter; import org.hypertrace.core.graphql.common.utils.Converter; import org.hypertrace.core.graphql.log.event.request.LogEventRequest; import org.hypertrace.gateway.service.v1.common.Expression; @@ -18,28 +21,21 @@ import org.hypertrace.gateway.service.v1.common.OrderByExpression; import org.hypertrace.gateway.service.v1.log.events.LogEventsRequest; +@RequiredArgsConstructor(onConstructor_ = @Inject) class GatewayServiceLogEventsRequestBuilder { - - private final Converter>, Filter> filterConverter; + private final BiConverter< + Collection>, LogicalFilterOperator, Filter> + filterConverter; private final Converter>, List> orderConverter; private final Converter, Set> attributeConverter; - @Inject - GatewayServiceLogEventsRequestBuilder( - Converter>, Filter> filterConverter, - Converter>, List> orderConverter, - Converter, Set> attributeConverter) { - this.filterConverter = filterConverter; - this.orderConverter = orderConverter; - this.attributeConverter = attributeConverter; - } - Single buildRequest(LogEventRequest gqlRequest) { return zip( this.attributeConverter.convert(gqlRequest.attributes()), this.orderConverter.convert(gqlRequest.orderArguments()), - this.filterConverter.convert(gqlRequest.filterArguments()), + this.filterConverter.convert( + gqlRequest.filterArguments(), gqlRequest.logicalFilterOperator()), (selections, orderBys, filters) -> LogEventsRequest.newBuilder() .setStartTimeMillis(gqlRequest.timeRange().startTime().toEpochMilli()) diff --git a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/LogEventDaoModule.java b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/LogEventDaoModule.java index e221a361..de21d049 100644 --- a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/LogEventDaoModule.java +++ b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/dao/LogEventDaoModule.java @@ -12,6 +12,7 @@ import org.hypertrace.core.graphql.common.request.AttributeRequest; import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.utils.BiConverter; import org.hypertrace.core.graphql.common.utils.Converter; @@ -46,7 +47,10 @@ protected void configure() { requireBinding( Key.get( new TypeLiteral< - Converter>, Filter>>() {})); + BiConverter< + Collection>, + LogicalFilterOperator, + Filter>>() {})); requireBinding( Key.get( diff --git a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/request/DefaultLogEventRequestBuilder.java b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/request/DefaultLogEventRequestBuilder.java index afb74e78..f7a744f5 100644 --- a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/request/DefaultLogEventRequestBuilder.java +++ b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/request/DefaultLogEventRequestBuilder.java @@ -22,6 +22,8 @@ import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument; import org.hypertrace.core.graphql.common.schema.results.ResultSet; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperatorArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.LimitArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.OffsetArgument; @@ -94,6 +96,11 @@ Single build( .deserializeObjectList(arguments, orderArgumentClass) .orElse(Collections.emptyList()); + LogicalFilterOperator filterOperator = + this.argumentDeserializer + .deserializePrimitive(arguments, LogicalFilterOperatorArgument.class) + .orElse(LogicalFilterOperator.AND); + List requestedFilters = this.argumentDeserializer .deserializeObjectList(arguments, FilterArgument.class) @@ -115,7 +122,14 @@ context, requestScope, getAttributeQueryableFields(selectionSet)) (attributeRequests, orders, filters) -> Single.just( new DefaultLogEventRequest( - context, attributeRequests, timeRange, limit, offset, orders, filters))) + context, + attributeRequests, + timeRange, + limit, + offset, + orders, + filterOperator, + filters))) .flatMap(single -> single); } @@ -135,6 +149,7 @@ private static class DefaultLogEventRequest implements LogEventRequest { int limit; int offset; List> orderArguments; + LogicalFilterOperator logicalFilterOperator; Collection> filterArguments; } } diff --git a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/request/LogEventRequest.java b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/request/LogEventRequest.java index 23147542..f4ae85ec 100644 --- a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/request/LogEventRequest.java +++ b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/request/LogEventRequest.java @@ -7,6 +7,7 @@ import org.hypertrace.core.graphql.common.request.ContextualRequest; import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; public interface LogEventRequest extends ContextualRequest { @@ -21,5 +22,7 @@ public interface LogEventRequest extends ContextualRequest { List> orderArguments(); + LogicalFilterOperator logicalFilterOperator(); + Collection> filterArguments(); } diff --git a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/schema/LogEventSchema.java b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/schema/LogEventSchema.java index 6a844def..77677478 100644 --- a/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/schema/LogEventSchema.java +++ b/hypertrace-core-graphql-log-event-schema/src/main/java/org/hypertrace/core/graphql/log/event/schema/LogEventSchema.java @@ -7,6 +7,8 @@ import java.util.List; import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperatorArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.LimitArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.OffsetArgument; @@ -21,6 +23,8 @@ public interface LogEventSchema { @GraphQLDataFetcher(LogEventFetcher.class) LogEventResultSet logEvents( @GraphQLName(TimeRangeArgument.ARGUMENT_NAME) @GraphQLNonNull TimeRangeArgument between, + @GraphQLName(LogicalFilterOperatorArgument.ARGUMENT_NAME) + LogicalFilterOperator logicalFilterOperator, @GraphQLName(FilterArgument.ARGUMENT_NAME) List filterBy, @GraphQLName(OrderArgument.ARGUMENT_NAME) List orderBy, @GraphQLName(LimitArgument.ARGUMENT_NAME) int limit, diff --git a/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/BaseDaoTest.java b/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/BaseDaoTest.java index 951c0ae4..1b356c25 100644 --- a/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/BaseDaoTest.java +++ b/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/BaseDaoTest.java @@ -14,6 +14,7 @@ import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument; import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.context.GraphQlRequestContext; import org.hypertrace.core.graphql.log.event.request.LogEventRequest; @@ -30,6 +31,7 @@ static class DefaultLogEventRequest implements LogEventRequest { int limit; int offset; List> orderArguments; + LogicalFilterOperator logicalFilterOperator; Collection> filterArguments; } diff --git a/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsRequestBuilderTest.java b/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsRequestBuilderTest.java index 879b57e6..7f7efc43 100644 --- a/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsRequestBuilderTest.java +++ b/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsRequestBuilderTest.java @@ -20,7 +20,9 @@ import org.hypertrace.core.graphql.common.request.AttributeRequest; import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; +import org.hypertrace.core.graphql.common.utils.BiConverter; import org.hypertrace.core.graphql.common.utils.Converter; import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig; import org.hypertrace.core.graphql.utils.gateway.GatewayUtilsModule; @@ -50,11 +52,15 @@ protected void configure() { } }); - Converter>, Filter> filterConverter = - injector.getInstance( - Key.get( - new TypeLiteral< - Converter>, Filter>>() {})); + BiConverter>, LogicalFilterOperator, Filter> + filterConverter = + injector.getInstance( + Key.get( + new TypeLiteral< + BiConverter< + Collection>, + LogicalFilterOperator, + Filter>>() {})); Converter>, List> orderConverter = injector.getInstance( Key.get( @@ -115,6 +121,7 @@ void testBuildRequest() { 0, 0, List.of(), + LogicalFilterOperator.AND, Collections.emptyList()); LogEventsRequest logEventRequest = requestBuilder.buildRequest(defaultLogEventRequest).blockingGet(); diff --git a/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsResponseConverterTest.java b/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsResponseConverterTest.java index 4d472936..90aa01fe 100644 --- a/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsResponseConverterTest.java +++ b/hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsResponseConverterTest.java @@ -19,6 +19,7 @@ import org.hypertrace.core.graphql.common.request.AttributeAssociation; import org.hypertrace.core.graphql.common.request.AttributeRequest; import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.utils.BiConverter; import org.hypertrace.core.graphql.log.event.schema.LogEventResultSet; import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig; @@ -121,6 +122,7 @@ void testConvert() { 0, 0, List.of(), + LogicalFilterOperator.AND, Collections.emptyList()); LogEventResultSet logEventResultSet = responseConverter.convert(defaultLogEventRequest, logEventsResponse).blockingGet(); diff --git a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanRequestBuilder.java b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanRequestBuilder.java index 1445d3a9..aeb0e179 100644 --- a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanRequestBuilder.java +++ b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/dao/GatewayServiceSpanRequestBuilder.java @@ -7,10 +7,13 @@ import java.util.List; import java.util.Set; import javax.inject.Inject; +import lombok.RequiredArgsConstructor; import org.hypertrace.core.graphql.common.request.AttributeAssociation; import org.hypertrace.core.graphql.common.request.AttributeRequest; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; +import org.hypertrace.core.graphql.common.utils.BiConverter; import org.hypertrace.core.graphql.common.utils.Converter; import org.hypertrace.core.graphql.span.request.SpanRequest; import org.hypertrace.gateway.service.v1.common.Expression; @@ -18,28 +21,23 @@ import org.hypertrace.gateway.service.v1.common.OrderByExpression; import org.hypertrace.gateway.service.v1.span.SpansRequest; +@RequiredArgsConstructor(onConstructor_ = @Inject) class GatewayServiceSpanRequestBuilder { - private final Converter>, Filter> filterConverter; + private final BiConverter< + Collection>, LogicalFilterOperator, Filter> + filterConverter; private final Converter>, List> orderConverter; private final Converter, Set> attributeConverter; - @Inject - GatewayServiceSpanRequestBuilder( - Converter>, Filter> filterConverter, - Converter>, List> orderConverter, - Converter, Set> attributeConverter) { - this.filterConverter = filterConverter; - this.orderConverter = orderConverter; - this.attributeConverter = attributeConverter; - } - Single buildRequest(SpanRequest gqlRequest) { return zip( this.attributeConverter.convert(gqlRequest.spanEventsRequest().attributes()), this.orderConverter.convert(gqlRequest.spanEventsRequest().orderArguments()), - this.filterConverter.convert(gqlRequest.spanEventsRequest().filterArguments()), + this.filterConverter.convert( + gqlRequest.spanEventsRequest().filterArguments(), + gqlRequest.spanEventsRequest().logicalFilterOperator()), (selections, orderBys, filters) -> SpansRequest.newBuilder() .setStartTimeMillis( 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 ce172161..f9ae290f 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 @@ -15,6 +15,7 @@ import org.hypertrace.core.graphql.common.request.FilterRequestBuilder; import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.utils.BiConverter; import org.hypertrace.core.graphql.common.utils.Converter; @@ -58,7 +59,10 @@ protected void configure() { requireBinding( Key.get( new TypeLiteral< - Converter>, Filter>>() {})); + BiConverter< + Collection>, + LogicalFilterOperator, + Filter>>() {})); requireBinding( Key.get( diff --git a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/schema/SpanSchema.java b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/schema/SpanSchema.java index 49693ea6..6510b917 100644 --- a/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/schema/SpanSchema.java +++ b/hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/schema/SpanSchema.java @@ -7,6 +7,8 @@ import java.util.List; import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperatorArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.LimitArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.OffsetArgument; @@ -24,6 +26,8 @@ public interface SpanSchema { @GraphQLDataFetcher(SpanFetcher.class) SpanResultSet spans( @GraphQLName(TimeRangeArgument.ARGUMENT_NAME) @GraphQLNonNull TimeRangeArgument between, + @GraphQLName(LogicalFilterOperatorArgument.ARGUMENT_NAME) + LogicalFilterOperator logicalFilterOperator, @GraphQLName(FilterArgument.ARGUMENT_NAME) List filterBy, @GraphQLName(OrderArgument.ARGUMENT_NAME) List orderBy, @GraphQLName(LimitArgument.ARGUMENT_NAME) int limit, @@ -36,6 +40,8 @@ SpanResultSet spans( @GraphQLDataFetcher(ExportSpanFetcher.class) ExportSpanResult exportSpans( @GraphQLName(TimeRangeArgument.ARGUMENT_NAME) @GraphQLNonNull TimeRangeArgument between, + @GraphQLName(LogicalFilterOperatorArgument.ARGUMENT_NAME) + LogicalFilterOperator logicalFilterOperator, @GraphQLName(FilterArgument.ARGUMENT_NAME) List filterBy, @GraphQLName(LimitArgument.ARGUMENT_NAME) int limit); } diff --git a/hypertrace-core-graphql-span-schema/src/test/java/org/hypertrace/core/graphql/span/dao/DaoTestUtil.java b/hypertrace-core-graphql-span-schema/src/test/java/org/hypertrace/core/graphql/span/dao/DaoTestUtil.java index 19a9d6f2..cc65238b 100644 --- a/hypertrace-core-graphql-span-schema/src/test/java/org/hypertrace/core/graphql/span/dao/DaoTestUtil.java +++ b/hypertrace-core-graphql-span-schema/src/test/java/org/hypertrace/core/graphql/span/dao/DaoTestUtil.java @@ -21,6 +21,7 @@ import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterOperatorType; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterType; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.context.GraphQlRequestContext; import org.hypertrace.core.graphql.span.request.SpanRequest; @@ -85,6 +86,7 @@ static class DefaultResultSetRequest implements ResultSetRequest int limit; int offset; List> orderArguments; + LogicalFilterOperator logicalFilterOperator; Collection> filterArguments; Optional spaceId; } diff --git a/hypertrace-core-graphql-span-schema/src/test/java/org/hypertrace/core/graphql/span/dao/SpanLogEventRequestBuilderTest.java b/hypertrace-core-graphql-span-schema/src/test/java/org/hypertrace/core/graphql/span/dao/SpanLogEventRequestBuilderTest.java index 1258ee03..d4847354 100644 --- a/hypertrace-core-graphql-span-schema/src/test/java/org/hypertrace/core/graphql/span/dao/SpanLogEventRequestBuilderTest.java +++ b/hypertrace-core-graphql-span-schema/src/test/java/org/hypertrace/core/graphql/span/dao/SpanLogEventRequestBuilderTest.java @@ -36,6 +36,7 @@ import org.hypertrace.core.graphql.common.request.FilterRequestBuilder; import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.utils.Converter; import org.hypertrace.core.graphql.span.dao.DaoTestUtil.DefaultAttributeRequest; import org.hypertrace.core.graphql.span.dao.DaoTestUtil.DefaultResultSetRequest; @@ -150,6 +151,7 @@ void testBuildRequest() { 0, 0, List.of(), + LogicalFilterOperator.AND, Collections.emptyList(), Optional.empty()); SpanRequest spanRequest = @@ -192,6 +194,7 @@ void testBuildRequest_addSpanId() { 0, 0, List.of(), + LogicalFilterOperator.AND, Collections.emptyList(), Optional.empty()); SpanRequest spanRequest = diff --git a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceRequestBuilder.java b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceRequestBuilder.java index 1cb37645..ce5800a6 100644 --- a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceRequestBuilder.java +++ b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/GatewayServiceTraceRequestBuilder.java @@ -7,10 +7,13 @@ import java.util.List; import java.util.Set; import javax.inject.Inject; +import lombok.RequiredArgsConstructor; import org.hypertrace.core.graphql.common.request.AttributeAssociation; import org.hypertrace.core.graphql.common.request.AttributeRequest; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; +import org.hypertrace.core.graphql.common.utils.BiConverter; import org.hypertrace.core.graphql.common.utils.Converter; import org.hypertrace.core.graphql.trace.request.TraceRequest; import org.hypertrace.gateway.service.v1.common.Expression; @@ -18,29 +21,23 @@ import org.hypertrace.gateway.service.v1.common.OrderByExpression; import org.hypertrace.gateway.service.v1.trace.TracesRequest; +@RequiredArgsConstructor(onConstructor_ = @Inject) class GatewayServiceTraceRequestBuilder { - - private final Converter>, Filter> filterConverter; + private final BiConverter< + Collection>, LogicalFilterOperator, Filter> + filterConverter; private final Converter>, List> orderConverter; private final Converter, Set> selectionConverter; - @Inject - GatewayServiceTraceRequestBuilder( - Converter>, Filter> filterConverter, - Converter>, List> orderConverter, - Converter, Set> selectionConverter) { - this.filterConverter = filterConverter; - this.orderConverter = orderConverter; - this.selectionConverter = selectionConverter; - } - Single buildRequest(TraceRequest request) { return zip( this.selectionConverter.convert(request.resultSetRequest().attributes()), this.orderConverter.convert(request.resultSetRequest().orderArguments()), - this.filterConverter.convert(request.resultSetRequest().filterArguments()), + this.filterConverter.convert( + request.resultSetRequest().filterArguments(), + request.resultSetRequest().logicalFilterOperator()), (selections, orderBys, filters) -> TracesRequest.newBuilder() .setScope(request.traceType().getScopeString()) diff --git a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/TraceDaoModule.java b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/TraceDaoModule.java index 77ca9524..f532e049 100644 --- a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/TraceDaoModule.java +++ b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/dao/TraceDaoModule.java @@ -12,6 +12,7 @@ import org.hypertrace.core.graphql.common.request.AttributeRequest; import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeExpression; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.utils.BiConverter; import org.hypertrace.core.graphql.common.utils.Converter; @@ -47,7 +48,10 @@ protected void configure() { requireBinding( Key.get( new TypeLiteral< - Converter>, Filter>>() {})); + BiConverter< + Collection>, + LogicalFilterOperator, + Filter>>() {})); requireBinding( Key.get( diff --git a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/schema/TraceSchema.java b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/schema/TraceSchema.java index f4fda8dd..81d74c01 100644 --- a/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/schema/TraceSchema.java +++ b/hypertrace-core-graphql-trace-schema/src/main/java/org/hypertrace/core/graphql/trace/schema/TraceSchema.java @@ -7,6 +7,8 @@ import java.util.List; import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperator; +import org.hypertrace.core.graphql.common.schema.results.arguments.filter.LogicalFilterOperatorArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.LimitArgument; import org.hypertrace.core.graphql.common.schema.results.arguments.page.OffsetArgument; @@ -25,6 +27,8 @@ public interface TraceSchema { TraceResultSet traces( @Deprecated @GraphQLName(TraceTypeArgument.ARGUMENT_NAME) TraceType type, @GraphQLName(TimeRangeArgument.ARGUMENT_NAME) @GraphQLNonNull TimeRangeArgument between, + @GraphQLName(LogicalFilterOperatorArgument.ARGUMENT_NAME) + LogicalFilterOperator logicalFilterOperator, @GraphQLName(FilterArgument.ARGUMENT_NAME) List filterBy, @GraphQLName(OrderArgument.ARGUMENT_NAME) List orderBy, @GraphQLName(LimitArgument.ARGUMENT_NAME) int limit,