Skip to content

Commit

Permalink
add a provider for consistent parent based probability sampler (open-…
Browse files Browse the repository at this point in the history
  • Loading branch information
kes2464 authored and zeitlinger committed Aug 25, 2023
1 parent a7d3297 commit f71241d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions consistent-sampling/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ otelJava.moduleName.set("io.opentelemetry.contrib.sampler.consistent")

dependencies {
api("io.opentelemetry:opentelemetry-sdk-trace")
api("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
testImplementation("org.hipparchus:hipparchus-core:2.3")
testImplementation("org.hipparchus:hipparchus-stat:2.3")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.contrib.sampler.consistent;

import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import io.opentelemetry.sdk.autoconfigure.spi.traces.ConfigurableSamplerProvider;
import io.opentelemetry.sdk.trace.samplers.Sampler;

public final class ParentBasedConsistentProbabilitySamplerProvider
implements ConfigurableSamplerProvider {

@Override
public Sampler createSampler(ConfigProperties config) {
double samplingProbability = config.getDouble("otel.traces.sampler.arg", 1.0d);
return ConsistentSampler.parentBased(ConsistentSampler.probabilityBased(samplingProbability));
}

@Override
public String getName() {
return "parentbased_consistent_probability";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.opentelemetry.contrib.sampler.consistent.ParentBasedConsistentProbabilitySamplerProvider

0 comments on commit f71241d

Please sign in to comment.