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

[Sampling]: Example needed for ParentBased sampler with the TraceIDRatioBased sampler #6301

Open
JRobTS opened this issue Feb 12, 2025 · 2 comments
Labels

Comments

@JRobTS
Copy link

JRobTS commented Feb 12, 2025

URL

https://opentelemetry.io/docs/languages/go/sampling/

Description

The last statement in the document is unclear. It's not clear how to use the ParentBased sampler with the TraceIDRatioBased sampler.

An example would be handy.

I'm guessing here but to setup a 1% sampler, both parent and child services would configure this:

provider := trace.NewTracerProvider(
    trace.WithSampler(trace.ParentBased(trace.WithRemoteParentSampled(trace.TraceIDRatioBased(.01)))),
)

Or, is it more like this?

// In parent application:
provider := trace.NewTracerProvider(
    trace.WithSampler(trace.TraceIDRatioBased(.01)),
)

// In child application
provider := trace.NewTracerProvider()

Do we need to apply the same sampler to both?

// In parent application:
provider := trace.NewTracerProvider(
    trace.WithSampler(trace.TraceIDRatioBased(.01)),
)

// In child application
provider := trace.NewTracerProvider(
    trace.WithSampler(trace.ParentBased(trace.TraceIDRatioBased(.01))),
)
@tiffany76
Copy link
Contributor

Thanks for providing feedback and seeking clarification, @JRobTS!

@open-telemetry/go-approvers, PTAL.

@cartermp
Copy link
Contributor

You need to configure sampling for each application in exactly the same way, yes.

I'd recommend, if doing head sampling like this, to use environment variables instead.

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

No branches or pull requests

3 participants