File tree Expand file tree Collapse file tree 5 files changed +12
-14
lines changed
main/java/io/opentelemetry/api/incubator/config
testConvertToModel/java/io/opentelemetry/api/incubator
sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator Expand file tree Collapse file tree 5 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -23,15 +23,14 @@ public interface ConfigProvider {
2323 /**
2424 * Returns the {@link DeclarativeConfigProperties} corresponding to <a
2525 * href="https://github.com/open-telemetry/opentelemetry-configuration/blob/main/schema/instrumentation.json">instrumentation
26- * config</a>, or {@code null } if unavailable.
26+ * config</a>. Returns {@link DeclarativeConfigProperties#empty() } if unavailable.
2727 *
2828 * @return the instrumentation {@link DeclarativeConfigProperties}
2929 */
30- @ Nullable
3130 DeclarativeConfigProperties getInstrumentationConfig ();
3231
3332 /** Returns a no-op {@link ConfigProvider}. */
3433 static ConfigProvider noop () {
35- return () -> null ;
34+ return DeclarativeConfigProperties :: empty ;
3635 }
3736}
Original file line number Diff line number Diff line change @@ -124,9 +124,8 @@ public static DeclarativeConfigProperties javaInstrumentationConfig(
124124
125125 /**
126126 * Walk down the {@code segments} of {@link ConfigProvider#getInstrumentationConfig()} and call
127- * {@code accessor} on the terminal node. Returns null if {@link
128- * ConfigProvider#getInstrumentationConfig()} is null, or if null is encountered walking the
129- * {@code segments}, or if {@code accessor} returns null.
127+ * {@code accessor} on the terminal node. Returns null if null is encountered walking the {@code
128+ * segments}, or if {@code accessor} returns null.
130129 *
131130 * <p>See other methods in {@link InstrumentationConfigUtil} for usage examples.
132131 */
@@ -136,9 +135,6 @@ public static <T> T getOrNull(
136135 Function <DeclarativeConfigProperties , T > accessor ,
137136 String ... segments ) {
138137 DeclarativeConfigProperties config = configProvider .getInstrumentationConfig ();
139- if (config == null ) {
140- return null ;
141- }
142138 for (String segment : segments ) {
143139 config = config .getStructured (segment );
144140 if (config == null ) {
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ void toMap_RoundTrip() throws JsonProcessingException {
6161
6262 @ Test
6363 void getInstrumentationConfigModel_UnsetConfig () {
64- ConfigProvider configProvider = () -> null ;
64+ ConfigProvider configProvider = DeclarativeConfigProperties :: empty ;
6565
6666 assertThat (
6767 InstrumentationConfigUtil .getInstrumentationConfigModel (
Original file line number Diff line number Diff line change @@ -74,7 +74,6 @@ private ObfuscatedConfigProvider(SdkConfigProvider delegate) {
7474 }
7575
7676 @ Override
77- @ Nullable
7877 public DeclarativeConfigProperties getInstrumentationConfig () {
7978 return delegate .getInstrumentationConfig ();
8079 }
Original file line number Diff line number Diff line change 1414/** SDK implementation of {@link ConfigProvider}. */
1515public final class SdkConfigProvider implements ConfigProvider {
1616
17- @ Nullable private final DeclarativeConfigProperties instrumentationConfig ;
17+ private final DeclarativeConfigProperties instrumentationConfig ;
1818
1919 private SdkConfigProvider (
2020 OpenTelemetryConfigurationModel model , ComponentLoader componentLoader ) {
2121 DeclarativeConfigProperties configProperties =
2222 DeclarativeConfiguration .toConfigProperties (model , componentLoader );
23- this .instrumentationConfig = configProperties .getStructured ("instrumentation/development" );
23+ DeclarativeConfigProperties instrumentationConfigOrNull =
24+ configProperties .getStructured ("instrumentation/development" );
25+ this .instrumentationConfig =
26+ instrumentationConfigOrNull == null
27+ ? DeclarativeConfigProperties .empty ()
28+ : instrumentationConfigOrNull ;
2429 }
2530
2631 /**
@@ -45,7 +50,6 @@ public static SdkConfigProvider create(
4550 return new SdkConfigProvider (model , componentLoader );
4651 }
4752
48- @ Nullable
4953 @ Override
5054 public DeclarativeConfigProperties getInstrumentationConfig () {
5155 return instrumentationConfig ;
You can’t perform that action at this time.
0 commit comments