Search in sources :

Example 21 with Event

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;
}
Also used : Event(org.hypertrace.core.datamodel.Event) Nullable(javax.annotation.Nullable)

Example 22 with Event

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());
}
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 23 with Event

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);
}
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 24 with Event

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());
}
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 25 with Event

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());
}
Also used : 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