@@ -66,6 +66,10 @@ public static boolean getBoolean(
6666 (key ) -> getBoolean (key , defaultValue ));
6767 }
6868
69+ /**
70+ * Returns the int value of the given property name from system properties and environment
71+ * variables.
72+ */
6973 public static int getInt (String propertyName , int defaultValue ) {
7074 String strValue = getString (propertyName );
7175 if (strValue == null ) {
@@ -78,6 +82,13 @@ public static int getInt(String propertyName, int defaultValue) {
7882 }
7983 }
8084
85+ /**
86+ * Returns the string value of the given property name from system properties and environment
87+ * variables.
88+ *
89+ * <p>It's recommended to use {@link #getString(OpenTelemetry, String, String...)} instead to
90+ * support Declarative Config.
91+ */
8192 @ Nullable
8293 public static String getString (String propertyName ) {
8394 String value = System .getProperty (propertyName );
@@ -87,6 +98,10 @@ public static String getString(String propertyName) {
8798 return System .getenv (toEnvVarName (propertyName ));
8899 }
89100
101+ /**
102+ * Returns the string value of the given property name from Declarative Config if available,
103+ * otherwise falls back to system properties and environment variables.
104+ */
90105 public static String getString (
91106 OpenTelemetry openTelemetry , String defaultValue , String ... propertyName ) {
92107 return getDeclarativeConfigOrFallback (
@@ -99,21 +114,23 @@ public static String getString(
99114 });
100115 }
101116
102- private static List <String > getList (String propertyName , List <String > defaultValue ) {
103- String value = getString (propertyName );
104- if (value == null ) {
105- return defaultValue ;
106- }
107- return filterBlanksAndNulls (value .split ("," ));
108- }
109-
117+ /**
118+ * Returns the list of strings value of the given property name from Declarative Config if
119+ * available, otherwise falls back to system properties and environment variables.
120+ */
110121 public static List <String > getList (
111122 OpenTelemetry openTelemetry , List <String > defaultValue , String ... propertyName ) {
112123 return getDeclarativeConfigOrFallback (
113124 openTelemetry ,
114125 propertyName ,
115126 (node , key ) -> node .getScalarList (key , String .class , defaultValue ),
116- (key ) -> getList (key , defaultValue ));
127+ (key ) -> {
128+ String value = getString (key );
129+ if (value == null ) {
130+ return defaultValue ;
131+ }
132+ return filterBlanksAndNulls (value .split ("," ));
133+ });
117134 }
118135
119136 private static List <String > filterBlanksAndNulls (String [] values ) {
0 commit comments