use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class AbstractTraceEnricher method getEarliestEvent.
@Nullable
protected Event getEarliestEvent(StructuredTrace trace) {
long earliestEventTime = Long.MAX_VALUE;
Event earliestEvent = null;
List<Event> events = trace.getEventList();
for (Event event : events) {
long eventStartTime = event.getStartTimeMillis();
if (eventStartTime < earliestEventTime) {
earliestEventTime = eventStartTime;
earliestEvent = event;
}
}
return earliestEvent;
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class MessagingSemanticConventionUtilsTest method testGetRabbitmqOperation.
@Test
public void testGetRabbitmqOperation() {
Event e = mock(Event.class);
Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OtelMessagingSemanticConventions.MESSAGING_OPERATION.getValue(), SemanticConventionTestUtil.buildAttributeValue("publish")));
when(e.getAttributes()).thenReturn(attributes);
Optional<String> v = MessagingSemanticConventionUtils.getMessagingOperation(e);
assertEquals("publish", v.get());
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class MessagingSemanticConventionUtilsTest method testIsRabbitMqBackend.
@Test
public void testIsRabbitMqBackend() {
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);
boolean v = MessagingSemanticConventionUtils.isRabbitMqBackend(e);
assertTrue(v);
// other format
routingKey = "otherRoutingKey";
attributes = buildAttributes(Map.of(RawSpanConstants.getValue(RabbitMq.RABBIT_MQ_ROUTING_KEY), buildAttributeValue(routingKey)));
when(e.getAttributes()).thenReturn(attributes);
v = MessagingSemanticConventionUtils.isRabbitMqBackend(e);
assertTrue(v);
// not present
attributes = buildAttributes(Map.of());
when(e.getAttributes()).thenReturn(attributes);
v = MessagingSemanticConventionUtils.isRabbitMqBackend(e);
Assertions.assertFalse(v);
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class MessagingSemanticConventionUtilsTest method testGetKafkaDestination.
@Test
public void testGetKafkaDestination() {
Event e = mock(Event.class);
Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OtelMessagingSemanticConventions.MESSAGING_DESTINATION.getValue(), SemanticConventionTestUtil.buildAttributeValue("queueName"), OtelMessagingSemanticConventions.MESSAGING_KAFKA_CONSUMER_GROUP.getValue(), SemanticConventionTestUtil.buildAttributeValue("test")));
when(e.getAttributes()).thenReturn(attributes);
Optional<String> v = MessagingSemanticConventionUtils.getMessagingDestinationForKafka(e);
assertEquals("test.queueName", v.get());
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class RpcSemanticConventionUtilsTest method testGetGrpcAuthrity.
@Test
public void testGetGrpcAuthrity() {
Event event = mock(Event.class);
when(event.getAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(Map.of(RPC_REQUEST_METADATA_AUTHORITY.getValue(), AttributeValue.newBuilder().setValue("abc").build(), OTEL_SPAN_TAG_RPC_SYSTEM.getValue(), AttributeValue.newBuilder().setValue("grpc").build())).build());
assertEquals(Optional.of("abc"), RpcSemanticConventionUtils.getGrpcAuthority(event));
event = mock(Event.class);
assertTrue(RpcSemanticConventionUtils.getGrpcAuthority(event).isEmpty());
event = mock(Event.class);
when(event.getAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(Map.of(RPC_REQUEST_METADATA_AUTHORITY.getValue(), AttributeValue.newBuilder().setValue("abc").build(), OTEL_SPAN_TAG_RPC_SYSTEM.getValue(), AttributeValue.newBuilder().setValue("").build())).build());
assertTrue(RpcSemanticConventionUtils.getGrpcAuthority(event).isEmpty());
}
Aggregations