use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class EnrichedSpanUtilsTest method getRequestSize_grpcProtocol.
@Test
public void getRequestSize_grpcProtocol() {
Event e = createMockEventWithEnrichedAttribute("PROTOCOL", "GRPC");
when(e.getAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
addAttribute(e, RawSpanConstants.getValue(GRPC_REQUEST_BODY), "some grpc response body");
Optional<Integer> requestSize = EnrichedSpanUtils.getRequestSize(e);
assertFalse(requestSize.isEmpty());
assertEquals(23, requestSize.get().intValue());
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class EnrichedSpanUtilsTest method testGetBackendOperation_empty.
@Test
public void testGetBackendOperation_empty() {
Event e = mock(Event.class);
String backend_operation = EnrichedSpanUtils.getBackendOperation(e);
assertNull(backend_operation);
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class EnrichedSpanUtilsTest method getRequestSize_httpProtocol.
@Test
public void getRequestSize_httpProtocol() {
Event e = createMockEventWithEnrichedAttribute("PROTOCOL", "HTTP");
when(e.getAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
addAttribute(e, RawSpanConstants.getValue(HTTP_REQUEST_SIZE), "64");
Optional<Integer> requestSize = EnrichedSpanUtils.getRequestSize(e);
assertFalse(requestSize.isEmpty());
assertEquals(64, requestSize.get().intValue());
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class EnrichedSpanUtilsTest method should_getApiDiscoveryState_enrichedAttribute.
@Test
public void should_getApiDiscoveryState_enrichedAttribute() {
Event e = createMockEventWithEnrichedAttribute(API_DISCOVERY_STATE_ATTR, "DISCOVERED");
assertEquals("DISCOVERED", EnrichedSpanUtils.getApiDiscoveryState(e));
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class EnrichedSpanUtilsTest method createMockEventWithEnrichedAttribute.
private Event createMockEventWithEnrichedAttribute(String key, String value) {
Event e = mock(Event.class);
when(e.getAttributes()).thenReturn(null);
when(e.getEnrichedAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(Map.of(key, AttributeValue.newBuilder().setValue(value).build())).build());
return e;
}
Aggregations