Skip to content

Commit 48e9453

Browse files
committed
add unit tests for configuring emf exporter in adot
1 parent b686dc1 commit 48e9453

File tree

2 files changed

+553
-5
lines changed

2 files changed

+553
-5
lines changed

awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/AwsApplicationSignalsCustomizerProvider.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) {
180180
autoConfiguration.addMetricExporterCustomizer(this::customizeMetricExporter);
181181
}
182182

183-
private static Optional<String> getAwsRegionFromEnvironment() {
184-
String region = System.getenv(AWS_REGION);
183+
private static Optional<String> getAwsRegionFromConfig(ConfigProperties configProps) {
184+
String region = configProps.getString(AWS_REGION);
185185
if (region != null) {
186186
return Optional.of(region);
187187
}
188-
return Optional.ofNullable(System.getenv(AWS_DEFAULT_REGION));
188+
return Optional.ofNullable(configProps.getString(AWS_DEFAULT_REGION));
189189
}
190190

191191
static boolean isLambdaEnvironment() {
@@ -205,7 +205,7 @@ private boolean isApplicationSignalsRuntimeEnabled(ConfigProperties configProps)
205205
&& configProps.getBoolean(APPLICATION_SIGNALS_RUNTIME_ENABLED_CONFIG, true);
206206
}
207207

208-
private Map<String, String> customizeProperties(ConfigProperties configProps) {
208+
Map<String, String> customizeProperties(ConfigProperties configProps) {
209209
Map<String, String> propsOverride = new HashMap<>();
210210
boolean isLambdaEnvironment = isLambdaEnvironment();
211211

@@ -537,7 +537,8 @@ MetricExporter customizeMetricExporter(
537537
Map<String, String> headers =
538538
AwsApplicationSignalsConfigUtils.parseOtlpHeaders(
539539
configProps.getString(OTEL_EXPORTER_OTLP_LOGS_HEADERS));
540-
Optional<String> awsRegion = getAwsRegionFromEnvironment();
540+
Optional<String> awsRegion = getAwsRegionFromConfig(configProps);
541+
541542
if (awsRegion.isPresent()) {
542543
if (headers.containsKey(AWS_OTLP_LOGS_GROUP_HEADER)
543544
&& headers.containsKey(AWS_OTLP_LOGS_STREAM_HEADER)

0 commit comments

Comments
 (0)