use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class ExploreRequestValidatorTest method timeAggregationsAkaIntervals_shouldBeValid.
@Test
public void timeAggregationsAkaIntervals_shouldBeValid() {
Map<String, AttributeMetadata> attributeMetadataMap = new HashMap<>();
attributeMetadataMap.put("duration", AttributeMetadata.newBuilder().setFqn("duration").setType(AttributeType.ATTRIBUTE).build());
attributeMetadataMap.put("callersCount", AttributeMetadata.newBuilder().setFqn("callersCount").setType(AttributeType.METRIC).build());
ExploreRequest exploreRequest = ExploreRequest.newBuilder().setContext("API_TRACE").setStartTimeMillis(Instant.parse("2019-11-18T17:22:51.902Z").toEpochMilli()).setEndTimeMillis(Instant.parse("2019-11-18T17:26:51.902Z").toEpochMilli()).addTimeAggregation(TimeAggregation.newBuilder().setPeriod(Period.newBuilder().setUnit("SECONDS").setValue(60)).setAggregation(Expression.newBuilder().setFunction(FunctionExpression.newBuilder().setFunction(FunctionType.AVG).setAlias("AVG_Duration").addArguments(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("duration")))))).addTimeAggregation(TimeAggregation.newBuilder().setPeriod(Period.newBuilder().setUnit("SECONDS").setValue(60)).setAggregation(Expression.newBuilder().setFunction(FunctionExpression.newBuilder().setFunction(FunctionType.MAX).setAlias("MAX_Duration").addArguments(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("duration")))))).addTimeAggregation(TimeAggregation.newBuilder().setPeriod(Period.newBuilder().setUnit("SECONDS").setValue(60)).setAggregation(Expression.newBuilder().setFunction(FunctionExpression.newBuilder().setFunction(FunctionType.MIN).setAlias("MIN_callersCount").addArguments(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("callersCount")))))).setLimit(10).build();
ExploreRequestValidator exploreRequestValidator = new ExploreRequestValidator();
exploreRequestValidator.validate(exploreRequest, attributeMetadataMap);
}
use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class ExploreRequestValidatorTest method requestWithNoContext_shouldThrowIllegalArgException.
@Test
public void requestWithNoContext_shouldThrowIllegalArgException() {
Map<String, AttributeMetadata> attributeMetadataMap = new HashMap<>();
ExploreRequest exploreRequest = ExploreRequest.newBuilder().setStartTimeMillis(Instant.parse("2019-11-14T17:40:51.902Z").toEpochMilli()).setEndTimeMillis(Instant.parse("2019-11-14T18:40:51.902Z").toEpochMilli()).addSelection(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("serviceName"))).addSelection(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("apiName"))).setLimit(10).build();
ExploreRequestValidator exploreRequestValidator = new ExploreRequestValidator();
Assertions.assertThrows(IllegalArgumentException.class, () -> {
exploreRequestValidator.validate(exploreRequest, attributeMetadataMap);
});
}
use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class ExploreRequestValidatorTest method requestWithZeroLimit_shouldThrowIllegalArgException.
@Test
public void requestWithZeroLimit_shouldThrowIllegalArgException() {
Map<String, AttributeMetadata> attributeMetadataMap = new HashMap<>();
ExploreRequest exploreRequest = ExploreRequest.newBuilder().setContext("API_TRACE").setStartTimeMillis(Instant.parse("2019-11-14T17:40:51.902Z").toEpochMilli()).setEndTimeMillis(Instant.parse("2019-11-14T18:40:51.902Z").toEpochMilli()).addTimeAggregation(TimeAggregation.newBuilder().setPeriod(Period.newBuilder().setUnit("SECONDS").setValue(60)).setAggregation(Expression.newBuilder().setFunction(FunctionExpression.newBuilder().setFunction(FunctionType.AVG).setAlias("AVG_Duration").addArguments(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("duration")))))).addGroupBy(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("serviceName"))).build();
ExploreRequestValidator exploreRequestValidator = new ExploreRequestValidator();
Assertions.assertThrows(IllegalArgumentException.class, () -> {
exploreRequestValidator.validate(exploreRequest, attributeMetadataMap);
});
}
use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class ExploreRequestValidatorTest method timeAggregationsWithDifferentPeriods_shouldThrowIllegalArgException.
@Test
public void timeAggregationsWithDifferentPeriods_shouldThrowIllegalArgException() {
Map<String, AttributeMetadata> attributeMetadataMap = new HashMap<>();
attributeMetadataMap.put("duration", AttributeMetadata.newBuilder().setFqn("duration").setType(AttributeType.ATTRIBUTE).build());
attributeMetadataMap.put("callersCount", AttributeMetadata.newBuilder().setFqn("callersCount").setType(AttributeType.METRIC).build());
ExploreRequest exploreRequest = ExploreRequest.newBuilder().setContext("API_TRACE").setStartTimeMillis(Instant.parse("2019-11-18T17:22:51.902Z").toEpochMilli()).setEndTimeMillis(Instant.parse("2019-11-18T17:26:51.902Z").toEpochMilli()).addTimeAggregation(TimeAggregation.newBuilder().setPeriod(Period.newBuilder().setUnit("SECONDS").setValue(60)).setAggregation(Expression.newBuilder().setFunction(FunctionExpression.newBuilder().setFunction(FunctionType.AVG).setAlias("AVG_Duration").addArguments(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("duration")))))).addTimeAggregation(TimeAggregation.newBuilder().setPeriod(Period.newBuilder().setUnit("SECONDS").setValue(30)).setAggregation(Expression.newBuilder().setFunction(FunctionExpression.newBuilder().setFunction(FunctionType.MAX).setAlias("MAX_Duration").addArguments(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("duration")))))).addTimeAggregation(TimeAggregation.newBuilder().setPeriod(Period.newBuilder().setUnit("SECONDS").setValue(60)).setAggregation(Expression.newBuilder().setFunction(FunctionExpression.newBuilder().setFunction(FunctionType.MIN).setAlias("MIN_callersCount").addArguments(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("callersCount")))))).setLimit(10).build();
ExploreRequestValidator exploreRequestValidator = new ExploreRequestValidator();
Assertions.assertThrows(IllegalArgumentException.class, () -> {
exploreRequestValidator.validate(exploreRequest, attributeMetadataMap);
});
}
use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.
the class ExploreRequestValidatorTest method aggregationsWithGroupBy_shouldBeValid.
@Test
public void aggregationsWithGroupBy_shouldBeValid() {
Map<String, AttributeMetadata> attributeMetadataMap = new HashMap<>();
attributeMetadataMap.put("serviceName", AttributeMetadata.newBuilder().setFqn("serviceName").setType(AttributeType.ATTRIBUTE).build());
attributeMetadataMap.put("callersCount", AttributeMetadata.newBuilder().setFqn("callersCount").setType(AttributeType.METRIC).build());
ExploreRequest exploreRequest = ExploreRequest.newBuilder().setContext("API_TRACE").setStartTimeMillis(Instant.parse("2019-11-14T17:40:51.902Z").toEpochMilli()).setEndTimeMillis(Instant.parse("2019-11-14T18:40:51.902Z").toEpochMilli()).addSelection(Expression.newBuilder().setFunction(FunctionExpression.newBuilder().setFunction(FunctionType.AVG).setAlias("AVG_callersCount").addArguments(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("callersCount"))))).addGroupBy(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("serviceName"))).setLimit(3).build();
ExploreRequestValidator exploreRequestValidator = new ExploreRequestValidator();
exploreRequestValidator.validate(exploreRequest, attributeMetadataMap);
}
Aggregations