SpanBuilder should initialize the start time when start() is called
See original GitHub issueI’m creating SpanBuilder
instances and initializing them with a parent span as well as basic tags. These builders are then used for all child span initialization. However when a second span is created using the same builder the start time of the 2nd span == start time of the 1st. This is unexpected. When you call .start()
without calling .withStartTime(micros)
then the start time is initialized to the relative nowish value. So I expected that every time .start()
is called it generates a new span with tag data and parent span initialized.
I’m also unclear whether the starttime of a span originates from System.nanoTime()
or from System.currentTimeMillis() * 1_000L
.
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
Manual Instrumentation | OpenTelemetry
To create Spans, you only need to specify the name of the span. The start and end time of the span is automatically...
Read more >io.opentracing.Tracer$SpanBuilder.startActive java ... - Tabnine
Returns a newly started and activated Scope. The returned Scope supports try-with-resources. For example: try (Scope scope = tracer.buildSpan("...").
Read more >SpannableStringBuilder to create String with multiple fonts/text ...
You can do this either as @Rajesh suggested or by this. ... BOLD), start, longDescription.length(), Spannable.
Read more >SpannableStringBuilder | Android Developers
Convenience for replace(length(), length(), text, start, end) ... Sets the series of filters that will be called in succession whenever the text of...
Read more >Tracer.SpanBuilder (OpenTracing API 0.31.0 API) - javadoc.io
start(), finishSpanOnClose) . Parameters: finishSpanOnClose - whether span should automatically be finished when Scope.close() is called; Returns ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, I do not follow your first point. Could you elaborate with a code example?
On the second point - yes, it is an extra allocation. However, that is a fairly standard pattern in Java for creating objects with optional data. The purpose of the builder is exactly that - to allow passing various optional parameters to the main startSpan method. In other OT languages there are no builders, e.g. JS and Python have an idiomatic way of passing optional parameters to functions, and in Go we use a functional option pattern. The latter is possible with Java, although I am not sure if it would still cause an allocation for the vararg array.
So my point is that, even it may not be explicitly stated in the Java OT API, but the builder was intended to be single use. In my experience it is the most common way of using the builder objects, given that they are mutable and raise all kinds of threading concerns if you try to reuse them.
-1 for SpanStarter. tracer.buildSpan is a fluent interface which means that its function should be obvious even if people don’t know the class name. So I don’t think that changing the name helps with the general issue. Also, changing it would be a huuuge breaking change.
+1 for starting the clock on the call to “start”.