Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

API for minimizing no-tracer / non-sampled overhead #8

Open
bhs opened this issue Nov 16, 2016 · 1 comment
Open

API for minimizing no-tracer / non-sampled overhead #8

bhs opened this issue Nov 16, 2016 · 1 comment
Labels

Comments

@bhs
Copy link
Contributor

bhs commented Nov 16, 2016

Continuing the discussion from opentracing/opentracing.io#31

cc: @dkuebric @bensigelman @bogdandrutu @yurishkuro

@cwe1ss
Copy link
Member

cwe1ss commented Mar 30, 2018

In .NET, most new libraries/frameworks provide instrumentation hooks via an observer pattern through a type called DiagnosticSource. Having a "no-tracer"-check (e.g. tracer.isEnabled()) would allow us to not even create a subscription and would therefore result in a zero-overhead situation.

It's already possible to do this by checking the tracer instance type but this is pretty ugly especially due to how GlobalTracer works in Java/C# (it wraps the underlying tracer):

public static bool IsNoopTracer(ITracer tracer)
{
    // This will be "if (tracer is NoopTracer)" once an open PR in opentracing-csharp gets merged.
    if (tracer == NoopTracerFactory.Create())
        return true;

    // There's currently no way to check the underlying tracer on the instance 
    // so we have to check the static method.
    if (tracer is GlobalTracer && !GlobalTracer.IsRegistered())
        return true;

    return false;
}

Having a better way to do this would be nice.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants