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);
}
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);
}
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;
}
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);
});
}
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);
});
}
Aggregations