Search in sources :

Example 21 with BackendInfo

use of org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo in project hypertrace-ingester by hypertrace.

the class JdbcBackendProviderTest method testWithOtelFormatUrl.

@Test
public void testWithOtelFormatUrl() {
    Event e = Event.newBuilder().setCustomerId("__default").setEventId(ByteBuffer.wrap("bdf03dfabf5c70f8".getBytes())).setEntityIdList(Arrays.asList("4bfca8f7-4974-36a4-9385-dd76bf5c8824")).setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(Map.of("SPAN_TYPE", AttributeValue.newBuilder().setValue("EXIT").build())).build()).setAttributes(Attributes.newBuilder().setAttributeMap(Map.of(OTelSpanSemanticConventions.NET_PEER_NAME.getValue(), buildAttributeValue("127.0.0.1"), OTelSpanSemanticConventions.NET_PEER_PORT.getValue(), buildAttributeValue("3306"), OTelDbSemanticConventions.DB_CONNECTION_STRING.getValue(), buildAttributeValue("service(localhost)\\db;;"), OTelDbSemanticConventions.DB_SYSTEM.getValue(), buildAttributeValue("mysql"), "span.kind", buildAttributeValue("client"), OTelDbSemanticConventions.DB_STATEMENT.getValue(), buildAttributeValue("SELECT * from example.user"), "k8s.pod_id", buildAttributeValue("55636196-c840-11e9-a417-42010a8a0064"), "docker.container_id", buildAttributeValue("ee85cf2cfc3b24613a3da411fdbd2f3eabbe729a5c86c5262971c8d8c29dad0f"))).build()).setEventName("jdbc.connection.prepare").setStartTimeMillis(1566869077746L).setEndTimeMillis(1566869077750L).setMetrics(Metrics.newBuilder().setMetricMap(Map.of("Duration", MetricValue.newBuilder().setValue(4.0).build())).build()).setEventRefList(Collections.singletonList(EventRef.newBuilder().setTraceId(ByteBuffer.wrap("random_trace_id".getBytes())).setEventId(ByteBuffer.wrap("random_event_id".getBytes())).setRefType(EventRefType.CHILD_OF).build())).build();
    BackendInfo backendInfo = backendEntityEnricher.resolve(e, structuredTrace, structuredTraceGraph).get();
    final Entity backendEntity = backendInfo.getEntity();
    assertEquals("127.0.0.1:3306", backendEntity.getEntityName());
    assertEquals(BackendType.JDBC.name(), backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PROTOCOL)).getValue().getString());
    assertEquals("127.0.0.1", backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_HOST)).getValue().getString());
    assertEquals("3306", backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PORT)).getValue().getString());
    assertEquals("mysql", backendEntity.getAttributesMap().get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
    assertEquals("jdbc.connection.prepare", backendEntity.getAttributesMap().get(Constants.getEnrichedSpanConstant(Backend.BACKEND_FROM_EVENT)).getValue().getString());
    assertEquals("62646630336466616266356337306638", backendEntity.getAttributesMap().get(Constants.getEnrichedSpanConstant(Backend.BACKEND_FROM_EVENT_ID)).getValue().getString());
    Map<String, AttributeValue> attributes = backendInfo.getAttributes();
    assertEquals(Map.of("BACKEND_OPERATION", AttributeValueCreator.create("SELECT")), attributes);
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) TestUtil.buildAttributeValue(org.hypertrace.traceenricher.TestUtil.buildAttributeValue) AttributeValue(org.hypertrace.core.datamodel.AttributeValue) Event(org.hypertrace.core.datamodel.Event) BackendInfo(org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo) Test(org.junit.jupiter.api.Test)

Example 22 with BackendInfo

use of org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo in project hypertrace-ingester by hypertrace.

the class JdbcBackendProviderTest method testWebgoatUrl.

