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

Can we use Head-based sampling on iOS? #1713

Closed
Mirconet opened this issue Mar 7, 2024 · 3 comments
Closed

Can we use Head-based sampling on iOS? #1713

Mirconet opened this issue Mar 7, 2024 · 3 comments

Comments

@Mirconet
Copy link

Mirconet commented Mar 7, 2024

Question

We want to use the Head-based sampling, as suggested in your documentation, to keep the entire transaction traces.
We managed to achieve the result in the Android app using the dd-sdk-android. In the Android library, we found two different Sampler interfaces:

The default implementation for the first sampler uses random sampling, while the implementation of the second uses deterministic sampling. Setting our custom sampling frequency only to the deterministic one and 100% to the other permits us to achieve the result on Android.

On the contrary on the DD iOS library, we saw that we could configure the sampling rate in two different points:

  • on the Trace.Configuration init level
  • on the Trace.Configuration.URLSessionTracking init level passed to the Trace.Configuration init

Both the settings seem to make the tracer use the same random Sampler that doesn't permit us to link the spans between the chain of services and implement a Head-based sampling strategy to keep the entire transaction traces like Android.

How can we achieve this result on iOS?

@Mirconet Mirconet added the question Further information is requested label Mar 7, 2024
@ncreated ncreated self-assigned this Mar 8, 2024
@ncreated
Copy link
Member

ncreated commented Mar 8, 2024

Hello @Mirconet 👋. Thank you for this report, I think this is indeed a problem. I added it to our backlog and we will discuss it in the team. We will keep you posted in this GH Issue.

I believe you're right that the 2 sampling rates available in DatadogTrace module are not in proper sync:

traceConfig.sampleRate = 50 // tracer sampling
traceConfig.urlSessionTracking = .init(
    firstPartyHostsTracing: .trace(hosts: ["foo.com"], sampleRate: 100) // distributed trace sampling
)

The distributed trace sampling should take precedence over tracer sampling in distributed tracing scenario. Meaning that if foo.com trace was sampled at 100%, the span sent from SDK must respect it. Instead it seems to use 50% configured in tracer sampler.

Unfortunately, I don't see any mitigation / workaround at this moment other than "no sampling" (100% in both). We will keep this thread with updates.

@ncreated
Copy link
Member

Hey @Mirconet 👋. We just merged #1794 that adds support to head-based sampling. It should be available in next release.

@ncreated
Copy link
Member

2.11.0 is out and it includes head-based sampling. Closing the issue.

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

No branches or pull requests

3 participants