Skip to content

Commit a89364a

Browse files
committed
migrate code extractor
1 parent a87bb01 commit a89364a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/code/CodeAttributesExtractor.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ public final class CodeAttributesExtractor<REQUEST, RESPONSE>
2222
implements AttributesExtractor<REQUEST, RESPONSE> {
2323

2424
// copied from CodeIncubatingAttributes
25-
private static final AttributeKey<String> CODE_FUNCTION = AttributeKey.stringKey("code.function");
26-
private static final AttributeKey<String> CODE_NAMESPACE =
27-
AttributeKey.stringKey("code.namespace");
25+
private static final AttributeKey<String> CODE_FUNCTION_NAME =
26+
AttributeKey.stringKey("code.function.name");
2827

2928
/** Creates the code attributes extractor. */
3029
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
@@ -40,11 +39,13 @@ private CodeAttributesExtractor(CodeAttributesGetter<REQUEST> getter) {
4039

4140
@Override
4241
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
42+
StringBuilder sb = new StringBuilder();
4343
Class<?> cls = getter.getCodeClass(request);
4444
if (cls != null) {
45-
internalSet(attributes, CODE_NAMESPACE, cls.getName());
45+
sb.append(cls.getName()).append(".");
4646
}
47-
internalSet(attributes, CODE_FUNCTION, getter.getMethodName(request));
47+
sb.append(getter.getMethodName(request));
48+
internalSet(attributes, CODE_FUNCTION_NAME, sb.toString());
4849
}
4950

5051
@Override

0 commit comments

Comments
 (0)