Skip to content

Commit 78da2bb

Browse files
authored
enable azure provider by default when available (#596)
* enable azure provider by default * make test more generic and easier to extend * spotless * update changelog
1 parent eb6f422 commit 78da2bb

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

CHANGELOG.next-release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
* Switched the default of `otel.exporter.otlp.metrics.temporality.preference` from `CUMULATIVE` to `DELTA` to improve dashboarding experience with Kibana. If you want to restore the previous behaviour, you can manually override `otel.exporter.otlp.metrics.temporality.preference` to `CUMULATIVE` via JVM-properties or environment variables. - #583
22
* Set elastic-specific User-Agent header for OTLP exporters - #593
3+
* Enable Azure resource provider by default with `otel.resource.providers.azure.enabled` = `true`.

gradle/libs.versions.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ opentelemetryInstrumentationAlphaBom = { group = "io.opentelemetry.instrumentati
3030

3131
opentelemetryProto = { group = "io.opentelemetry.proto", name = "opentelemetry-proto", version.ref = "opentelemetryProto" }
3232

33-
awsContribResources = { group = "io.opentelemetry.contrib", name = "opentelemetry-aws-resources", version.ref = "opentelemetryContribAlpha" }
34-
gcpContribResources = { group = "io.opentelemetry.contrib", name = "opentelemetry-gcp-resources", version.ref = "opentelemetryContribAlpha" }
3533
contribResources = { group = "io.opentelemetry.contrib", name = "opentelemetry-resource-providers", version.ref = "opentelemetryContribAlpha" }
3634
contribSpanStacktrace = { group = "io.opentelemetry.contrib", name = "opentelemetry-span-stacktrace", version.ref = "opentelemetryContribAlpha" }
3735
contribInferredSpans = { group = "io.opentelemetry.contrib", name = "opentelemetry-inferred-spans", version.ref = "opentelemetryContribAlpha" }

resources/src/main/java/co/elastic/otel/resources/ResourcesAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@AutoService(AutoConfigurationCustomizerProvider.class)
2929
public class ResourcesAutoConfiguration implements AutoConfigurationCustomizerProvider {
3030

31-
private static final String[] PROVIDERS = {"aws", "gcp"};
31+
private static final String[] PROVIDERS = {"aws", "gcp", "azure"};
3232

3333
@Override
3434
public void customize(AutoConfigurationCustomizer autoConfiguration) {

resources/src/test/java/co/elastic/otel/resources/ResourcesAutoConfigurationTest.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,55 @@
2121
import static org.assertj.core.api.Assertions.assertThat;
2222

2323
import io.opentelemetry.sdk.autoconfigure.spi.internal.DefaultConfigProperties;
24+
import java.util.Arrays;
2425
import java.util.Collections;
2526
import java.util.HashMap;
27+
import java.util.List;
2628
import java.util.Map;
2729
import org.junit.jupiter.api.Test;
2830

2931
class ResourcesAutoConfigurationTest {
3032

31-
public static final String GCP_ENABLED = "otel.resource.providers.gcp.enabled";
32-
public static final String AWS_ENABLED = "otel.resource.providers.aws.enabled";
33+
private static final List<String> LIST =
34+
Arrays.asList(config("gcp"), config("aws"), config("azure"));
35+
36+
private static String config(String provider) {
37+
return String.format("otel.resource.providers.%s.enabled", provider);
38+
}
3339

3440
@Test
3541
void elastic_defaults() {
3642
// default everything should be enabled
3743

3844
Map<String, String> explicitConfig = Collections.emptyMap();
3945
Map<String, String> expectedResult = new HashMap<>();
40-
expectedResult.put(GCP_ENABLED, "true");
41-
expectedResult.put(AWS_ENABLED, "true");
46+
47+
LIST.forEach(v -> expectedResult.put(v, "true"));
4248

4349
testConfig(explicitConfig, expectedResult);
4450
}
4551

4652
@Test
4753
void explicitly_enabled() {
4854
Map<String, String> explicitConfig = new HashMap<>();
49-
explicitConfig.put(GCP_ENABLED, "true");
55+
explicitConfig.put(LIST.get(0), "true");
5056

5157
Map<String, String> expectedResult = new HashMap<>();
52-
expectedResult.put(GCP_ENABLED, "true");
53-
expectedResult.put(AWS_ENABLED, "true");
58+
LIST.forEach(v -> expectedResult.put(v, "true"));
5459

5560
testConfig(explicitConfig, expectedResult);
5661
}
5762

5863
@Test
5964
void explicitly_disabled() {
6065
Map<String, String> explicitConfig = new HashMap<>();
61-
explicitConfig.put(GCP_ENABLED, "false");
66+
explicitConfig.put(LIST.get(0), "false");
6267

6368
Map<String, String> expectedResult = new HashMap<>();
64-
expectedResult.put(GCP_ENABLED, "false");
65-
expectedResult.put(AWS_ENABLED, "true");
69+
expectedResult.put(LIST.get(0), "false");
70+
for (int i = 1; i < LIST.size(); i++) {
71+
expectedResult.put(LIST.get(i), "true");
72+
}
6673

6774
testConfig(explicitConfig, expectedResult);
6875
}

0 commit comments

Comments
 (0)