Search in sources :

Example 11 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class QueryAndGatewayDtoConverter method convertToGatewayValueForMetricValue.

public static org.hypertrace.gateway.service.v1.common.Value convertToGatewayValueForMetricValue(AttributeKind attributeKind, Map<String, AttributeMetadata> resultKeyToAttributeMetadataMap, ColumnMetadata metadata, Value queryValue) {
    String resultKey = metadata.getColumnName();
    // if there's no override from the function, then this is regular attribute, then
    // use the attribute map to convert the value
    AttributeMetadata attributeMetadata;
    if (attributeKind == null) {
        attributeMetadata = resultKeyToAttributeMetadataMap.get(resultKey);
    } else {
        attributeMetadata = AttributeMetadata.newBuilder().setId(metadata.getColumnName()).setType(AttributeType.METRIC).setValueKind(attributeKind).build();
    }
    LOG.debug("Converting {} from type: {} to type: {}", resultKey, metadata.getValueType().name(), attributeMetadata.getValueKind().name());
    return QueryAndGatewayDtoConverter.convertQueryValueToGatewayValue(queryValue, attributeMetadata);
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata)

Example 12 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class EntityServiceAndGatewayServiceConverter method convertToGatewayValueForMetricValue.

public static org.hypertrace.gateway.service.v1.common.Value convertToGatewayValueForMetricValue(AttributeKind attributeKind, Map<String, AttributeMetadata> resultKeyToAttributeMetadataMap, ColumnMetadata metadata, Value value) {
    String resultKey = metadata.getColumnName();
    // if there's no override from the function, then this is regular attribute, then
    // use the attribute map to convert the value
    AttributeMetadata attributeMetadata;
    if (attributeKind == null) {
        attributeMetadata = resultKeyToAttributeMetadataMap.get(resultKey);
    } else {
        attributeMetadata = AttributeMetadata.newBuilder().setId(metadata.getColumnName()).setType(AttributeType.METRIC).setValueKind(attributeKind).build();
    }
    LOG.debug("Converting {} from type: {} to type: {}", resultKey, metadata.getValueType().name(), attributeMetadata.getValueKind().name());
    return EntityServiceAndGatewayServiceConverter.convertQueryValueToGatewayValue(value, attributeMetadata);
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata)

Example 13 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class EdsEntityUpdaterTest method mockTestMetadata.

private Map<String, AttributeMetadata> mockTestMetadata() {
    Map<String, AttributeMetadata> attributeMetadataMap = new HashMap<>();
    AttributeMetadata stringMetadata = AttributeMetadata.newBuilder().setValueKind(AttributeKind.TYPE_STRING).build();
    attributeMetadataMap.put("Test.id", stringMetadata);
    attributeMetadataMap.put("Test.status", stringMetadata);
    return attributeMetadataMap;
}
Also used : HashMap(java.util.HashMap) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata)

Example 14 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class ExploreRequestValidatorTest method selectingOnUnknownAttributes_shouldThrowIllegalArgException.

@Test
public void selectingOnUnknownAttributes_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()).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 15 with AttributeMetadata

use of org.hypertrace.core.attribute.service.v1.AttributeMetadata in project gateway-service by hypertrace.

the class ExploreRequestValidatorTest method requestsWithFunctionGroupBy_shouldThrowIllegalArgException.

@Test
public void requestsWithFunctionGroupBy_shouldThrowIllegalArgException() {
    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().setFunction(FunctionExpression.newBuilder().setFunction(FunctionType.AVG).setAlias("AVG_CallersCount").addArguments(Expression.newBuilder().setColumnIdentifier(ColumnIdentifier.newBuilder().setColumnName("callersCount"))))).setLimit(3).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)

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