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));
}
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());
}
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());
}
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());
}
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());
}
Aggregations