@Test
public void testWebgoatUrl() {
    Event e = Event.newBuilder().setCustomerId("__default").setEventId(ByteBuffer.wrap("bdf03dfabf5c70f8".getBytes())).setEntityIdList(Arrays.asList("4bfca8f7-4974-36a4-9385-dd76bf5c8824")).setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(Map.of("SPAN_TYPE", AttributeValue.newBuilder().setValue("EXIT").build())).build()).setAttributes(Attributes.newBuilder().setAttributeMap(Map.of("sql.url", AttributeValue.newBuilder().setValue("jdbc:hsqldb:hsql://dbhost:9001/webgoat").build(), "span.kind", AttributeValue.newBuilder().setValue("client").build(), "sql.query", AttributeValue.newBuilder().setValue("insert into audit_message (message, id) values (?, ?)").build(), "db.operation", AttributeValue.newBuilder().setValue("select").build(), "k8s.pod_id", AttributeValue.newBuilder().setValue("55636196-c840-11e9-a417-42010a8a0064").build(), "docker.container_id", AttributeValue.newBuilder().setValue("ee85cf2cfc3b24613a3da411fdbd2f3eabbe729a5c86c5262971c8d8c29dad0f").build(), "FLAGS", AttributeValue.newBuilder().setValue("0").build())).build()).setEventName("jdbc.connection.prepare").setStartTimeMillis(1566869077746L).setEndTimeMillis(1566869077750L).setMetrics(Metrics.newBuilder().setMetricMap(Map.of("Duration", MetricValue.newBuilder().setValue(4.0).build())).build()).setEventRefList(Arrays.asList(EventRef.newBuilder().setTraceId(ByteBuffer.wrap("random_trace_id".getBytes())).setEventId(ByteBuffer.wrap("random_event_id".getBytes())).setRefType(EventRefType.CHILD_OF).build())).build();
    BackendInfo backendInfo = backendEntityEnricher.resolve(e, structuredTrace, structuredTraceGraph).get();
    final Entity backendEntity = backendInfo.getEntity();
    assertEquals("dbhost:9001", backendEntity.getEntityName());
    assertEquals(3, backendEntity.getIdentifyingAttributesCount());
    Assertions.assertEquals(BackendType.JDBC.name(), backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PROTOCOL)).getValue().getString());
    assertEquals("dbhost", backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_HOST)).getValue().getString());
    assertEquals("9001", backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PORT)).getValue().getString());
    assertEquals("hsqldb", backendEntity.getAttributesMap().get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
    assertEquals("jdbc.connection.prepare", backendEntity.getAttributesMap().get(Constants.getEnrichedSpanConstant(Backend.BACKEND_FROM_EVENT)).getValue().getString());
    assertEquals("62646630336466616266356337306638", backendEntity.getAttributesMap().get(Constants.getEnrichedSpanConstant(Backend.BACKEND_FROM_EVENT_ID)).getValue().getString());
    assertEquals("/webgoat", backendEntity.getAttributesMap().get(EntityConstants.getValue(BackendAttribute.BACKEND_ATTRIBUTE_PATH)).getValue().getString());
    Map<String, AttributeValue> attributes = backendInfo.getAttributes();
    assertEquals(Map.of("BACKEND_OPERATION", AttributeValueCreator.create("select")), attributes);
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) TestUtil.buildAttributeValue(org.hypertrace.traceenricher.TestUtil.buildAttributeValue) AttributeValue(org.hypertrace.core.datamodel.AttributeValue) Event(org.hypertrace.core.datamodel.Event) BackendInfo(org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo) Test(org.junit.jupiter.api.Test)

Example 23 with BackendInfo

use of org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo in project hypertrace-ingester by hypertrace.

the class JdbcBackendProviderTest method testBackendDestinationWithoutTableName.

@Test
public void testBackendDestinationWithoutTableName() {
    Event e = Event.newBuilder().setCustomerId("__default").setEventId(ByteBuffer.wrap("bdf03dfabf5c70f8".getBytes())).setEntityIdList(Arrays.asList("4bfca8f7-4974-36a4-9385-dd76bf5c8824")).setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(Map.of("SPAN_TYPE", AttributeValue.newBuilder().setValue("EXIT").build())).build()).setAttributes(Attributes.newBuilder().setAttributeMap(Map.of("sql.url", AttributeValue.newBuilder().setValue("jdbc:hsqldb:hsql://dbhost:9001/webgoat").build(), "span.kind", AttributeValue.newBuilder().setValue("client").build(), "db.name", AttributeValue.newBuilder().setValue("customer").build())).build()).setEventName("jdbc.connection.prepare").setEventRefList(Arrays.asList(EventRef.newBuilder().setTraceId(ByteBuffer.wrap("random_trace_id".getBytes())).setEventId(ByteBuffer.wrap("random_event_id".getBytes())).setRefType(EventRefType.CHILD_OF).build())).build();
    BackendInfo backendInfo = backendEntityEnricher.resolve(e, structuredTrace, structuredTraceGraph).get();
    Map<String, AttributeValue> attributes = backendInfo.getAttributes();
    assertEquals(Map.of("BACKEND_DESTINATION", AttributeValueCreator.create("customer")), attributes);
}
Also used : TestUtil.buildAttributeValue(org.hypertrace.traceenricher.TestUtil.buildAttributeValue) AttributeValue(org.hypertrace.core.datamodel.AttributeValue) Event(org.hypertrace.core.datamodel.Event) BackendInfo(org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo) Test(org.junit.jupiter.api.Test)

Example 24 with BackendInfo

use of org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo in project hypertrace-ingester by hypertrace.

the class KafkaBackendProviderTest method TestOtelBackendDestinationResolution.

@Test
public void TestOtelBackendDestinationResolution() {
    String broker = "kafka-test.hypertrace.com:9092";
    BackendInfo backendInfo = backendEntityEnricher.resolve(getOtelKafkaBackendEventForDestination(broker), structuredTrace, structuredTraceGraph).get();
    Entity entity = backendInfo.getEntity();
    Assertions.assertEquals(broker, entity.getEntityName());
    Map<String, AttributeValue> attributes = backendInfo.getAttributes();
    assertEquals(Map.of("BACKEND_DESTINATION", AttributeValueCreator.create("myGroup.QueueName")), attributes);
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) AttributeValue(org.hypertrace.core.datamodel.AttributeValue) BackendInfo(org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo) Test(org.junit.jupiter.api.Test)

