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

Updated sampling result name #1661

Merged
merged 8 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public SamplingResult shouldSample(
List<Link> parentLinks) {
// We sample only if the Span name contains "SAMPLE"
return Samplers.emptySamplingResult(
name.contains("SAMPLE") ? Decision.RECORD_AND_SAMPLED : Decision.NOT_RECORD);
name.contains("SAMPLE") ? Decision.RECORD_AND_SAMPLE : Decision.DROP);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ SamplingResult shouldSample(

/** A decision on whether a span should be recorded, recorded and sampled or not recorded. */
euniceek marked this conversation as resolved.
Show resolved Hide resolved
enum Decision {
NOT_RECORD,
RECORD,
RECORD_AND_SAMPLED,
DROP,
RECORD_ONLY,
RECORD_AND_SAMPLE,
}

/**
Expand All @@ -85,8 +85,8 @@ interface SamplingResult {
* Return tags which will be attached to the span.
*
* @return attributes added to span. These attributes should be added to the span only when
* {@linkplain #getDecision() the sampling decision} is {@link Decision#RECORD} or {@link
* Decision#RECORD_AND_SAMPLED}.
* {@linkplain #getDecision() the sampling decision} is {@link Decision#RECORD_ONLY} or
* {@link Decision#RECORD_AND_SAMPLE}.
*/
Attributes getAttributes();
}
Expand Down
20 changes: 10 additions & 10 deletions sdk/tracing/src/main/java/io/opentelemetry/sdk/trace/Samplers.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ public final class Samplers {
DoubleAttributeSetter.create("sampling.probability");

private static final SamplingResult EMPTY_RECORDED_AND_SAMPLED_SAMPLING_RESULT =
SamplingResultImpl.createWithoutAttributes(Decision.RECORD_AND_SAMPLED);
SamplingResultImpl.createWithoutAttributes(Decision.RECORD_AND_SAMPLE);
private static final SamplingResult EMPTY_NOT_SAMPLED_OR_RECORDED_SAMPLING_RESULT =
SamplingResultImpl.createWithoutAttributes(Decision.NOT_RECORD);
SamplingResultImpl.createWithoutAttributes(Decision.DROP);
private static final SamplingResult EMPTY_RECORDED_SAMPLING_RESULT =
SamplingResultImpl.createWithoutAttributes(Decision.RECORD);
SamplingResultImpl.createWithoutAttributes(Decision.RECORD_ONLY);

// No instance of this class.
private Samplers() {}

static boolean isRecording(Decision decision) {
return Decision.RECORD.equals(decision) || Decision.RECORD_AND_SAMPLED.equals(decision);
return Decision.RECORD_ONLY.equals(decision) || Decision.RECORD_AND_SAMPLE.equals(decision);
}

static boolean isSampled(Decision decision) {
return Decision.RECORD_AND_SAMPLED.equals(decision);
return Decision.RECORD_AND_SAMPLE.equals(decision);
}

/**
Expand Down Expand Up @@ -104,11 +104,11 @@ public static SamplingResult samplingResult(Decision decision, Attributes attrib
*/
public static SamplingResult emptySamplingResult(Decision decision) {
switch (decision) {
case RECORD_AND_SAMPLED:
case RECORD_AND_SAMPLE:
return EMPTY_RECORDED_AND_SAMPLED_SAMPLING_RESULT;
case RECORD:
case RECORD_ONLY:
return EMPTY_RECORDED_SAMPLING_RESULT;
case NOT_RECORD:
case DROP:
return EMPTY_NOT_SAMPLED_OR_RECORDED_SAMPLING_RESULT;
}
throw new AssertionError("unrecognised samplingResult");
Expand Down Expand Up @@ -445,8 +445,8 @@ static Probability create(double probability) {
return new AutoValue_Samplers_Probability(
probability,
idUpperBound,
SamplingResultImpl.createWithProbability(Decision.RECORD_AND_SAMPLED, probability),
SamplingResultImpl.createWithProbability(Decision.NOT_RECORD, probability));
SamplingResultImpl.createWithProbability(Decision.RECORD_AND_SAMPLE, probability),
SamplingResultImpl.createWithProbability(Decision.DROP, probability));
}

abstract double getProbability();
Expand Down
Loading