-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df397de
commit 7f4bd5e
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
javaagent/src/test/java/io/opentelemetry/javaagent/ResourceProviderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.ServiceLoader; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ResourceProviderTest { | ||
|
||
@Test | ||
void resourceProviderOrder() throws Exception { | ||
boolean containerProviderFound = false; | ||
boolean awsProviderFound = false; | ||
// verify that aws resource provider is found after the regular container provider | ||
// provider that is found later can overrider values from previous providers | ||
Class<?> resourceProviderClass = | ||
Class.forName( | ||
"io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider", | ||
false, | ||
IntegrationTestUtils.getAgentClassLoader()); | ||
for (Object resourceProvider : | ||
ServiceLoader.load(resourceProviderClass, IntegrationTestUtils.getAgentClassLoader())) { | ||
Class<?> clazz = resourceProvider.getClass(); | ||
if (clazz | ||
.getName() | ||
.equals("io.opentelemetry.instrumentation.resources.ContainerResourceProvider")) { | ||
containerProviderFound = true; | ||
assertFalse(awsProviderFound); | ||
} else if (clazz.getName().startsWith("io.opentelemetry.contrib.aws.resource.")) { | ||
awsProviderFound = true; | ||
assertTrue(containerProviderFound); | ||
} | ||
} | ||
assertTrue(containerProviderFound); | ||
assertTrue(awsProviderFound); | ||
} | ||
} |