Search in sources :

Example 71 with Event

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

the class DbSemanticConventionUtilsTest method testGetSqlDestination.

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

Example 72 with Event

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

the class DbSemanticConventionUtilsTest method isMongoBackend.

@Test
public void isMongoBackend() {
    Event e = mock(Event.class);
    // otel format, dbsystem is not mongo
    Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelDbSemanticConventions.DB_SYSTEM.getValue(), SemanticConventionTestUtil.buildAttributeValue(OTelDbSemanticConventions.MYSQL_DB_SYSTEM_VALUE.getValue()), OTelDbSemanticConventions.DB_CONNECTION_STRING.getValue(), SemanticConventionTestUtil.buildAttributeValue("mongo:27017")));
    when(e.getAttributes()).thenReturn(attributes);
    boolean v = DbSemanticConventionUtils.isMongoBackend(e);
    assertFalse(v);
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of(RawSpanConstants.getValue(Mongo.MONGO_ADDRESS), SemanticConventionTestUtil.buildAttributeValue("mongo:27017")));
    when(e.getAttributes()).thenReturn(attributes);
    v = DbSemanticConventionUtils.isMongoBackend(e);
    assertTrue(v);
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of(RawSpanConstants.getValue(Mongo.MONGO_URL), SemanticConventionTestUtil.buildAttributeValue("mongo:27017")));
    when(e.getAttributes()).thenReturn(attributes);
    v = DbSemanticConventionUtils.isMongoBackend(e);
    assertTrue(v);
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of("span.kind", SemanticConventionTestUtil.buildAttributeValue("client")));
    when(e.getAttributes()).thenReturn(attributes);
    v = DbSemanticConventionUtils.isMongoBackend(e);
    assertFalse(v);
}
Also used : Attributes(org.hypertrace.core.datamodel.Attributes) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 73 with Event

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

the class DbSemanticConventionUtilsTest method testIfMongoOperationIsEmpty.

@Test
public void testIfMongoOperationIsEmpty() {
    Event e = mock(Event.class);
    assertTrue(DbSemanticConventionUtils.getDbOperationForMongo(e).isEmpty());
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 74 with Event

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

the class DbSemanticConventionUtilsTest method testGetBackendURIForOtelFormat.

@Test
public void testGetBackendURIForOtelFormat() {
    Event e = mock(Event.class);
    // only ip is present
    Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelSpanSemanticConventions.NET_PEER_IP.getValue(), SemanticConventionTestUtil.buildAttributeValue("127.0.0.1")));
    when(e.getAttributes()).thenReturn(attributes);
    Optional<String> v = DbSemanticConventionUtils.getBackendURIForOtelFormat(e);
    assertEquals("127.0.0.1", v.get());
    // ip & host present
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelSpanSemanticConventions.NET_PEER_IP.getValue(), SemanticConventionTestUtil.buildAttributeValue("127.0.0.1"), OTelSpanSemanticConventions.NET_PEER_NAME.getValue(), SemanticConventionTestUtil.buildAttributeValue("mysql.example.com")));
    when(e.getAttributes()).thenReturn(attributes);
    v = DbSemanticConventionUtils.getBackendURIForOtelFormat(e);
    assertEquals("mysql.example.com", v.get());
    // host & port present
    attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelSpanSemanticConventions.NET_PEER_IP.getValue(), SemanticConventionTestUtil.buildAttributeValue("127.0.0.1"), OTelSpanSemanticConventions.NET_PEER_NAME.getValue(), SemanticConventionTestUtil.buildAttributeValue("mysql.example.com"), OTelSpanSemanticConventions.NET_PEER_PORT.getValue(), SemanticConventionTestUtil.buildAttributeValue("3306")));
    when(e.getAttributes()).thenReturn(attributes);
    v = DbSemanticConventionUtils.getBackendURIForOtelFormat(e);
    assertEquals("mysql.example.com:3306", v.get());
}
Also used : Attributes(org.hypertrace.core.datamodel.Attributes) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 75 with Event

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

the class DbSemanticConventionUtilsTest method testGetRedisOperation.

@Test
public void testGetRedisOperation() {
    Event e = mock(Event.class);
    Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(RawSpanConstants.getValue(Redis.REDIS_COMMAND), SemanticConventionTestUtil.buildAttributeValue("GET")));
    when(e.getAttributes()).thenReturn(attributes);
    Optional<String> v = DbSemanticConventionUtils.getDbOperationForRedis(e);
    assertEquals("GET", v.get());
}
Also used : Attributes(org.hypertrace.core.datamodel.Attributes) 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