Skip to content

Commit

Permalink
Updated sampling result name (#1661)
Browse files Browse the repository at this point in the history
* Changed all sampling result names

* Changed all sampling result names - spanbuilderSdkTest

* Changed all sampling result names

* Changed all sampling result names - spanbuilderSdkTest

* fixed formatting violations

* fixed formatting violations

* Update sdk/tracing/src/main/java/io/opentelemetry/sdk/trace/Sampler.java

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>
  • Loading branch information
euniceek and anuraaga authored Sep 18, 2020
1 parent 51e93f7 commit 0ec2914
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 84 deletions.
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 @@ -61,11 +61,11 @@ SamplingResult shouldSample(
*/
String getDescription();

/** A decision on whether a span should be recorded, recorded and sampled or not recorded. */
/** A decision on whether a span should be recorded, recorded and sampled or dropped. */
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

0 comments on commit 0ec2914

Please sign in to comment.