Skip to content

feat: add group limit to explorer api #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2021
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
Expand Up @@ -73,6 +73,7 @@ Single<org.hypertrace.gateway.service.v1.explore.ExploreRequest> buildRequest(
.setOffset(request.offset())
.setFilter(filter)
.setSpaceId(request.spaceId().orElse("")) // String proto default value
.setGroupLimit(request.groupLimit().orElse(0)) // Int proto default value
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ private static class DefaultGroupByArgument implements GroupByArgument {

@JsonProperty(GROUP_BY_INCLUDE_REST_KEY)
boolean includeRest;

@JsonProperty(GROUP_BY_LIMIT_KEY)
int groupLimit;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ private Single<ExploreRequest> build(
groupByAttribute,
intervalArgument,
groupBy.map(GroupByArgument::includeRest).orElse(false),
spaceId));
spaceId,
groupBy.map(GroupByArgument::groupLimit)));
}

private Single<Set<AttributeRequest>> buildGroupByAttributes(
Expand All @@ -189,5 +190,6 @@ private static class DefaultExploreRequest implements ExploreRequest {
Optional<IntervalArgument> timeInterval;
boolean includeRest;
Optional<String> spaceId;
Optional<Integer> groupLimit;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public interface ExploreRequest {
boolean includeRest();

Optional<String> spaceId();

Optional<Integer> groupLimit();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface GroupByArgument {

String GROUP_BY_KEYS_KEY = "keys";
String GROUP_BY_INCLUDE_REST_KEY = "includeRest";
String GROUP_BY_LIMIT_KEY = "groupLimit";

@GraphQLField
@GraphQLNonNull
Expand All @@ -21,4 +22,8 @@ public interface GroupByArgument {
@GraphQLField
@GraphQLName(GROUP_BY_INCLUDE_REST_KEY)
boolean includeRest();

@GraphQLField
@GraphQLName(GROUP_BY_LIMIT_KEY)
int groupLimit();
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,41 +138,36 @@ public Instant startTime() {
private static class ActiveSpaceExploreRequest implements ExploreRequest {
private static final String SPACE_IDS_KEY = "spaceIds";
private static final String SPACE_IDS_SCOPE = "EVENT";
private static final int MAX_SPACES = 100;

GraphQlRequestContext requestContext;
String scope;
String scope = SPACE_IDS_SCOPE;
int limit = MAX_SPACES;
int offset = 0;
Set<AttributeRequest> attributeRequests = emptySet();
List<AttributeAssociation<FilterArgument>> filterArguments = emptyList();
Optional<IntervalArgument> timeInterval = Optional.empty();
boolean includeRest = false;
Optional<String> spaceId = Optional.empty();
Optional<Integer> groupLimit = Optional.of(MAX_SPACES);

TimeRangeArgument timeRange;
int limit;
int offset;
Set<AttributeRequest> attributeRequests;
Set<MetricAggregationRequest> aggregationRequests;
List<ExploreOrderArgument> orderArguments;
List<AttributeAssociation<FilterArgument>> filterArguments;
Set<AttributeRequest> groupByAttributeRequests;
Optional<IntervalArgument> timeInterval;
boolean includeRest;
Optional<String> spaceId;

ActiveSpaceExploreRequest(
GraphQlRequestContext context,
TimeRangeArgument timeRange,
AttributeRequest spaceIdRequest,
MetricAggregationRequest spaceIdCountRequest) {
this.requestContext = context;
this.scope = SPACE_IDS_SCOPE;
this.limit = 100;
this.offset = 0;
this.timeRange = timeRange;
this.attributeRequests = emptySet();
// Aggregation needed to pass explorer validation - a no agg request is not valid
this.aggregationRequests = Set.of(spaceIdCountRequest);
this.orderArguments =
List.of(new SpaceExploreOrderArgument(Optional.of(spaceIdRequest.attribute())));
this.filterArguments = emptyList();
this.groupByAttributeRequests = Set.of(spaceIdRequest);
this.timeInterval = Optional.empty();
this.includeRest = false;
this.spaceId = Optional.empty();
}
}

Expand Down