5
5
6
6
package io .opentelemetry .javaagent .extension ;
7
7
8
- import static io .opentelemetry .sdk . autoconfigure . spi . internal . StructuredConfigProperties .empty ;
8
+ import static io .opentelemetry .api . incubator . config . DeclarativeConfigProperties .empty ;
9
9
10
+ import io .opentelemetry .api .incubator .config .DeclarativeConfigProperties ;
10
11
import io .opentelemetry .sdk .autoconfigure .spi .ConfigProperties ;
11
- import io .opentelemetry .sdk .autoconfigure .spi .internal .StructuredConfigProperties ;
12
12
import java .time .Duration ;
13
13
import java .util .Collections ;
14
14
import java .util .HashMap ;
18
18
import javax .annotation .Nullable ;
19
19
20
20
/**
21
- * A {@link ConfigProperties} which resolves properties based on {@link StructuredConfigProperties}.
21
+ * A {@link ConfigProperties} which resolves properties based on {@link
22
+ * DeclarativeConfigProperties}.
22
23
*
23
24
* <p>Only properties starting with "otel.instrumentation." are resolved. Others return null (or
24
25
* default value if provided).
30
31
* <li>The portion of the property after "otel.instrumentation." is split into segments based on
31
32
* ".".
32
33
* <li>For each N-1 segment, we walk down the tree to find the relevant leaf {@link
33
- * StructuredConfigProperties }.
34
- * <li>We extract the property from the resolved {@link StructuredConfigProperties } using the last
35
- * segment as the property key.
34
+ * DeclarativeConfigProperties }.
35
+ * <li>We extract the property from the resolved {@link DeclarativeConfigProperties } using the
36
+ * last segment as the property key.
36
37
* </ul>
37
38
*
38
39
* <p>For example, given the following YAML, asking for {@code
45
46
* string_key: value
46
47
* </pre>
47
48
*/
48
- final class StructuredConfigPropertiesBridge implements ConfigProperties {
49
+ final class DeclarativeConfigPropertiesBridge implements ConfigProperties {
49
50
50
51
private static final String OTEL_INSTRUMENTATION_PREFIX = "otel.instrumentation." ;
51
52
52
53
// The node at .instrumentation.java
53
- private final StructuredConfigProperties instrumentationJavaNode ;
54
+ private final DeclarativeConfigProperties instrumentationJavaNode ;
54
55
55
- StructuredConfigPropertiesBridge (StructuredConfigProperties rootStructuredConfigProperties ) {
56
- instrumentationJavaNode =
57
- rootStructuredConfigProperties
58
- .getStructured ("instrumentation" , empty ())
59
- .getStructured ("java" , empty ());
56
+ DeclarativeConfigPropertiesBridge (DeclarativeConfigProperties instrumentationNode ) {
57
+ instrumentationJavaNode = instrumentationNode .getStructured ("java" , empty ());
60
58
}
61
59
62
60
@ Nullable
63
61
@ Override
64
62
public String getString (String propertyName ) {
65
- return getPropertyValue (propertyName , StructuredConfigProperties ::getString );
63
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getString );
66
64
}
67
65
68
66
@ Nullable
69
67
@ Override
70
68
public Boolean getBoolean (String propertyName ) {
71
- return getPropertyValue (propertyName , StructuredConfigProperties ::getBoolean );
69
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getBoolean );
72
70
}
73
71
74
72
@ Nullable
75
73
@ Override
76
74
public Integer getInt (String propertyName ) {
77
- return getPropertyValue (propertyName , StructuredConfigProperties ::getInt );
75
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getInt );
78
76
}
79
77
80
78
@ Nullable
81
79
@ Override
82
80
public Long getLong (String propertyName ) {
83
- return getPropertyValue (propertyName , StructuredConfigProperties ::getLong );
81
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getLong );
84
82
}
85
83
86
84
@ Nullable
87
85
@ Override
88
86
public Double getDouble (String propertyName ) {
89
- return getPropertyValue (propertyName , StructuredConfigProperties ::getDouble );
87
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getDouble );
90
88
}
91
89
92
90
@ Nullable
93
91
@ Override
94
92
public Duration getDuration (String propertyName ) {
95
- Long millis = getPropertyValue (propertyName , StructuredConfigProperties ::getLong );
93
+ Long millis = getPropertyValue (propertyName , DeclarativeConfigProperties ::getLong );
96
94
if (millis == null ) {
97
95
return null ;
98
96
}
@@ -110,8 +108,8 @@ public List<String> getList(String propertyName) {
110
108
111
109
@ Override
112
110
public Map <String , String > getMap (String propertyName ) {
113
- StructuredConfigProperties propertyValue =
114
- getPropertyValue (propertyName , StructuredConfigProperties ::getStructured );
111
+ DeclarativeConfigProperties propertyValue =
112
+ getPropertyValue (propertyName , DeclarativeConfigProperties ::getStructured );
115
113
if (propertyValue == null ) {
116
114
return Collections .emptyMap ();
117
115
}
@@ -131,7 +129,7 @@ public Map<String, String> getMap(String propertyName) {
131
129
132
130
@ Nullable
133
131
private <T > T getPropertyValue (
134
- String property , BiFunction <StructuredConfigProperties , String , T > extractor ) {
132
+ String property , BiFunction <DeclarativeConfigProperties , String , T > extractor ) {
135
133
if (!property .startsWith (OTEL_INSTRUMENTATION_PREFIX )) {
136
134
return null ;
137
135
}
@@ -141,7 +139,7 @@ private <T> T getPropertyValue(
141
139
if (segments .length == 0 ) {
142
140
return null ;
143
141
}
144
- StructuredConfigProperties target = instrumentationJavaNode ;
142
+ DeclarativeConfigProperties target = instrumentationJavaNode ;
145
143
if (segments .length > 1 ) {
146
144
for (int i = 0 ; i < segments .length - 1 ; i ++) {
147
145
target = target .getStructured (segments [i ], empty ());
0 commit comments