Search in sources :

Example 16 with AttributeMetadata

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);
}
Also used : HashMap(java.util.HashMap) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) ExploreRequest(org.hypertrace.gateway.service.v1.explore.ExploreRequest) Test(org.junit.jupiter.api.Test)

Example 17 with AttributeMetadata

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);
    });
}
Also used : HashMap(java.util.HashMap) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) ExploreRequest(org.hypertrace.gateway.service.v1.explore.ExploreRequest) Test(org.junit.jupiter.api.Test)

Example 18 with AttributeMetadata

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);
    });
}
Also used : HashMap(java.util.HashMap) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) ExploreRequest(org.hypertrace.gateway.service.v1.explore.ExploreRequest) Test(org.junit.jupiter.api.Test)

Example 19 with AttributeMetadata

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);
    });
}
Also used : HashMap(java.util.HashMap) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) ExploreRequest(org.hypertrace.gateway.service.v1.explore.ExploreRequest) Test(org.junit.jupiter.api.Test)

Example 20 with AttributeMetadata

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);
}
Also used : HashMap(java.util.HashMap) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) ExploreRequest(org.hypertrace.gateway.service.v1.explore.ExploreRequest) Test(org.junit.jupiter.api.Test)

Aggregations

AttributeMetadata (org.hypertrace.core.attribute.service.v1.AttributeMetadata)140 Test (org.junit.jupiter.api.Test)109 Value (org.hypertrace.core.query.service.api.Value)55 HashMap (java.util.HashMap)44 ExploreRequest (org.hypertrace.gateway.service.v1.explore.ExploreRequest)15 QueryRequest (org.hypertrace.core.query.service.api.QueryRequest)11 ResultSetChunk (org.hypertrace.core.query.service.api.ResultSetChunk)11 EntitiesRequest (org.hypertrace.gateway.service.v1.entity.EntitiesRequest)11 Event (org.hypertrace.core.datamodel.Event)10 TimeAggregation (org.hypertrace.gateway.service.v1.common.TimeAggregation)9 Map (java.util.Map)8 Row (org.hypertrace.core.query.service.api.Row)8 List (java.util.List)7 ColumnMetadata (org.hypertrace.core.query.service.api.ColumnMetadata)7 RequestContext (org.hypertrace.gateway.service.common.RequestContext)7 ArrayList (java.util.ArrayList)6 TracesRequest (org.hypertrace.gateway.service.v1.trace.TracesRequest)6 Iterator (java.util.Iterator)5 BaselineEntitiesRequest (org.hypertrace.gateway.service.v1.baseline.BaselineEntitiesRequest)5 Instant (java.time.Instant)4