Search in sources :

Example 26 with Attributes

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

the class ErrorSemanticConventionUtilsTest method testCheckForException.

@Test
public void testCheckForException() {
    Event e = mock(Event.class);
    Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelErrorSemanticConventions.EXCEPTION_TYPE.getValue(), SemanticConventionTestUtil.buildAttributeValue("xyzerror")));
    when(e.getAttributes()).thenReturn(attributes);
    boolean v = ErrorSemanticConventionUtils.checkForException(e);
    assertTrue(v);
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelErrorSemanticConventions.EXCEPTION_MESSAGE.getValue(), SemanticConventionTestUtil.buildAttributeValue("xyzerror")));
    when(e.getAttributes()).thenReturn(attributes);
    v = ErrorSemanticConventionUtils.checkForException(e);
    assertTrue(v);
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of("other_error", SemanticConventionTestUtil.buildAttributeValue("xyzerror")));
    when(e.getAttributes()).thenReturn(attributes);
    v = ErrorSemanticConventionUtils.checkForException(e);
    assertFalse(v);
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of(RawSpanConstants.getValue(Error.ERROR_STACK_TRACE), SemanticConventionTestUtil.buildAttributeValue("org.abc.etc...")));
    when(e.getAttributes()).thenReturn(attributes);
    v = ErrorSemanticConventionUtils.checkForException(e);
    assertTrue(v);
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelErrorSemanticConventions.EXCEPTION_STACKTRACE.getValue(), SemanticConventionTestUtil.buildAttributeValue("org.abc.etc...")));
    when(e.getAttributes()).thenReturn(attributes);
    v = ErrorSemanticConventionUtils.checkForException(e);
    assertTrue(v);
}
Also used : Attributes(org.hypertrace.core.datamodel.Attributes) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 27 with Attributes

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

the class MessagingSemanticConventionUtilsTest method testGetSqsOperation.

@Test
public void testGetSqsOperation() {
    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 28 with Attributes

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

the class MessagingSemanticConventionUtilsTest method testGetSqsDestination.

@Test
public void testGetSqsDestination() {
    Event e = mock(Event.class);
    Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OtelMessagingSemanticConventions.MESSAGING_DESTINATION.getValue(), SemanticConventionTestUtil.buildAttributeValue("queueName")));
    when(e.getAttributes()).thenReturn(attributes);
    Optional<String> v = MessagingSemanticConventionUtils.getMessagingDestination(e);
    assertEquals("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 29 with Attributes

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

the class DbSemanticConventionUtilsTest method testGetMongoDestination.

@Test
public void testGetMongoDestination() {
    Event e = mock(Event.class);
    Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelDbSemanticConventions.MONGODB_COLLECTION.getValue(), SemanticConventionTestUtil.buildAttributeValue("testCollection"), OTelDbSemanticConventions.DB_NAME.getValue(), SemanticConventionTestUtil.buildAttributeValue("customer")));
    when(e.getAttributes()).thenReturn(attributes);
    Optional<String> v = DbSemanticConventionUtils.getDestinationForMongo(e);
    assertEquals("customer.testCollection", v.get());
}
Also used : Attributes(org.hypertrace.core.datamodel.Attributes) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 30 with Attributes

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

the class DbSemanticConventionUtilsTest method testGetCassandraOperation.

@Test
public void testGetCassandraOperation() {
    Event e = mock(Event.class);
    Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelDbSemanticConventions.DB_OPERATION.getValue(), SemanticConventionTestUtil.buildAttributeValue("select")));
    when(e.getAttributes()).thenReturn(attributes);
    Optional<String> v = DbSemanticConventionUtils.getDbOperation(e);
    assertEquals("select", v.get());
}
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