-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add xray configurable sampler * Check name
- Loading branch information
Anuraag Agrawal
authored
Aug 5, 2021
1 parent
236b9e6
commit e1050fa
Showing
4 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
25 changes: 25 additions & 0 deletions
25
aws-xray/src/main/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerProvider.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,25 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package io.opentelemetry.contrib.awsxray; | ||
|
||
import com.google.auto.service.AutoService; | ||
import io.opentelemetry.sdk.autoconfigure.ConfigProperties; | ||
import io.opentelemetry.sdk.autoconfigure.OpenTelemetrySdkAutoConfiguration; | ||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurableSamplerProvider; | ||
import io.opentelemetry.sdk.trace.samplers.Sampler; | ||
|
||
@AutoService(ConfigurableSamplerProvider.class) | ||
public class AwsXrayRemoteSamplerProvider implements ConfigurableSamplerProvider { | ||
|
||
@Override | ||
public Sampler createSampler(ConfigProperties config) { | ||
return AwsXrayRemoteSampler.newBuilder(OpenTelemetrySdkAutoConfiguration.getResource()).build(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "xray"; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...xray/src/test/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerProviderTest.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,24 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package io.opentelemetry.contrib.awsxray; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.InstanceOfAssertFactories.type; | ||
|
||
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurableSamplerProvider; | ||
import java.util.ServiceLoader; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class AwsXrayRemoteSamplerProviderTest { | ||
|
||
@Test | ||
void serviceProvider() { | ||
ServiceLoader<ConfigurableSamplerProvider> samplerProviders = | ||
ServiceLoader.load(ConfigurableSamplerProvider.class); | ||
assertThat(samplerProviders) | ||
.singleElement(type(AwsXrayRemoteSamplerProvider.class)) | ||
.satisfies(provider -> assertThat(provider.getName()).isEqualTo("xray")); | ||
} | ||
} |
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