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

span-reporter span id generation is very slow. #18 #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ public class SpanBuilderR implements Tracer.SpanBuilder {
}

String findSpanId(SpanContext context) {
if (context != null && context.baggageItems() != null) {
for (Map.Entry<String,String> kv: context.baggageItems()) {
if (BAGGAGE_SPANID_KEY.equals(kv.getKey())) {
return kv.getValue();
if (context != null) {
Iterable<Map.Entry<String, String>> baggageItems = context.baggageItems();
if (baggageItems != null) {
for (Map.Entry<String,String> kv: baggageItems) {
if (BAGGAGE_SPANID_KEY.equals(kv.getKey())) {
return kv.getValue();
}
}
}
}
Expand All @@ -69,7 +72,14 @@ public Tracer.SpanBuilder asChildOf(Span parent) {
@Override
public Tracer.SpanBuilder addReference(String s, SpanContext spanContext) {
wrapped.addReference(s, spanContext);
references.put(s, findSpanId(spanContext));
String referenceId;
if (spanContext != null) {
referenceId = spanContext.toSpanId();
}
else {
referenceId = findSpanId(spanContext);
}
Comment on lines +79 to +81
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regarding the impl of findSpanId, referenceId is always "" in this case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, I need to go back (refresh) into the API of Opentracing (like spanContext.toSpanId();) and into the code to complete my review. FYI, I'll not be able to publish a new release (I don't have the permissions to publish)

@davidB - Thanks for your reply. Does that mean there wont be any releases/updates on this library going forward?

references.put(s, referenceId);
return this;
}

Expand Down Expand Up @@ -118,8 +128,14 @@ public Tracer.SpanBuilder withStartTimestamp(long l) {
@Override
public Span start() {
Span wspan = wrapped.start();
String spanId = UUID.randomUUID().toString();
wspan.setBaggageItem(BAGGAGE_SPANID_KEY, spanId);
String spanId;
SpanContext spanContext = wspan.context();
if (spanContext != null) {
spanId = spanContext.toSpanId();
} else {
spanId = UUID.randomUUID().toString();
wspan.setBaggageItem(BAGGAGE_SPANID_KEY, spanId);
}

// shamelessly copied from io.jaegertracing.internal.JaegerTracer.SpanBuilder#start
// of io.jaegertracing:jaeger-core:0.35.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ public void close() {
this.wrapped.close();
}

@Override
public String toString() {
return "SpanReporterTracer{" + wrapped + '}';
}

}