[
https://issues.apache.org/jira/browse/HTRACE-359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15248439#comment-15248439
]
Mike Drob commented on HTRACE-359:
----------------------------------
Leaving the TraceScope in the type signature for the constructor makes it very
clunky to trace tasks originating from RPC requests where you can efficiently
encode a span id, but not a full scope.
Having only a span id means that to create a task specific sub-trace involves
either creating a new scope as a child of that span id and using that to wrap
the task (bad because tracing the rpc handler is not interesting) or create a
new scope and detach/reattach (bad because this is significantly more invasive
than simply wrapping the task would be).
Current code would looks something like...
{code}
void process(RPC request) {
// Implementation here not relevant, assume some kind of struct
SpanId parentSpanId = request.getSpanId();
getTracer().newScope("RPC Process", parentSpanId);
Callable<?> task = getTracer().wrap(new MyCallable(request), null);
// task gets submitted and used later, imagine some sort of queuing mechanism
}
{code}
I see several problems with this pattern. What happens to the result from
{{Tracer::newScope}}? When should it be closed? We only created it so that
{{Tracer::wrap}} would have something returned from {{threadLocalScope.get()}}.
Ignoring the return value and relying on side effects is bound to cause
problems down the road.
The other option, to detach and reattach scopes, would end up being fairly
invasive to the code used, and defeats the point of having convenience
implementations for {{Trace\{Run,Call}able}}. In my ideal world, I could
construct them on my own and then limit the changes for integrating my
application with HTrace to minimal surface area.
> TraceRunnable and TraceCallable should store parent spanId not scope
> --------------------------------------------------------------------
>
> Key: HTRACE-359
> URL: https://issues.apache.org/jira/browse/HTRACE-359
> Project: HTrace
> Issue Type: Bug
> Components: core
> Affects Versions: 4.0
> Reporter: Mike Drob
> Assignee: Mike Drob
> Attachments: HTRACE-359.patch.txt
>
>
> TraceRunnable/Callable both take a parent TraceScope and extract the span Id
> from it when executing the task. Instead, we should allow users to create
> custom TraceRunnable/Callable instances with only a SpanId instead of a full
> TraceScope, for instance when reading a span id from an RPC call and a
> TraceScope object is not available.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)