-
Notifications
You must be signed in to change notification settings - Fork 911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor span names class #3281
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hoping as we migrate more to instrumenter API, we'll use a CodeSpanNameExtractor.create(codeAttributes)
pattern instead of this class directly
instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/ClassNames.java
Outdated
Show resolved
Hide resolved
return type.getSimpleName(); | ||
} | ||
String className = type.getName(); | ||
if (type.getPackage() != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Packages are optional. Perhaps it would be better to use the same strategy as jdk uses
className = className.substring(className.lastIndexOf('.') + 1);
|
||
package io.opentelemetry.instrumentation.api.tracer; | ||
|
||
public class ClassNames { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: make it final and add a private constructor
@@ -33,7 +33,7 @@ private CodeSpanNameExtractor(CodeAttributesExtractor<REQUEST, ?> attributesExtr | |||
public String extract(REQUEST request) { | |||
Class<?> cls = attributesExtractor.codeClass(request); | |||
// TODO: avoid using SpanNames, encapsulate the logic here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can remove this TODO
A few things in this PR:
BaseTracer.spanName*
methodsClassNames
fromSpanNames
SpanNames.spanNameForMethod
-->SpanNames.fromMethod
SpanNames.spanNameForClass
-->ClassNames.simpleName
Based on @anuraaga's #3070 (comment):