Skip to content

Commit 24125d9

Browse files
committed
Update tests and test resource
1 parent 9483d56 commit 24125d9

File tree

2 files changed

+53
-278
lines changed

2 files changed

+53
-278
lines changed

instrumentation/opentelemetry-sdk-extension-autoconfigure-1.28.0/src/test/java/com/nr/agent/instrumentation/utils/span/AttributeMapperTest.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ public void getInstance_withValidJson_createsValidMapper() {
2727

2828
for (SpanKind spanKind : SpanKind.values()) {
2929
Map<AttributeType, List<AttributeKey>> attributeTypesBySpan = mappings.get(spanKind);
30-
assertEquals(2, attributeTypesBySpan.size());
30+
assertEquals(14, attributeTypesBySpan.size());
3131

32-
// The actual attribute key mappings...
33-
for (AttributeType attributeType : AttributeType.values()) {
34-
assertEquals(2, attributeTypesBySpan.get(attributeType).size());
35-
}
32+
assertEquals(2, attributeTypesBySpan.get(AttributeType.Port).size());
33+
assertEquals(2, attributeTypesBySpan.get(AttributeType.Host).size());
3634
}
3735
}
3836

@@ -66,10 +64,19 @@ public void attributeKeyClass_properlyParsesSemanticConventionField() {
6664
// Comma delimited list of semantic conventions exist in the SERVER -> Port
6765
Map<SpanKind, Map<AttributeType, List<AttributeKey>>> attributes = attributeMapper.getMappings();
6866
AttributeKey attribute = attributes.get(SpanKind.SERVER).get(AttributeType.Port).get(0);
69-
assertEquals(2, attribute.getSemanticConventions().length);
67+
assertEquals(3, attribute.getSemanticConventions().length);
68+
assertEquals("HTTP-Server:1.23", attribute.getSemanticConventions()[0]);
69+
assertEquals("HTTP-Server:1.24", attribute.getSemanticConventions()[1]);
70+
assertEquals("HTTP-Server:1.25", attribute.getSemanticConventions()[2]);
7071

7172
// Only one in SERVER -> Host
7273
attribute = attributes.get(SpanKind.SERVER).get(AttributeType.Host).get(0);
7374
assertEquals(1, attribute.getSemanticConventions().length);
75+
assertEquals("HTTP-Server:1.23", attribute.getSemanticConventions()[0]);
76+
77+
// Handle empty semantic convention field. INTERNAL -> Port
78+
attribute = attributes.get(SpanKind.INTERNAL).get(AttributeType.Port).get(0);
79+
assertEquals(1, attribute.getSemanticConventions().length);
80+
assertEquals("", attribute.getSemanticConventions()[0]);
7481
}
7582
}

0 commit comments

Comments
 (0)