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

Disable tracerresolver configuration #38

Closed
pavolloffay opened this issue Sep 7, 2017 · 10 comments
Closed

Disable tracerresolver configuration #38

pavolloffay opened this issue Sep 7, 2017 · 10 comments

Comments

@pavolloffay
Copy link
Collaborator

Currently, if I want to use tracerresolver there is no way how to tell auto-config that I would like to use NoopTracer to quickly "disable the instrumentation". Probably we should provide a configuration property which would use Noop or resolve the tracer.

cc @objectiser @jpkrohling

@objectiser
Copy link
Contributor

As TracerResolver relies on the relevant tracer being in the classpath, wouldn't another option just be to comment out the tracer dependency? Not saying a config option wouldn't be ok, but just looking at alternatives.

@pavolloffay
Copy link
Collaborator Author

Yeah, that is one possibility although it might be inconvenient.

I would like to port https://github.com/redhat-helloworld-msa/ola and other SB services to use tracerresolver. Currently the code use noop is tracer server URL is not specified.

@jpkrohling
Copy link

I think your case is one that warrants setting the "skip tracer resolver" flag and dealing with the GlobalTracer at your application level. After all, the logic of "if tracer server URL is not specified, use the NoopTracer` is an application logic :)

@pavolloffay
Copy link
Collaborator Author

if tracer server URL is not specified, use the NoopTracer it is kind of "a" logic. How would you solve my use case then?

I would like to get rid of all app level logic regarding tracing. And I would like to be able to enable/disable tracing with some ENV property. (currently it can be done by using noop, we could also use one conf. property on all auto-configs)

@objectiser
Copy link
Contributor

If this was going to be done via env/property - then it would be better done in the TracerResolver itself, so it would be applicable outside any particular instrumentation/framework.

@pavolloffay
Copy link
Collaborator Author

To clarify this issue, the use case is to provide a way to quickly disable instrumentation.

I can think of two solutions:

1. disable all auto-configs with a property

This is by means is the best from the performance perspective. However, if users are using tracer inside the app it can fail in some scenarios (e.g. fails to autowire tracer bean).

2. use noop tracer

The only issue I currently have with noop tracer is that it does not use span source inside so switching from real tracer to noop can result in NPEs (e.g. tracer.activeSpan() retruns null (https://github.com/opentracing/opentracing-java/blob/master/opentracing-noop/src/main/java/io/opentracing/noop/NoopTracer.java#L41)). I would like to address this in the next version of the API.

When somebody is not using tracerresolver and would like to disable instrumentation it can simply return NoopTracer bean or use:

@ConditionalOnProperty(name = "instrumenation.enabled", havingValue = "true", matchIfMissing = true)
@Bean
Tracer tracer() {...}

So when he start app using java -jar -Dinstrumentation.enabled=false foo.jar our auto-config will use NoopTracer.

However, if you are using tracerrresolver you cannot do ^^^. Tracer impl can be removed from classpath, however, it is not ideal for k8s deployment where you would like to control things via env properties.

@pavolloffay
Copy link
Collaborator Author

@ask4gilles
Copy link
Contributor

I'd like to be able to completely skip the autoconfig (like we can do in https://github.com/opentracing-contrib/java-spring-cloud/) It would be the responsibility of the user to inject the tracer with required=false Currently, what would be the alternative to skip web tracing? (for IT tests for example or for some environments where you are not interested in tracing metrics?)

@pavolloffay
Copy link
Collaborator Author

@ask4gilles I have created a separate issue for this: #65. Let me know if you would like to contribute it, it seems like a simple fix.

@pavolloffay
Copy link
Collaborator Author

I will close this for now.

At the moment all auto-configurations can be disabled with a property. Tracer configuration has been moved here https://github.com/opentracing-contrib/java-spring-tracer-configuration.

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

No branches or pull requests

4 participants