|
46 | 46 | */ |
47 | 47 | final class StructuredConfigPropertiesBridge implements ConfigProperties { |
48 | 48 |
|
| 49 | + private static final String OTEL_INSTRUMENTATION_PREFIX = "otel.instrumentation."; |
| 50 | + |
49 | 51 | private static final StructuredConfigProperties EMPTY = new EmptyStructuredConfigProperties(); |
50 | 52 |
|
51 | | - private final StructuredConfigProperties javaInstrumentation; |
| 53 | + // The node at .instrumentation.java |
| 54 | + private final StructuredConfigProperties instrumentationJavaNode; |
52 | 55 |
|
53 | 56 | StructuredConfigPropertiesBridge(StructuredConfigProperties rootStructuredConfigProperties) { |
54 | 57 | StructuredConfigProperties instrumentation = |
55 | 58 | rootStructuredConfigProperties.getStructured("instrumentation"); |
56 | 59 | if (instrumentation != null) { |
57 | 60 | StructuredConfigProperties javaInstrumentation = instrumentation.getStructured("java"); |
58 | | - this.javaInstrumentation = javaInstrumentation != null ? javaInstrumentation : EMPTY; |
| 61 | + this.instrumentationJavaNode = javaInstrumentation != null ? javaInstrumentation : EMPTY; |
59 | 62 | } else { |
60 | | - this.javaInstrumentation = EMPTY; |
| 63 | + this.instrumentationJavaNode = EMPTY; |
61 | 64 | } |
62 | 65 | } |
63 | 66 |
|
@@ -134,16 +137,16 @@ public Map<String, String> getMap(String propertyName) { |
134 | 137 | @Nullable |
135 | 138 | private <T> T getPropertyValue( |
136 | 139 | String property, BiFunction<StructuredConfigProperties, String, T> extractor) { |
137 | | - if (!property.startsWith("otel.instrumentation.")) { |
| 140 | + if (!property.startsWith(OTEL_INSTRUMENTATION_PREFIX)) { |
138 | 141 | return null; |
139 | 142 | } |
140 | | - String suffix = property.substring("otel.instrumentation.".length()); |
| 143 | + String suffix = property.substring(OTEL_INSTRUMENTATION_PREFIX.length()); |
141 | 144 | // Split the remainder of the property on ".", and walk to the N-1 entry |
142 | 145 | String[] segments = suffix.split("\\."); |
143 | 146 | if (segments.length == 0) { |
144 | 147 | return null; |
145 | 148 | } |
146 | | - StructuredConfigProperties target = javaInstrumentation; |
| 149 | + StructuredConfigProperties target = instrumentationJavaNode; |
147 | 150 | if (segments.length > 1) { |
148 | 151 | for (int i = 0; i < segments.length - 1; i++) { |
149 | 152 | StructuredConfigProperties newTarget = target.getStructured(segments[i]); |
|
0 commit comments