Skip to content
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

Merged
merged 9 commits into from
Jun 14, 2021
Merged

Refactor span names class #3281

merged 9 commits into from
Jun 14, 2021

Conversation

trask
Copy link
Member

@trask trask commented Jun 13, 2021

A few things in this PR:

  • Remove already deprecated BaseTracer.spanName* methods
  • Split out ClassNames from SpanNames
    • Rename SpanNames.spanNameForMethod --> SpanNames.fromMethod
    • Move SpanNames.spanNameForClass --> ClassNames.simpleName

Based on @anuraaga's #3070 (comment):

Not for this PR, just for everyone's thought, I feel like this method shouldn't be needed (publicly) either we should audit its usage, spans are methods, not classes.

Copy link
Contributor

@anuraaga anuraaga left a 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

return type.getSimpleName();
}
String className = type.getName();
if (type.getPackage() != null) {
Copy link
Contributor

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 {
Copy link
Member

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
Copy link
Member

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

@trask trask merged commit 9f31a05 into open-telemetry:main Jun 14, 2021
@trask trask deleted the refactor-span-names-class branch June 14, 2021 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants