Skip to content

Commit 9f10ec7

Browse files
committed
string
1 parent 2f9acf3 commit 9f10ec7

File tree

4 files changed

+12
-31
lines changed

4 files changed

+12
-31
lines changed

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/InstrumenterBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ private String getSchemaUrl() {
370370
SpanSuppressor buildSpanSuppressor() {
371371
return new SpanSuppressors.ByContextKey(
372372
SpanSuppressionStrategy.fromConfig(
373-
ConfigPropertiesUtil.getNullableString(
374-
openTelemetry, "experimental", "span_suppression_strategy"))
373+
ConfigPropertiesUtil.getString(
374+
openTelemetry, "semconv", "experimental", "span_suppression_strategy"))
375375
.create(getSpanKeysFromAttributesExtractors()));
376376
}
377377

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanSuppressionStrategy.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import java.util.Locale;
1818
import java.util.Map;
1919
import java.util.Set;
20-
import javax.annotation.Nullable;
2120

2221
enum SpanSuppressionStrategy {
2322
/** Do not suppress spans at all. */
@@ -74,10 +73,7 @@ SpanSuppressor create(Set<SpanKey> spanKeys) {
7473

7574
abstract SpanSuppressor create(Set<SpanKey> spanKeys);
7675

77-
static SpanSuppressionStrategy fromConfig(@Nullable String value) {
78-
if (value == null) {
79-
value = "semconv";
80-
}
76+
static SpanSuppressionStrategy fromConfig(String value) {
8177
switch (value.toLowerCase(Locale.ROOT)) {
8278
case "none":
8379
return NONE;

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/ConfigPropertiesUtil.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package io.opentelemetry.instrumentation.api.internal;
77

88
import static io.opentelemetry.api.incubator.config.DeclarativeConfigProperties.empty;
9-
import static java.util.Objects.requireNonNull;
109

1110
import io.opentelemetry.api.OpenTelemetry;
1211
import io.opentelemetry.api.incubator.ExtendedOpenTelemetry;
@@ -90,27 +89,14 @@ public static String getString(String propertyName) {
9089

9190
public static String getString(
9291
OpenTelemetry openTelemetry, String defaultValue, String... propertyName) {
93-
return requireNonNull(getStringImpl(openTelemetry, defaultValue, propertyName));
94-
}
95-
96-
@Nullable
97-
public static String getStringImpl(
98-
OpenTelemetry openTelemetry, @Nullable String defaultValue, String... propertyName) {
99-
String result =
100-
getDeclarativeConfigOrFallback(
101-
openTelemetry,
102-
propertyName,
103-
(node, key) -> node.getString(key),
104-
(key) -> getString(key));
105-
if (result == null) {
106-
return defaultValue;
107-
}
108-
return result;
109-
}
110-
111-
@Nullable
112-
public static String getNullableString(OpenTelemetry openTelemetry, String... propertyName) {
113-
return getStringImpl(openTelemetry, null, propertyName);
92+
return getDeclarativeConfigOrFallback(
93+
openTelemetry,
94+
propertyName,
95+
(node, key) -> node.getString(key, defaultValue),
96+
(key) -> {
97+
String strValue = getString(key);
98+
return strValue == null ? defaultValue : strValue;
99+
});
114100
}
115101

116102
private static List<String> getList(String propertyName, List<String> defaultValue) {

instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/SpanSuppressionStrategyTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ private static Stream<Arguments> configArgs() {
4545
Arguments.of("Span-Kind", SpanSuppressionStrategy.SPAN_KIND),
4646
Arguments.of("semconv", SpanSuppressionStrategy.SEMCONV),
4747
Arguments.of("SemConv", SpanSuppressionStrategy.SEMCONV),
48-
Arguments.of("asdfasdfasdf", SpanSuppressionStrategy.SEMCONV),
49-
Arguments.of(null, SpanSuppressionStrategy.SEMCONV));
48+
Arguments.of("asdfasdfasdf", SpanSuppressionStrategy.SEMCONV));
5049
}
5150

5251
@ParameterizedTest

0 commit comments

Comments
 (0)