Search in sources :

Example 11 with Event

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());
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 12 with Event

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);
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 13 with Event

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());
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 14 with Event

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));
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 15 with Event

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;
}
Also used : Event(org.hypertrace.core.datamodel.Event)

Aggregations

Event (org.hypertrace.core.datamodel.Event)304 Test (org.junit.jupiter.api.Test)257 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)54 StructuredTrace (org.hypertrace.core.datamodel.StructuredTrace)54 Attributes (org.hypertrace.core.datamodel.Attributes)41 Entity (org.hypertrace.entity.data.service.v1.Entity)27 HashMap (java.util.HashMap)25 AbstractAttributeEnricherTest (org.hypertrace.traceenricher.enrichment.enrichers.AbstractAttributeEnricherTest)17 ByteBuffer (java.nio.ByteBuffer)13 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)13 StructuredTraceGraph (org.hypertrace.core.datamodel.shared.StructuredTraceGraph)12 TestUtil.buildAttributeValue (org.hypertrace.traceenricher.TestUtil.buildAttributeValue)11 AttributeMetadata (org.hypertrace.core.attribute.service.v1.AttributeMetadata)10 SemanticConventionTestUtil.buildAttributes (org.hypertrace.semantic.convention.utils.SemanticConventionTestUtil.buildAttributes)8 Edge (org.hypertrace.core.datamodel.Edge)7 Entity (org.hypertrace.core.datamodel.Entity)7 HashSet (java.util.HashSet)6 List (java.util.List)6 Map (java.util.Map)6 ArrayList (java.util.ArrayList)5