Skip to content

Commit

Permalink
Add xray configurable sampler (#64)
Browse files Browse the repository at this point in the history
* Add xray configurable sampler

* Check name
  • Loading branch information
Anuraag Agrawal authored Aug 5, 2021
1 parent 236b9e6 commit e1050fa
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
6 changes: 6 additions & 0 deletions aws-xray/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ dependencies {
api("io.opentelemetry:opentelemetry-api")
api("io.opentelemetry:opentelemetry-sdk-trace")

compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")

implementation("io.opentelemetry:opentelemetry-semconv")

compileOnly("org.checkerframework:checker-qual")

annotationProcessor("com.google.auto.service:auto-service")
compileOnly("com.google.auto.service:auto-service-annotations")

annotationProcessor("com.google.auto.value:auto-value")
compileOnly("com.google.auto.value:auto-value-annotations")

implementation("com.fasterxml.jackson.core:jackson-core")
implementation("com.fasterxml.jackson.core:jackson-databind")

testImplementation("com.linecorp.armeria:armeria-junit5")
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
testImplementation("com.google.guava:guava")
testImplementation("org.slf4j:slf4j-simple")
Expand Down
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";
}
}
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"));
}
}
5 changes: 5 additions & 0 deletions dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ val DEPENDENCY_BOMS = listOf(
)

val DEPENDENCY_SETS = listOf(
DependencySet(
"com.google.auto.service",
"1.0",
listOf("auto-service", "auto-service-annotations")
),
DependencySet(
"com.google.auto.value",
"1.8.1",
Expand Down

0 comments on commit e1050fa

Please sign in to comment.