Search in sources :

Example 96 with Event

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

the class UserAgentSpanEnricherTest method enrichUserAgentFromGrpc.

@Test
public void enrichUserAgentFromGrpc() {
    String userAgent = "grpc-java-okhttp/1.19.0";
    Event e = createMockEvent();
    mockProtocol(e, Protocol.PROTOCOL_GRPC);
    addAttribute(e, RPC_REQUEST_METADATA_USER_AGENT.getValue(), userAgent);
    addAttribute(e, OTEL_SPAN_TAG_RPC_SYSTEM.getValue(), "grpc");
    enricher.enrichEvent(null, e);
    Map<String, AttributeValue> map = e.getEnrichedAttributes().getAttributeMap();
    assertEquals(7, map.size());
    assertEquals("unknown", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_NAME)).getValue());
    assertEquals("", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_BROWSER_VERSION)).getValue());
    assertEquals("", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_DEVICE_CATEGORY)).getValue());
    assertEquals("unknown", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_OS_NAME)).getValue());
    assertEquals("", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_OS_VERSION)).getValue());
    assertEquals("", 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 97 with Event

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

the class BackendEntityEnricherTest method test_EnrichTrace_apiEntryEvent.

@Test
public void test_EnrichTrace_apiEntryEvent() {
    Event e = createApiEntryEvent(EVENT_ID).build();
    StructuredTrace trace = createStructuredTrace(TENANT_ID, e);
    enricher.enrichTrace(trace);
    Assertions.assertEquals(ByteBuffer.wrap(EVENT_ID.getBytes()), e.getEventId());
    Assertions.assertNull(EnrichedSpanUtils.getBackendId(e));
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test) AbstractAttributeEnricherTest(org.hypertrace.traceenricher.enrichment.enrichers.AbstractAttributeEnricherTest)

Example 98 with Event

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

the class BackendEntityEnricherTest method test_EnrichTrace_BackendResolvedForBrokenFacadeEvent.

@Test
public void test_EnrichTrace_BackendResolvedForBrokenFacadeEvent() {
    String eventName = "broken facade event";
    String backendName = "peer";
    String serviceName = "peer";
    String backendId = "peerId";
    Map<String, String> identifyingAttributes = Map.of(BACKEND_PROTOCOL_ATTR_NAME, "UNKNOWN", BACKEND_HOST_ATTR_NAME, backendName, BACKEND_PORT_ATTR_NAME, "-1");
    Map<String, String> attributes = Map.of("FROM_EVENT", eventName, "FROM_EVENT_ID", HexUtils.getHex(ByteBuffer.wrap(EVENT_ID.getBytes())));
    Entity backendEntity = createEntity(EntityType.BACKEND, backendName, identifyingAttributes, attributes, TENANT_ID);
    when(edsClient.upsert(eq(backendEntity))).thenReturn(Entity.newBuilder(backendEntity).setEntityId(backendId).putAllAttributes(createEdsAttributes(identifyingAttributes)).build());
    // both service and peer service are same
    Event e = createApiExitEvent(EVENT_ID, serviceName, backendName).setEventName(eventName).build();
    StructuredTrace trace = createStructuredTrace(TENANT_ID, e);
    enricher.enrichTrace(trace);
    // assert that backend has been created for above event
    Assertions.assertNotNull(EnrichedSpanUtils.getBackendId(e));
    Assertions.assertNotNull(EnrichedSpanUtils.getBackendName(e));
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test) AbstractAttributeEnricherTest(org.hypertrace.traceenricher.enrichment.enrichers.AbstractAttributeEnricherTest)

Example 99 with Event

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

the class BackendEntityEnricherTest method test_EnrichEvent_test_enrichEvent_missingBackendOperationEvent.

@Test
public void test_EnrichEvent_test_enrichEvent_missingBackendOperationEvent() {
    Event e = createApiEntryEvent(EVENT_ID).build();
    StructuredTrace trace = createStructuredTrace(TENANT_ID, e);
    enricher.enrichEvent(trace, e);
    Assertions.assertNull(EnrichedSpanUtils.getBackendOperation(e));
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test) AbstractAttributeEnricherTest(org.hypertrace.traceenricher.enrichment.enrichers.AbstractAttributeEnricherTest)

Example 100 with Event

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

the class BackendEntityEnricherTest method test_EnrichTrace_BackendResolvedForBrokenEvent.

@Test
public void test_EnrichTrace_BackendResolvedForBrokenEvent() {
    String eventName = "broken event";
    String backendName = "peer";
    String backendId = "peerId";
    String serviceName = "client";
    Map<String, String> identifyingAttributes = Map.of(BACKEND_PROTOCOL_ATTR_NAME, "UNKNOWN", BACKEND_HOST_ATTR_NAME, backendName, BACKEND_PORT_ATTR_NAME, "-1");
    Map<String, String> attributes = Map.of("FROM_EVENT", eventName, "FROM_EVENT_ID", HexUtils.getHex(ByteBuffer.wrap(EVENT_ID.getBytes())));
    Entity backendEntity = createEntity(EntityType.BACKEND, backendName, identifyingAttributes, attributes, TENANT_ID);
    when(edsClient.upsert(eq(backendEntity))).thenReturn(Entity.newBuilder(backendEntity).setEntityId(backendId).putAllAttributes(createEdsAttributes(identifyingAttributes)).build());
    // for broken event service and peer service are different
    Event e = createApiExitEvent(EVENT_ID, serviceName, backendName).setEventName(eventName).build();
    StructuredTrace trace = createStructuredTrace(TENANT_ID, e);
    enricher.enrichTrace(trace);
    // assert that backend has been created
    Assertions.assertNotNull(EnrichedSpanUtils.getBackendId(e));
    Assertions.assertNotNull(EnrichedSpanUtils.getBackendName(e));
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test) AbstractAttributeEnricherTest(org.hypertrace.traceenricher.enrichment.enrichers.AbstractAttributeEnricherTest)

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