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

Trace config property to indicate that the responsibility of deciding to trace or not is delegated to another component #1865

Closed
dh-ger opened this issue Dec 9, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@dh-ger
Copy link

dh-ger commented Dec 9, 2020

Is your feature request related to a problem? Please describe.
We are in the process of modernizing a legacy application and splitting out components into microservices.
We run in Kubernetes where we have many different APIs (ours is a spring boot API) and we sit behind an API gateway.
In terms of distributed tracing we use b3-multi propagation, and it is the responsibility of a component at the gateway to set the headers before forwarding to the appropriate service. For our product we chose to set x-b3-sampled to 1 for 1% of requests.
We have some other traffic that hits our API (health checks, integration tests etc), that originates from within the cluster that will not have the b3 headers set. What we find in this scenario is that the java-instrumentation will by default trace all of these, when ideally we would like to not trace them at all.
Of course we can control the probability, but this does not really work as desired for this case.

Describe the solution you'd like
A flag that would indicate that the instrumentation would operate in passive mode and rely on the values set as indicated by the selected propagation method, rather than initiating a trace if the headers are not set.

Describe alternatives you've considered
We tried setting the otel.config.sampler.probability=0, but this has the effect of not tracing anything, even when the headers are set by the gateway, as a workaround we set this to 0.001 so that only every 1/1000 requests that do not have headers get traced as a temporary workaround.

@dh-ger dh-ger added the enhancement New feature or request label Dec 9, 2020
@iNikem
Copy link
Contributor

iNikem commented Dec 9, 2020

Do I understand you correctly, that you want an option to run a javaagent in a mode, where it joins already existing trace but will not initiate new ones?

@dh-ger
Copy link
Author

dh-ger commented Dec 9, 2020

Yes, this essentially what it boils down to

@iNikem
Copy link
Contributor

iNikem commented Dec 9, 2020

I think using Sampler.parentBased(Sampler.alwaysOff()) sampler achieves this, no? The question remains, how do tell this javaagent to use this sampler...

@dh-ger
Copy link
Author

dh-ger commented Dec 9, 2020

So I had assumed that the desired behavior would be achieved when setting otel.config.sampler.probability to 0.
However when this is set to 0, then it also does not join existing traces.

It is possible that your suggestion might work, however as you say I have no idea how to configure the javaagent to do this.

@trask
Copy link
Member

trask commented Dec 9, 2020

another option is #1060

@dh-ger
Copy link
Author

dh-ger commented Dec 10, 2020

Yes, this would definitely solve the issue we have with health checks getting traced

@trask
Copy link
Member

trask commented Apr 6, 2021

I think using Sampler.parentBased(Sampler.alwaysOff()) sampler achieves this, no? The question remains, how do tell this javaagent to use this sampler...

Closing, this should be possible now using

OTEL_TRACES_SAMPLER=parentbased_always_off

(https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#sampler)

@trask trask closed this as completed Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants