55
66package  io .opentelemetry .javaagent .extension ;
77
8- import  static  io .opentelemetry .sdk . autoconfigure . spi . internal . StructuredConfigProperties .empty ;
8+ import  static  io .opentelemetry .api . incubator . config . DeclarativeConfigProperties .empty ;
99
10+ import  io .opentelemetry .api .incubator .config .DeclarativeConfigProperties ;
1011import  io .opentelemetry .sdk .autoconfigure .spi .ConfigProperties ;
11- import  io .opentelemetry .sdk .autoconfigure .spi .internal .StructuredConfigProperties ;
1212import  java .time .Duration ;
1313import  java .util .Collections ;
1414import  java .util .HashMap ;
1818import  javax .annotation .Nullable ;
1919
2020/** 
21-  * A {@link ConfigProperties} which resolves properties based on {@link StructuredConfigProperties}. 
21+  * A {@link ConfigProperties} which resolves properties based on {@link 
22+  * DeclarativeConfigProperties}. 
2223 * 
2324 * <p>Only properties starting with "otel.instrumentation." are resolved. Others return null (or 
2425 * default value if provided). 
3031 *   <li>The portion of the property after "otel.instrumentation." is split into segments based on 
3132 *       ".". 
3233 *   <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. 
3637 * </ul> 
3738 * 
3839 * <p>For example, given the following YAML, asking for {@code 
4546 *         string_key: value 
4647 * </pre> 
4748 */ 
48- final  class  StructuredConfigPropertiesBridge  implements  ConfigProperties  {
49+ final  class  DeclarativeConfigPropertiesBridge  implements  ConfigProperties  {
4950
5051  private  static  final  String  OTEL_INSTRUMENTATION_PREFIX  = "otel.instrumentation." ;
5152
5253  // The node at .instrumentation.java 
53-   private  final  StructuredConfigProperties  instrumentationJavaNode ;
54+   private  final  DeclarativeConfigProperties  instrumentationJavaNode ;
5455
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 ());
6058  }
6159
6260  @ Nullable 
6361  @ Override 
6462  public  String  getString (String  propertyName ) {
65-     return  getPropertyValue (propertyName , StructuredConfigProperties ::getString );
63+     return  getPropertyValue (propertyName , DeclarativeConfigProperties ::getString );
6664  }
6765
6866  @ Nullable 
6967  @ Override 
7068  public  Boolean  getBoolean (String  propertyName ) {
71-     return  getPropertyValue (propertyName , StructuredConfigProperties ::getBoolean );
69+     return  getPropertyValue (propertyName , DeclarativeConfigProperties ::getBoolean );
7270  }
7371
7472  @ Nullable 
7573  @ Override 
7674  public  Integer  getInt (String  propertyName ) {
77-     return  getPropertyValue (propertyName , StructuredConfigProperties ::getInt );
75+     return  getPropertyValue (propertyName , DeclarativeConfigProperties ::getInt );
7876  }
7977
8078  @ Nullable 
8179  @ Override 
8280  public  Long  getLong (String  propertyName ) {
83-     return  getPropertyValue (propertyName , StructuredConfigProperties ::getLong );
81+     return  getPropertyValue (propertyName , DeclarativeConfigProperties ::getLong );
8482  }
8583
8684  @ Nullable 
8785  @ Override 
8886  public  Double  getDouble (String  propertyName ) {
89-     return  getPropertyValue (propertyName , StructuredConfigProperties ::getDouble );
87+     return  getPropertyValue (propertyName , DeclarativeConfigProperties ::getDouble );
9088  }
9189
9290  @ Nullable 
9391  @ Override 
9492  public  Duration  getDuration (String  propertyName ) {
95-     Long  millis  = getPropertyValue (propertyName , StructuredConfigProperties ::getLong );
93+     Long  millis  = getPropertyValue (propertyName , DeclarativeConfigProperties ::getLong );
9694    if  (millis  == null ) {
9795      return  null ;
9896    }
@@ -110,8 +108,8 @@ public List<String> getList(String propertyName) {
110108
111109  @ Override 
112110  public  Map <String , String > getMap (String  propertyName ) {
113-     StructuredConfigProperties  propertyValue  =
114-         getPropertyValue (propertyName , StructuredConfigProperties ::getStructured );
111+     DeclarativeConfigProperties  propertyValue  =
112+         getPropertyValue (propertyName , DeclarativeConfigProperties ::getStructured );
115113    if  (propertyValue  == null ) {
116114      return  Collections .emptyMap ();
117115    }
@@ -131,7 +129,7 @@ public Map<String, String> getMap(String propertyName) {
131129
132130  @ Nullable 
133131  private  <T > T  getPropertyValue (
134-       String  property , BiFunction <StructuredConfigProperties , String , T > extractor ) {
132+       String  property , BiFunction <DeclarativeConfigProperties , String , T > extractor ) {
135133    if  (!property .startsWith (OTEL_INSTRUMENTATION_PREFIX )) {
136134      return  null ;
137135    }
@@ -141,7 +139,7 @@ private <T> T getPropertyValue(
141139    if  (segments .length  == 0 ) {
142140      return  null ;
143141    }
144-     StructuredConfigProperties  target  = instrumentationJavaNode ;
142+     DeclarativeConfigProperties  target  = instrumentationJavaNode ;
145143    if  (segments .length  > 1 ) {
146144      for  (int  i  = 0 ; i  < segments .length  - 1 ; i ++) {
147145        target  = target .getStructured (segments [i ], empty ());
0 commit comments