-
Notifications
You must be signed in to change notification settings - Fork 249
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
Set sampler other than the default #321
Comments
So something like: sampler = OpenTelemetry::SDK::Trace::Samplers.parent_or_else(OpenTelemetry::SDK::Trace::Samplers.probability(0.001))
trace_config = OpenTelemetry::SDK::Trace::Config::TraceConfig.new(sampler: sampler)
OpenTelemetry.tracer_provider.active_trace_config = trace_config The heavily nested namespaces are decidedly unpleasant when you see them like this 😞 . The spec is less prescriptive than it used to be about configuration, so we should carefully consider whether this should be more convenient. To my mind, I'd prefer to configure the OpenTelemetry.tracer_provider.sampler = OpenTelemetry::SDK::Trace::Samplers.parent_or_else(OpenTelemetry::SDK::Trace::Samplers.probability(0.001)) There's still heavy nesting of the I suppose we could tweak the interface of OpenTelemetry.tracer_provider.sampler = OpenTelemetry::SDK::Trace::Samplers.parent_or_else(probability: 0.001)
OpenTelemetry.tracer_provider.sampler = OpenTelemetry::SDK::Trace::Samplers.parent_or_else(:always_on)
OpenTelemetry.tracer_provider.sampler = OpenTelemetry::SDK::Trace::Samplers.parent_or_else(:always_off)
OpenTelemetry.tracer_provider.sampler = OpenTelemetry::SDK::Trace::Samplers.parent_or_else(MyCustomSampler.new) Note that the spec for |
Thanks, what about exposing the sampler as an SDK configuration method? OpenTelemetry::SDK.configure do |config|
config.sampler OpenTelemetry::SDK::Trace::Samplers.parent_or_probability(0.001)
...
end |
We can do that, but the spec also allows the sampler to be replaced after configuration (MAY rather than MUST, but we already support it). Also, I think we want to be clear that this is the trace sampler. Anyway, I'll address the SDK configuration in a separate PR. |
And actually, I think we want to make the configuration even less wordy by providing helpers for the standard samplers: OpenTelemetry::SDK.configure do |c|
c.trace_sampler = c.parent_or_else(c.probability(0.001))
...
end |
Is this implemented yet? i.e. is there now a way to set overall sampling probability in the global |
@johnnyshields I actually don't think the configurator block supports this yet - I believe the best way to do it globally is via environment variables. See the test suite here for examples:
@fbogsany This is probably something we should still plan on doing, yeah? |
@ahayworth thank you. Would be great if configurator could support it as well. |
👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the |
Hello,
I can't find and setter to the sampler in
TracerProvider
, Is there any option to change the default sampler within the SDK's configuration?The text was updated successfully, but these errors were encountered: