You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@htrace.apache.org by "Colin Patrick McCabe (JIRA)" <ji...@apache.org> on 2015/07/17 06:25:05 UTC

[jira] [Commented] (HTRACE-215) Simplify the Sampler type

    [ https://issues.apache.org/jira/browse/HTRACE-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14630744#comment-14630744 ] 

Colin Patrick McCabe commented on HTRACE-215:
---------------------------------------------

I've been thinking about this, and I don't think the {{Sampler<T>}} type provides any advantage over just plain old {{Sampler}}.  It seems like in practice pretty much every traced application and library uses the {{SamplerFactory}}, which just returns a {{Sampler<?>}}.  We don't have a single example of a {{Sampler}} which is anything other than {{Sampler<Object>}}, or a single example of one that uses the templated parameter.

The fundamental issue is that if you want to use a {{Sampler<Foo>}}, you have to change your code to call {{startSpan("spanName", mySampler, myFoo)}}.  If we're going to start hacking up the application code, we could easily do something like this:

{code}
startSpan("spanName", myFoo.saysItIsOk() ? AlwaysSampler.INSTANCE : NeverSampler.INSTANCE)
{code}

If this seems to cumbersome, we could always write a utility function wrapping it, similar to {{DFSClient#getPathTraceScope}}, which creates a new span with a "path" KV annotation.

So in summary, the generic type parameter seems to add no additional value, and it leads to a lot of ugly {{<?>}} boilerplate and findbugs warnings.  Let's zap it in 4.0.

> Simplify the Sampler type
> -------------------------
>
>                 Key: HTRACE-215
>                 URL: https://issues.apache.org/jira/browse/HTRACE-215
>             Project: HTrace
>          Issue Type: Sub-task
>    Affects Versions: 4.0
>            Reporter: Colin Patrick McCabe
>            Assignee: Colin Patrick McCabe
>
> The Sampler type currently is parameterized on another type, like {{Sampler<T>}}.  However, this is not really useful now that we have moved to a model of creating samplers from the {{SamplerFactory}}, since the {{SamplerFactory}} returns a {{Sampler<?>}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)