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
@@ -50,9 +51,9 @@ final class StructuredConfigPropertiesBridge implements ConfigProperties {
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
+ StructuredConfigPropertiesBridge (DeclarativeConfigProperties rootStructuredConfigProperties ) {
56
57
instrumentationJavaNode =
57
58
rootStructuredConfigProperties
58
59
.getStructured ("instrumentation" , empty ())
@@ -62,37 +63,37 @@ final class StructuredConfigPropertiesBridge implements ConfigProperties {
62
63
@ Nullable
63
64
@ Override
64
65
public String getString (String propertyName ) {
65
- return getPropertyValue (propertyName , StructuredConfigProperties ::getString );
66
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getString );
66
67
}
67
68
68
69
@ Nullable
69
70
@ Override
70
71
public Boolean getBoolean (String propertyName ) {
71
- return getPropertyValue (propertyName , StructuredConfigProperties ::getBoolean );
72
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getBoolean );
72
73
}
73
74
74
75
@ Nullable
75
76
@ Override
76
77
public Integer getInt (String propertyName ) {
77
- return getPropertyValue (propertyName , StructuredConfigProperties ::getInt );
78
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getInt );
78
79
}
79
80
80
81
@ Nullable
81
82
@ Override
82
83
public Long getLong (String propertyName ) {
83
- return getPropertyValue (propertyName , StructuredConfigProperties ::getLong );
84
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getLong );
84
85
}
85
86
86
87
@ Nullable
87
88
@ Override
88
89
public Double getDouble (String propertyName ) {
89
- return getPropertyValue (propertyName , StructuredConfigProperties ::getDouble );
90
+ return getPropertyValue (propertyName , DeclarativeConfigProperties ::getDouble );
90
91
}
91
92
92
93
@ Nullable
93
94
@ Override
94
95
public Duration getDuration (String propertyName ) {
95
- Long millis = getPropertyValue (propertyName , StructuredConfigProperties ::getLong );
96
+ Long millis = getPropertyValue (propertyName , DeclarativeConfigProperties ::getLong );
96
97
if (millis == null ) {
97
98
return null ;
98
99
}
@@ -110,8 +111,8 @@ public List<String> getList(String propertyName) {
110
111
111
112
@ Override
112
113
public Map <String , String > getMap (String propertyName ) {
113
- StructuredConfigProperties propertyValue =
114
- getPropertyValue (propertyName , StructuredConfigProperties ::getStructured );
114
+ DeclarativeConfigProperties propertyValue =
115
+ getPropertyValue (propertyName , DeclarativeConfigProperties ::getStructured );
115
116
if (propertyValue == null ) {
116
117
return Collections .emptyMap ();
117
118
}
@@ -131,7 +132,7 @@ public Map<String, String> getMap(String propertyName) {
131
132
132
133
@ Nullable
133
134
private <T > T getPropertyValue (
134
- String property , BiFunction <StructuredConfigProperties , String , T > extractor ) {
135
+ String property , BiFunction <DeclarativeConfigProperties , String , T > extractor ) {
135
136
if (!property .startsWith (OTEL_INSTRUMENTATION_PREFIX )) {
136
137
return null ;
137
138
}
@@ -141,7 +142,7 @@ private <T> T getPropertyValue(
141
142
if (segments .length == 0 ) {
142
143
return null ;
143
144
}
144
- StructuredConfigProperties target = instrumentationJavaNode ;
145
+ DeclarativeConfigProperties target = instrumentationJavaNode ;
145
146
if (segments .length > 1 ) {
146
147
for (int i = 0 ; i < segments .length - 1 ; i ++) {
147
148
target = target .getStructured (segments [i ], empty ());
0 commit comments