Search in sources :

Example 1 with Attributes

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

the class ApiTraceGraphDebug method addEnrichedAttribute.

void addEnrichedAttribute(Event event, String key, AttributeValue value) {
    Attributes enrichedAttributes = event.getEnrichedAttributes();
    if (enrichedAttributes == null) {
        enrichedAttributes = Attributes.newBuilder().build();
        event.setEnrichedAttributes(enrichedAttributes);
    }
    enrichedAttributes.getAttributeMap().put(key, value);
}
Also used : Attributes(org.hypertrace.core.datamodel.Attributes)

Example 2 with Attributes

use of org.hypertrace.core.datamodel.Attributes 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 3 with Attributes

use of org.hypertrace.core.datamodel.Attributes 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 4 with Attributes

use of org.hypertrace.core.datamodel.Attributes 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 5 with Attributes

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

the class RpcSemanticConventionUtilsTest method testIsRpcTypeGrpcForOTelFormat.

@Test
public void testIsRpcTypeGrpcForOTelFormat() {
    Event e = mock(Event.class);
    // otel format
    Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelRpcSemanticConventions.RPC_SYSTEM.getValue(), SemanticConventionTestUtil.buildAttributeValue(OTelRpcSemanticConventions.RPC_SYSTEM_VALUE_GRPC.getValue())));
    when(e.getAttributes()).thenReturn(attributes);
    boolean v = RpcSemanticConventionUtils.isRpcTypeGrpcForOTelFormat(e);
    assertTrue(v);
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelRpcSemanticConventions.RPC_SYSTEM.getValue(), SemanticConventionTestUtil.buildAttributeValue("other")));
    when(e.getAttributes()).thenReturn(attributes);
    v = RpcSemanticConventionUtils.isRpcTypeGrpcForOTelFormat(e);
    assertFalse(v);
}
Also used : Attributes(org.hypertrace.core.datamodel.Attributes) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Aggregations

Attributes (org.hypertrace.core.datamodel.Attributes)45 Event (org.hypertrace.core.datamodel.Event)41 Test (org.junit.jupiter.api.Test)40 SemanticConventionTestUtil.buildAttributes (org.hypertrace.semantic.convention.utils.SemanticConventionTestUtil.buildAttributes)8 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)3 HashMap (java.util.HashMap)2 AvroBuilderCache.fastNewBuilder (org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ProtocolStringList (com.google.protobuf.ProtocolStringList)1 JaegerSpanInternalModel (io.jaegertracing.api_v2.JaegerSpanInternalModel)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Nullable (javax.annotation.Nullable)1 Schema (org.apache.avro.Schema)1