Example 25 with BackendInfo

use of org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo in project hypertrace-ingester by hypertrace.

the class MongoBackendProviderTest method checkBackendEntityGeneratedFromInstrumentedMongoEventOtelFormat.

@Test
public void checkBackendEntityGeneratedFromInstrumentedMongoEventOtelFormat() {
    Event e = Event.newBuilder().setCustomerId("__default").setEventId(ByteBuffer.wrap("bdf03dfabf5c70f8".getBytes())).setEntityIdList(Arrays.asList("4bfca8f7-4974-36a4-9385-dd76bf5c8824")).setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(Map.of("SPAN_TYPE", AttributeValue.newBuilder().setValue("EXIT").build())).build()).setAttributes(Attributes.newBuilder().setAttributeMap(Map.of(OTelDbSemanticConventions.DB_SYSTEM.getValue(), buildAttributeValue(OTelDbSemanticConventions.MONGODB_DB_SYSTEM_VALUE.getValue()), OTelSpanSemanticConventions.NET_PEER_NAME.getValue(), buildAttributeValue("mongodb0"), OTelDbSemanticConventions.MONGODB_COLLECTION.getValue(), buildAttributeValue("sampleshop.userReview"), "span.kind", buildAttributeValue("client"), OTelDbSemanticConventions.DB_OPERATION.getValue(), buildAttributeValue("FindOperation"), OTelDbSemanticConventions.DB_NAME.getValue(), buildAttributeValue("customers"), OTelSpanSemanticConventions.NET_PEER_PORT.getValue(), buildAttributeValue("27017"))).build()).setEventName("mongo.async.exit").setStartTimeMillis(1566869077746L).setEndTimeMillis(1566869077750L).setMetrics(Metrics.newBuilder().setMetricMap(Map.of("Duration", MetricValue.newBuilder().setValue(4.0).build())).build()).setEventRefList(Arrays.asList(EventRef.newBuilder().setTraceId(ByteBuffer.wrap("random_trace_id".getBytes())).setEventId(ByteBuffer.wrap("random_event_id".getBytes())).setRefType(EventRefType.CHILD_OF).build())).build();
    final BackendInfo backendInfo = backendEntityEnricher.resolve(e, structuredTrace, structuredTraceGraph).get();
    final Entity backendEntity = backendInfo.getEntity();
    assertEquals("mongodb0:27017", backendEntity.getEntityName());
    assertEquals(3, backendEntity.getIdentifyingAttributesCount());
    assertEquals(backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PROTOCOL)).getValue().getString(), "MONGO");
    assertEquals("mongodb0", backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_HOST)).getValue().getString());
    assertEquals(backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PORT)).getValue().getString(), "27017");
    assertEquals(backendEntity.getAttributesMap().get(OTelDbSemanticConventions.MONGODB_COLLECTION.getValue()).getValue().getString(), "sampleshop.userReview");
    assertEquals(backendEntity.getAttributesMap().get(OTelDbSemanticConventions.DB_OPERATION.getValue()).getValue().getString(), "FindOperation");
    assertEquals(backendEntity.getAttributesMap().get(Constants.getEnrichedSpanConstant(Backend.BACKEND_FROM_EVENT)).getValue().getString(), "mongo.async.exit");
    assertEquals(backendEntity.getAttributesMap().get(Constants.getEnrichedSpanConstant(Backend.BACKEND_FROM_EVENT_ID)).getValue().getString(), "62646630336466616266356337306638");
    Map<String, AttributeValue> attributes = backendInfo.getAttributes();
    assertEquals(Map.of("BACKEND_DESTINATION", AttributeValueCreator.create("customers.sampleshop.userReview"), "BACKEND_OPERATION", AttributeValueCreator.create("FindOperation")), attributes);
}
Also used : Entity(org.hypertrace.entity.data.service.v1.Entity) TestUtil.buildAttributeValue(org.hypertrace.traceenricher.TestUtil.buildAttributeValue) AttributeValue(org.hypertrace.core.datamodel.AttributeValue) Event(org.hypertrace.core.datamodel.Event) BackendInfo(org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo) Test(org.junit.jupiter.api.Test)

Aggregations

BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)26 Test (org.junit.jupiter.api.Test)25 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)24 Entity (org.hypertrace.entity.data.service.v1.Entity)20 Event (org.hypertrace.core.datamodel.Event)12 TestUtil.buildAttributeValue (org.hypertrace.traceenricher.TestUtil.buildAttributeValue)10 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 AttributeValue (org.hypertrace.entity.data.service.v1.AttributeValue)1 Builder (org.hypertrace.entity.data.service.v1.Entity.Builder)1 BackendType (org.hypertrace.traceenricher.enrichment.enrichers.BackendType)1 BackendProvider (org.hypertrace.traceenricher.enrichment.enrichers.backend.provider.BackendProvider)1