Search in sources :

Example 51 with Event

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

the class HttpSemanticConventionUtilsTest method testGetHttpPath.

@Test
public void testGetHttpPath() {
    Event event = createMockEventWithAttribute(RawSpanConstants.getValue(HTTP_REQUEST_PATH), "/path");
    assertEquals(Optional.of("/path"), HttpSemanticConventionUtils.getHttpPath(event));
    event = mock(Event.class);
    assertTrue(HttpSemanticConventionUtils.getHttpPath(event).isEmpty());
    event = createMockEventWithAttribute(RawSpanConstants.getValue(HTTP_REQUEST_PATH), "");
    assertTrue(HttpSemanticConventionUtils.getHttpPath(event).isEmpty());
    event = createMockEventWithAttribute(RawSpanConstants.getValue(HTTP_REQUEST_PATH), "path");
    assertTrue(HttpSemanticConventionUtils.getHttpPath(event).isEmpty());
    event = mock(Event.class);
    when(event.getAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(Map.of(RawSpanConstants.getValue(HTTP_REQUEST_PATH), AttributeValue.newBuilder().setValue("/path1").build(), RawSpanConstants.getValue(HTTP_PATH), AttributeValue.newBuilder().setValue("/path2").build(), OTelHttpSemanticConventions.HTTP_TARGET.getValue(), AttributeValue.newBuilder().setValue("/path3").build())).build());
    assertEquals(Optional.of("/path1"), HttpSemanticConventionUtils.getHttpPath(event));
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 52 with Event

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

the class MessagingSemanticConventionUtilsTest method testIfKafkaOperationIsEmpty.

@Test
public void testIfKafkaOperationIsEmpty() {
    Event e = mock(Event.class);
    assertTrue(MessagingSemanticConventionUtils.getMessagingOperation(e).isEmpty());
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 53 with Event

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

the class MessagingSemanticConventionUtilsTest method testGetRabbitmqDestination.

@Test
public void testGetRabbitmqDestination() {
    Event e = mock(Event.class);
    Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OtelMessagingSemanticConventions.MESSAGING_DESTINATION.getValue(), SemanticConventionTestUtil.buildAttributeValue("queueName"), OtelMessagingSemanticConventions.RABBITMQ_ROUTING_KEY.getValue(), SemanticConventionTestUtil.buildAttributeValue("test-key")));
    when(e.getAttributes()).thenReturn(attributes);
    Optional<String> v = MessagingSemanticConventionUtils.getMessagingDestinationForRabbitmq(e);
    assertEquals("test-key.queueName", v.get());
}
Also used : SemanticConventionTestUtil.buildAttributes(org.hypertrace.semantic.convention.utils.SemanticConventionTestUtil.buildAttributes) Attributes(org.hypertrace.core.datamodel.Attributes) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 54 with Event

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

the class MessagingSemanticConventionUtilsTest method testIfRabbitmqOperationIsEmpty.

@Test
public void testIfRabbitmqOperationIsEmpty() {
    Event e = mock(Event.class);
    assertTrue(MessagingSemanticConventionUtils.getMessagingOperation(e).isEmpty());
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 55 with Event

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

the class MessagingSemanticConventionUtilsTest method testGetRabbitMqRoutingKey.

@Test
public void testGetRabbitMqRoutingKey() {
    Event e = mock(Event.class);
    // otel format
    String routingKey = "otelRoutingKey";
    Attributes attributes = buildAttributes(Map.of(OtelMessagingSemanticConventions.RABBITMQ_ROUTING_KEY.getValue(), buildAttributeValue(routingKey)));
    when(e.getAttributes()).thenReturn(attributes);
    Optional<String> v = MessagingSemanticConventionUtils.getRabbitMqRoutingKey(e);
    assertEquals(routingKey, v.get());
    // other format
    routingKey = "otherRoutingKey";
    attributes = buildAttributes(Map.of(RawSpanConstants.getValue(RabbitMq.RABBIT_MQ_ROUTING_KEY), buildAttributeValue(routingKey)));
    when(e.getAttributes()).thenReturn(attributes);
    v = MessagingSemanticConventionUtils.getRabbitMqRoutingKey(e);
    assertEquals(routingKey, v.get());
    // routing key absent
    attributes = buildAttributes(Map.of("span.kind", buildAttributeValue("client")));
    when(e.getAttributes()).thenReturn(attributes);
    v = MessagingSemanticConventionUtils.getRabbitMqRoutingKey(e);
    assertTrue(v.isEmpty());
}
Also used : SemanticConventionTestUtil.buildAttributes(org.hypertrace.semantic.convention.utils.SemanticConventionTestUtil.buildAttributes) Attributes(org.hypertrace.core.datamodel.Attributes) 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