removed head sampling ratio from config

Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
This commit is contained in:
Pratik Mankawde
2026-06-09 18:45:52 +01:00
parent bb8f7f0e9a
commit fa71280795
5 changed files with 99 additions and 47 deletions

View File

@@ -30,6 +30,7 @@
#include <opentelemetry/sdk/trace/batch_span_processor_options.h>
#include <opentelemetry/sdk/trace/processor.h>
#include <opentelemetry/sdk/trace/sampler.h>
#include <opentelemetry/sdk/trace/samplers/parent_factory.h>
#include <opentelemetry/sdk/trace/samplers/trace_id_ratio.h>
#include <opentelemetry/sdk/trace/tracer_provider.h>
#include <opentelemetry/sdk/trace/tracer_provider_factory.h>
@@ -299,8 +300,15 @@ public:
{"xrpl.network.type", setup_.networkType},
});
// Configure sampler
auto sampler = std::make_unique<trace_sdk::TraceIdRatioBasedSampler>(setup_.samplingRatio);
// Configure sampler. Head sampling is fixed at 1.0 (sample everything);
// setup_.samplingRatio is not config-driven. Wrap the ratio sampler in a
// ParentBasedSampler so spans with a remote parent honor the upstream
// sampled flag — this keeps keep/drop decisions coherent for a single
// distributed trace spanning multiple nodes. Volume reduction is left to
// the collector's tail sampling.
auto rootSampler =
std::make_shared<trace_sdk::TraceIdRatioBasedSampler>(setup_.samplingRatio);
auto sampler = trace_sdk::ParentBasedSamplerFactory::Create(std::move(rootSampler));
// Create TracerProvider
sdkProvider_ = trace_sdk::TracerProviderFactory::Create(