|
9 | 9 | import io.opentelemetry.api.common.AttributeKey; |
10 | 10 | import io.opentelemetry.api.common.Attributes; |
11 | 11 | import io.opentelemetry.api.common.AttributesBuilder; |
12 | | -import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; |
13 | 12 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; |
14 | 13 | import io.opentelemetry.sdk.autoconfigure.spi.internal.ConditionalResourceProvider; |
15 | 14 | import io.opentelemetry.sdk.resources.Resource; |
|
21 | 20 | import java.util.Set; |
22 | 21 | import java.util.function.Function; |
23 | 22 | import java.util.stream.Collectors; |
24 | | -import javax.annotation.Nullable; |
25 | 23 |
|
26 | 24 | /** |
27 | 25 | * An easier alternative to {@link io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider}, which |
@@ -67,25 +65,16 @@ public final boolean shouldApply(ConfigProperties config, Resource existing) { |
67 | 65 |
|
68 | 66 | @Override |
69 | 67 | public final Resource createResource(ConfigProperties config) { |
70 | | - return create(filteredKeys); |
71 | | - } |
72 | | - |
73 | | - @SuppressWarnings({"unchecked", "rawtypes"}) |
74 | | - public final Resource createResource(DeclarativeConfigProperties config) { |
75 | | - return create((Set) attributeGetters.keySet()); |
76 | | - } |
77 | | - |
78 | | - private Resource create(@Nullable Set<AttributeKey<?>> keys) { |
79 | | - if (keys == null) { |
80 | | - throw new IllegalStateException("shouldApply should be called first"); |
81 | | - } |
82 | 68 | return attributeProvider |
83 | 69 | .readData() |
84 | 70 | .map( |
85 | 71 | data -> { |
| 72 | + if (filteredKeys == null) { |
| 73 | + throw new IllegalStateException("shouldApply should be called first"); |
| 74 | + } |
86 | 75 | AttributesBuilder builder = Attributes.builder(); |
87 | 76 | attributeGetters.entrySet().stream() |
88 | | - .filter(e -> keys.contains(e.getKey())) |
| 77 | + .filter(e -> filteredKeys.contains(e.getKey())) |
89 | 78 | .forEach( |
90 | 79 | e -> |
91 | 80 | e.getValue() |
|
0 commit comments