| 
5 | 5 | 
 
  | 
6 | 6 | package io.opentelemetry.javaagent.extension;  | 
7 | 7 | 
 
  | 
 | 8 | +import static io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties.empty;  | 
 | 9 | + | 
8 | 10 | import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;  | 
9 | 11 | import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties;  | 
10 | 12 | import java.time.Duration;  | 
11 | 13 | import java.util.Collections;  | 
12 | 14 | import java.util.HashMap;  | 
13 | 15 | import java.util.List;  | 
14 | 16 | import java.util.Map;  | 
15 |  | -import java.util.Set;  | 
16 | 17 | import java.util.function.BiFunction;  | 
17 | 18 | import javax.annotation.Nullable;  | 
18 | 19 | 
 
  | 
@@ -48,20 +49,14 @@ final class StructuredConfigPropertiesBridge implements ConfigProperties {  | 
48 | 49 | 
 
  | 
49 | 50 |   private static final String OTEL_INSTRUMENTATION_PREFIX = "otel.instrumentation.";  | 
50 | 51 | 
 
  | 
51 |  | -  private static final StructuredConfigProperties EMPTY = new EmptyStructuredConfigProperties();  | 
52 |  | - | 
53 | 52 |   // The node at .instrumentation.java  | 
54 | 53 |   private final StructuredConfigProperties instrumentationJavaNode;  | 
55 | 54 | 
 
  | 
56 | 55 |   StructuredConfigPropertiesBridge(StructuredConfigProperties rootStructuredConfigProperties) {  | 
57 |  | -    StructuredConfigProperties instrumentation =  | 
58 |  | -        rootStructuredConfigProperties.getStructured("instrumentation");  | 
59 |  | -    if (instrumentation != null) {  | 
60 |  | -      StructuredConfigProperties javaInstrumentation = instrumentation.getStructured("java");  | 
61 |  | -      this.instrumentationJavaNode = javaInstrumentation != null ? javaInstrumentation : EMPTY;  | 
62 |  | -    } else {  | 
63 |  | -      this.instrumentationJavaNode = EMPTY;  | 
64 |  | -    }  | 
 | 56 | +    instrumentationJavaNode =  | 
 | 57 | +        rootStructuredConfigProperties  | 
 | 58 | +            .getStructured("instrumentation", empty())  | 
 | 59 | +            .getStructured("java", empty());  | 
65 | 60 |   }  | 
66 | 61 | 
 
  | 
67 | 62 |   @Nullable  | 
@@ -149,70 +144,10 @@ private <T> T getPropertyValue(  | 
149 | 144 |     StructuredConfigProperties target = instrumentationJavaNode;  | 
150 | 145 |     if (segments.length > 1) {  | 
151 | 146 |       for (int i = 0; i < segments.length - 1; i++) {  | 
152 |  | -        StructuredConfigProperties newTarget = target.getStructured(segments[i]);  | 
153 |  | -        if (newTarget == null) {  | 
154 |  | -          target = EMPTY;  | 
155 |  | -          break;  | 
156 |  | -        }  | 
157 |  | -        target = newTarget;  | 
 | 147 | +        target = target.getStructured(segments[i], empty());  | 
158 | 148 |       }  | 
159 | 149 |     }  | 
160 | 150 |     String lastPart = segments[segments.length - 1];  | 
161 | 151 |     return extractor.apply(target, lastPart);  | 
162 | 152 |   }  | 
163 |  | - | 
164 |  | -  private static class EmptyStructuredConfigProperties implements StructuredConfigProperties {  | 
165 |  | -    @Nullable  | 
166 |  | -    @Override  | 
167 |  | -    public String getString(String s) {  | 
168 |  | -      return null;  | 
169 |  | -    }  | 
170 |  | - | 
171 |  | -    @Nullable  | 
172 |  | -    @Override  | 
173 |  | -    public Boolean getBoolean(String s) {  | 
174 |  | -      return null;  | 
175 |  | -    }  | 
176 |  | - | 
177 |  | -    @Nullable  | 
178 |  | -    @Override  | 
179 |  | -    public Integer getInt(String s) {  | 
180 |  | -      return null;  | 
181 |  | -    }  | 
182 |  | - | 
183 |  | -    @Nullable  | 
184 |  | -    @Override  | 
185 |  | -    public Long getLong(String s) {  | 
186 |  | -      return null;  | 
187 |  | -    }  | 
188 |  | - | 
189 |  | -    @Nullable  | 
190 |  | -    @Override  | 
191 |  | -    public Double getDouble(String s) {  | 
192 |  | -      return null;  | 
193 |  | -    }  | 
194 |  | - | 
195 |  | -    @Nullable  | 
196 |  | -    @Override  | 
197 |  | -    public <T> List<T> getScalarList(String s, Class<T> aClass) {  | 
198 |  | -      return null;  | 
199 |  | -    }  | 
200 |  | - | 
201 |  | -    @Nullable  | 
202 |  | -    @Override  | 
203 |  | -    public StructuredConfigProperties getStructured(String s) {  | 
204 |  | -      return null;  | 
205 |  | -    }  | 
206 |  | - | 
207 |  | -    @Nullable  | 
208 |  | -    @Override  | 
209 |  | -    public List<StructuredConfigProperties> getStructuredList(String s) {  | 
210 |  | -      return null;  | 
211 |  | -    }  | 
212 |  | - | 
213 |  | -    @Override  | 
214 |  | -    public Set<String> getPropertyKeys() {  | 
215 |  | -      return Collections.emptySet();  | 
216 |  | -    }  | 
217 |  | -  }  | 
218 | 153 | }  | 
0 commit comments