Skip to content

Commit e276b1c

Browse files
authored
Exporter code simplification (#1398)
* Exporter code simplification * Fixes * Use internal namespace * E_TOO_MANY_METHOD_PARAMS * Remove duplication
1 parent ced1832 commit e276b1c

File tree

3 files changed

+113
-166
lines changed

3 files changed

+113
-166
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/sampling/TraceIdBasedSampler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.List;
44
import javax.annotation.Nullable;
55

6+
import com.microsoft.applicationinsights.agent.Exporter;
67
import io.opentelemetry.api.common.AttributeKey;
78
import io.opentelemetry.api.common.Attributes;
89
import io.opentelemetry.api.common.ReadableAttributes;
@@ -20,8 +21,6 @@ public final class TraceIdBasedSampler implements Sampler {
2021

2122
private static final Logger logger = LoggerFactory.getLogger(TraceIdBasedSampler.class);
2223

23-
private static final AttributeKey<Double> AI_SAMPLING_PERCENTAGE = AttributeKey.doubleKey("ai.internal.sampling.percentage");
24-
2524
// all sampling percentage must be in a ratio of 100/N where N is a whole number (2, 3, 4, …)
2625
// e.g. 50 for 1/2 or 33.33 for 1/3
2726
//
@@ -35,7 +34,7 @@ public TraceIdBasedSampler(double samplingPercentage) {
3534
this.samplingPercentage = samplingPercentage;
3635
Attributes alwaysOnAttributes;
3736
if (samplingPercentage != 100) {
38-
alwaysOnAttributes = Attributes.of(AI_SAMPLING_PERCENTAGE, samplingPercentage);
37+
alwaysOnAttributes = Attributes.of(Exporter.AI_SAMPLING_PERCENTAGE_KEY, samplingPercentage);
3938
} else {
4039
alwaysOnAttributes = Attributes.empty();
4140
}

0 commit comments

Comments
 (0)