Search in sources :

Example 91 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class TraceStatsEnricherTest method headSpanIndexInTraceNotAddedToTraceAttributeIfNoApiNodesInTrace.

@Test
void headSpanIndexInTraceNotAddedToTraceAttributeIfNoApiNodesInTrace() {
    // 0
    Event yEntryEvent = createUnspecifiedTypeEventWithName("yEvent");
    // 1
    Event zEntryEvent = createUnspecifiedTypeEventWithName("zEvent");
    StructuredTrace trace = createTraceWithEventsAndEdges(new Event[] { yEntryEvent, zEntryEvent }, new HashMap<>() {

        {
            put(0, new int[] { 1 });
        }
    });
    TraceStatsEnricher traceStatsEnricher = new TraceStatsEnricher();
    traceStatsEnricher.enrichTrace(trace);
    assertNull(trace.getAttributes().getAttributeMap().get(HEAD_EVENT_ID));
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 92 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class TraceStatsEnricherTest method totalNumberOfUniqueApiNodeAttributeEqualsToOneIfAtLeastOneNodeExist.

@Test
void totalNumberOfUniqueApiNodeAttributeEqualsToOneIfAtLeastOneNodeExist() {
    // 0
    Event yEntryEvent = createUnspecifiedTypeEventWithName("yEvent");
    // 1
    Event zEntryEvent = createUnspecifiedTypeEventWithName("zEvent");
    // 2
    Event aEntryHeadSpanEvent = createEntryEventWithName("aEvent");
    addApiIdAttr(aEntryHeadSpanEvent, "aApiId");
    Event[] allEvents = new Event[] { yEntryEvent, zEntryEvent, aEntryHeadSpanEvent };
    HashMap<Integer, int[]> eventEdges = new HashMap<>() {

        {
            put(0, new int[] { 1 });
            put(1, new int[] { 2 });
        }
    };
    StructuredTrace trace = createTraceWithEventsAndEdges(allEvents, eventEdges);
    TraceStatsEnricher traceStatsEnricher = new TraceStatsEnricher();
    traceStatsEnricher.enrichTrace(trace);
    String actualTotalNumberOfCalls = trace.getAttributes().getAttributeMap().get(UNIQUE_API_NODES_COUNT).getValue();
    assertEquals("1", actualTotalNumberOfCalls);
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) HashMap(java.util.HashMap) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 93 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class TraceStatsEnricherTest method headSpanIdIsAddedToTraceAttribute.

@Test
void headSpanIdIsAddedToTraceAttribute() {
    // 0
    Event aEntryHeadSpanEvent = createEntryEventWithName("aEvent");
    // 1
    Event aExitEvent = createExitEventName("aExitEvent");
    // 2
    Event bEntryEvent = createEntryEventWithName("bEvent");
    StructuredTrace trace = createTraceWithEventsAndEdges(new Event[] { aEntryHeadSpanEvent, aExitEvent, bEntryEvent }, new HashMap<>() {

        {
            put(0, new int[] { 1 });
            put(1, new int[] { 2 });
        }
    });
    TraceStatsEnricher traceStatsEnricher = new TraceStatsEnricher();
    traceStatsEnricher.enrichTrace(trace);
    ByteBuffer actualHeadSpanId = aEntryHeadSpanEvent.getEventId();
    assertEquals(actualHeadSpanId, trace.getAttributes().getAttributeMap().get(HEAD_EVENT_ID).getBinaryValue());
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Event(org.hypertrace.core.datamodel.Event) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.jupiter.api.Test)

Example 94 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class UserAgentSpanEnricherTest method enrichFromUserAgent.

@Test
public void enrichFromUserAgent() {
    String userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36";
    Event e = createMockEvent();
    when(e.getHttp()).thenReturn(Http.newBuilder().setRequest(Request.newBuilder().setHeaders(RequestHeaders.newBuilder().setUserAgent(userAgent).build()).setUserAgent(userAgent).build()).build());
    mockProtocol(e, Protocol.PROTOCOL_HTTP);
    addAttribute(e, RawSpanConstants.getValue(HTTP_USER_DOT_AGENT), userAgent);
    addAttribute(e, RawSpanConstants.getValue(HTTP_USER_AGENT_REQUEST_HEADER), userAgent);
    enricher.enrichEvent(null, e);
    Map<String, AttributeValue> map = e.getEnrichedAttributes().getAttributeMap();
    assertEquals(7, map.size());
    assertEquals("Chrome", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_NAME)).getValue());
    assertEquals("Browser", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_TYPE)).getValue());
    assertEquals("Personal computer", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_DEVICE_CATEGORY)).getValue());
    assertEquals("OS X", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_OS_NAME)).getValue());
    assertEquals("10.14.3", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_OS_VERSION)).getValue());
    assertEquals("73.0.3683.103", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_BROWSER_VERSION)).getValue());
}
Also used : AttributeValue(org.hypertrace.core.datamodel.AttributeValue) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 95 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class UserAgentSpanEnricherTest method enrichFromLongUserAgentString.

@Test
public void enrichFromLongUserAgentString() {
    final String userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT" + " 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" + " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows" + " NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" + " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT" + " 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0" + " (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" + " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT" + " 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 " + "(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows" + " NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" + " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0" + " (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" + " Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0" + " (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0" + " (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0" + " (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0" + " (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0" + " (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0" + " (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82" + " Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)" + " Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" + " (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36 Mozilla/5.0 (Windows NT 10.0; Win64; x64)" + " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36";
    Event e = createMockEvent();
    when(e.getHttp()).thenReturn(Http.newBuilder().setRequest(Request.newBuilder().setHeaders(RequestHeaders.newBuilder().setUserAgent(userAgent).build()).setUserAgent(userAgent).build()).build());
    mockProtocol(e, Protocol.PROTOCOL_HTTP);
    addAttribute(e, RawSpanConstants.getValue(HTTP_USER_DOT_AGENT), userAgent);
    addAttribute(e, RawSpanConstants.getValue(HTTP_USER_AGENT_REQUEST_HEADER), userAgent);
    enricher.enrichEvent(null, e);
    Map<String, AttributeValue> map = e.getEnrichedAttributes().getAttributeMap();
    assertEquals(7, map.size());
    assertEquals("Chrome", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_NAME)).getValue());
    assertEquals("Browser", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_TYPE)).getValue());
    assertEquals("Personal computer", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_DEVICE_CATEGORY)).getValue());
    assertEquals("Windows", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_OS_NAME)).getValue());
    assertEquals("10.0", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_OS_VERSION)).getValue());
    assertEquals("93.0.4577.82", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_BROWSER_VERSION)).getValue());
}
Also used : AttributeValue(org.hypertrace.core.datamodel.AttributeValue) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

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