Skip to content

Commit 8a8e32f

Browse files
author
Rishabh
authored
Update identifying attribute for jdbc backend (#88)
1 parent fb3c315 commit 8a8e32f

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/resolver/backend/JdbcBackendResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public Optional<Entity> resolveEntity(Event event, StructuredTraceGraph structur
7777
EntityConstants.getValue(BackendAttribute.BACKEND_ATTRIBUTE_PATH),
7878
createAttributeValue(path));
7979
}
80-
entityBuilder.putIdentifyingAttributes(RawSpanConstants.getValue(Sql.SQL_DB_TYPE),
80+
entityBuilder.putAttributes(RawSpanConstants.getValue(Sql.SQL_DB_TYPE),
8181
createAttributeValue(dbType));
8282
return Optional.of(entityBuilder.build());
8383
}

hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/test/java/org/hypertrace/traceenricher/enrichment/enrichers/resolver/backend/BackendEntityResolverTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ public void checkBackendEntityGeneratedFromJdbcEvent() {
714714
.setRefType(EventRefType.CHILD_OF).build())).build();
715715
final Entity backendEntity = backendEntityResolver.resolveEntity(e, structuredTraceGraph).get();
716716
assertEquals("mysql:3306", backendEntity.getEntityName());
717-
assertEquals(4, backendEntity.getIdentifyingAttributesCount());
717+
assertEquals(3, backendEntity.getIdentifyingAttributesCount());
718718
Assertions.assertEquals(BackendType.JDBC.name(),
719719
backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PROTOCOL))
720720
.getValue().getString());
@@ -725,7 +725,7 @@ public void checkBackendEntityGeneratedFromJdbcEvent() {
725725
backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PORT)).getValue()
726726
.getString());
727727
assertEquals("mysql",
728-
backendEntity.getIdentifyingAttributesMap().get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
728+
backendEntity.getAttributesMap().get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
729729
assertEquals("jdbc.connection.prepare",
730730
backendEntity.getAttributesMap().get(Constants.getEnrichedSpanConstant(Backend.BACKEND_FROM_EVENT)).getValue().getString());
731731
assertEquals("62646630336466616266356337306638",
@@ -762,7 +762,7 @@ public void testGetBackendEntity() {
762762
assertEquals("mysql", idAttrMap.get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_HOST)).getValue().getString());
763763
assertEquals("3306", idAttrMap.get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PORT)).getValue().getString());
764764
assertEquals("JDBC", idAttrMap.get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PROTOCOL)).getValue().getString());
765-
assertEquals("mysql", idAttrMap.get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
765+
assertEquals("mysql", backendEntity.getAttributesMap().get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
766766
}
767767

768768
@Test

hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/test/java/org/hypertrace/traceenricher/enrichment/enrichers/resolver/backend/JdbcBackendResolverTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void testWebgoatUrl() {
6969
.setRefType(EventRefType.CHILD_OF).build())).build();
7070
final Entity backendEntity = jdbcBackendResolver.resolveEntity(e, structuredTraceGraph).get();
7171
assertEquals("dbhost:9001", backendEntity.getEntityName());
72-
assertEquals(4, backendEntity.getIdentifyingAttributesCount());
72+
assertEquals(3, backendEntity.getIdentifyingAttributesCount());
7373
Assertions.assertEquals(BackendType.JDBC.name(),
7474
backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(
7575
BackendAttribute.BACKEND_ATTRIBUTE_PROTOCOL))
@@ -81,7 +81,7 @@ public void testWebgoatUrl() {
8181
backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PORT)).getValue()
8282
.getString());
8383
assertEquals("hsqldb",
84-
backendEntity.getIdentifyingAttributesMap().get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
84+
backendEntity.getAttributesMap().get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
8585
assertEquals("jdbc.connection.prepare",
8686
backendEntity.getAttributesMap().get(Constants.getEnrichedSpanConstant(Backend.BACKEND_FROM_EVENT)).getValue().getString());
8787
assertEquals("62646630336466616266356337306638",
@@ -133,7 +133,7 @@ public void testWithOtelFormatUrl() {
133133
backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_PORT)).getValue()
134134
.getString());
135135
assertEquals("mysql",
136-
backendEntity.getIdentifyingAttributesMap().get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
136+
backendEntity.getAttributesMap().get(Constants.getRawSpanConstant(Sql.SQL_DB_TYPE)).getValue().getString());
137137
assertEquals("jdbc.connection.prepare",
138138
backendEntity.getAttributesMap().get(Constants.getEnrichedSpanConstant(Backend.BACKEND_FROM_EVENT)).getValue().getString());
139139
assertEquals("62646630336466616266356337306638",

0 commit comments

Comments
 (0)