Skip to content

Commit

Permalink
don't fail spring application startup if sdk is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Feb 19, 2024
1 parent c885982 commit 9919997
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ private ExporterConfigEvaluator() {}
public static boolean isExporterEnabled(
Environment environment, String exportersKey, String wantExporter, boolean defaultValue) {

if (environment.getProperty("otel.sdk.disabled", Boolean.class, false)) {
return false;
}

String exporter = environment.getProperty(exportersKey);
if (exporter != null) {
return Arrays.asList(exporter.split(",")).contains(wantExporter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -26,6 +27,7 @@
@EnableConfigurationProperties(PropagationProperties.class)
@AutoConfigureBefore(OpenTelemetryAutoConfiguration.class)
@ConditionalOnProperty(prefix = "otel.propagation", name = "enabled", matchIfMissing = true)
@ConditionalOnBean(ConfigProperties.class)
public class PropagationAutoConfiguration {

private static final List<String> DEFAULT_PROPAGATORS = Arrays.asList("tracecontext", "baggage");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.smoketest;

import io.opentelemetry.spring.smoketest.OtelSpringStarterSmokeTestApplication;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest(
classes = {
OtelSpringStarterSmokeTestApplication.class,
OtelSpringStarterSmokeTest.TestConfiguration.class
},
properties = {"otel.sdk.disabled=true"})
class OtelSpringStarterDisabledSmokeTest {

@Test
void shouldStartApplication() {
// make sure we can still start the application with the disabled property
}
}

0 comments on commit 9919997

Please sign in to comment.