use of org.hypertrace.core.datamodel.AttributeValue in project hypertrace-ingester by hypertrace.
the class ElasticsearchBackendProviderTest method testBackendResolutionForOTEvent.
@Test
public void testBackendResolutionForOTEvent() {
BackendInfo backendInfo = backendEntityEnricher.resolve(getElasticsearchOTEvent(), structuredTrace, structuredTraceGraph).get();
Entity entity = backendInfo.getEntity();
Assertions.assertEquals("test", entity.getEntityName());
Map<String, AttributeValue> attributes = backendInfo.getAttributes();
assertEquals(Map.of("BACKEND_OPERATION", AttributeValueCreator.create("GET"), "BACKEND_DESTINATION", AttributeValueCreator.create("test-index")), attributes);
}
use of org.hypertrace.core.datamodel.AttributeValue in project hypertrace-ingester by hypertrace.
the class ErrorsAndExceptionsEnricherTest method test_successStatus_shouldNotGetError.
@Test
public void test_successStatus_shouldNotGetError() {
ErrorsAndExceptionsEnricher enricher = new ErrorsAndExceptionsEnricher();
// Negative test
Event e2 = createMockEvent();
Map<String, AttributeValue> attributeValueMap = e2.getAttributes().getAttributeMap();
attributeValueMap.put(Constants.getEnrichedSpanConstant(API_STATUS), AttributeValue.newBuilder().setValue(Constants.getEnrichedSpanConstant(ApiStatus.API_STATUS_SUCCESS)).build());
enricher.enrichEvent(null, e2);
Assertions.assertNull(e2.getMetrics().getMetricMap().get(Constants.getEnrichedSpanConstant(ErrorMetrics.ERROR_METRICS_ERROR_COUNT)));
}
use of org.hypertrace.core.datamodel.AttributeValue in project hypertrace-ingester by hypertrace.
the class HttpAttributeEnricherTest method testGetQueryParamsFromUrl.
@Test
public void testGetQueryParamsFromUrl() {
String query_string = "action=checkout&cat=1dog=2&action=a&age=2&age=3;&location=&area&&";
Event e = createMockEvent();
// ; in url should not be treated as an splitting character.
// Url in this test also contains successive & and param with no value.
addAttribute(e, RawSpanConstants.getValue(HTTP_PATH), "/users");
addAttribute(e, RawSpanConstants.getValue(HTTP_REQUEST_QUERY_STRING), query_string);
enricher.enrichEvent(mockTrace, e);
String httpPathEnrichedValue = SpanAttributeUtils.getStringAttribute(e, Constants.getEnrichedSpanConstant(HTTP_REQUEST_PATH));
assertEquals("/users", httpPathEnrichedValue);
AttributeValue actionParam = SpanAttributeUtils.getAttributeValue(e, Constants.getEnrichedSpanConstant(HTTP_REQUEST_QUERY_PARAM) + ".action");
assertEquals("checkout", actionParam.getValue());
assertEquals(List.of("checkout", "a"), actionParam.getValueList());
AttributeValue ageParam = SpanAttributeUtils.getAttributeValue(e, Constants.getEnrichedSpanConstant(HTTP_REQUEST_QUERY_PARAM) + ".age");
assertEquals("2", ageParam.getValue());
assertEquals(List.of("2", "3;"), ageParam.getValueList());
AttributeValue locationParam = SpanAttributeUtils.getAttributeValue(e, Constants.getEnrichedSpanConstant(HTTP_REQUEST_QUERY_PARAM) + ".location");
assertNull(locationParam);
AttributeValue areaParam = SpanAttributeUtils.getAttributeValue(e, Constants.getEnrichedSpanConstant(HTTP_REQUEST_QUERY_PARAM) + ".area");
assertNull(areaParam);
AttributeValue catParam = SpanAttributeUtils.getAttributeValue(e, Constants.getEnrichedSpanConstant(HTTP_REQUEST_QUERY_PARAM) + ".cat");
assertEquals("1dog=2", catParam.getValue());
assertEquals(List.of("1dog=2"), catParam.getValueList());
}
use of org.hypertrace.core.datamodel.AttributeValue in project hypertrace-ingester by hypertrace.
the class HttpAttributeEnricherTest method testDecodeQueryParamsInvalidInput.
@Test
public void testDecodeQueryParamsInvalidInput() {
// Try putting invalid encoded string in both query param key and value.
String query_string = "action=check%!mout&loca%.Ption=hello%3Dworld";
Event e = createMockEvent();
addAttribute(e, RawSpanConstants.getValue(HTTP_PATH), "/users");
addAttribute(e, RawSpanConstants.getValue(HTTP_REQUEST_QUERY_STRING), query_string);
enricher.enrichEvent(mockTrace, e);
// If input is invalid(can't be decoded) the input is returned as it is.
AttributeValue actionParam = SpanAttributeUtils.getAttributeValue(e, Constants.getEnrichedSpanConstant(HTTP_REQUEST_QUERY_PARAM) + ".action");
assertEquals("check%!mout", actionParam.getValue());
assertEquals(List.of("check%!mout"), actionParam.getValueList());
AttributeValue locationParam = SpanAttributeUtils.getAttributeValue(e, Constants.getEnrichedSpanConstant(HTTP_REQUEST_QUERY_PARAM) + ".loca%.Ption");
assertEquals("hello=world", locationParam.getValue());
assertEquals(List.of("hello=world"), locationParam.getValueList());
}
use of org.hypertrace.core.datamodel.AttributeValue in project hypertrace-ingester by hypertrace.
the class SpanTypeAttributeEnricherTest method test_getProtocolName_grpcAndHttp_shouldReturnGrpc.
@Test
public void test_getProtocolName_grpcAndHttp_shouldReturnGrpc() {
Map<String, AttributeValue> map = new HashMap<>();
map.put(Constants.getRawSpanConstant(Grpc.GRPC_METHOD), AttributeValue.newBuilder().setValue("grpc method").build());
map.put(Constants.getRawSpanConstant(Http.HTTP_REQUEST_METHOD), AttributeValue.newBuilder().setValue("GET").build());
Event e = createEvent(map, new HashMap<>());
Assertions.assertEquals(Protocol.PROTOCOL_GRPC, SpanTypeAttributeEnricher.getProtocolName(e));
}
Aggregations