-
Couldn't load subscription status.
- Fork 168
add declarative config support for AWS X-Ray #2296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
zeitlinger
wants to merge
4
commits into
open-telemetry:main
Choose a base branch
from
zeitlinger:declarative-config-xray-sampler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
45 changes: 45 additions & 0 deletions
45
...src/main/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerComponentProvider.java
This file contains hidden or 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,45 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.contrib.awsxray; | ||
|
|
||
| import com.google.auto.service.AutoService; | ||
| import io.opentelemetry.api.incubator.config.DeclarativeConfigProperties; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
| import io.opentelemetry.sdk.resources.Resource; | ||
| import io.opentelemetry.sdk.trace.samplers.Sampler; | ||
|
|
||
| /** | ||
| * File configuration SPI implementation for {@link AwsXrayRemoteSampler}. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| @SuppressWarnings("rawtypes") | ||
| @AutoService(ComponentProvider.class) | ||
| public class AwsXrayRemoteSamplerComponentProvider implements ComponentProvider<Sampler> { | ||
| @Override | ||
| public Class<Sampler> getType() { | ||
| return Sampler.class; | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "xray"; | ||
| } | ||
|
|
||
| @Override | ||
| public Sampler create(DeclarativeConfigProperties config) { | ||
| Resource resource = io.opentelemetry.contrib.awsxray.ResourceHolder.getResource(); | ||
| AwsXrayRemoteSamplerBuilder builder = AwsXrayRemoteSampler.newBuilder(resource); | ||
|
|
||
| String endpoint = config.getString("endpoint"); | ||
| if (endpoint != null) { | ||
| builder.setEndpoint(endpoint); | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
...test/java/io/opentelemetry/contrib/awsxray/AwsXrayRemoteSamplerComponentProviderTest.java
This file contains hidden or 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,33 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.contrib.awsxray; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import io.opentelemetry.sdk.OpenTelemetrySdk; | ||
| import io.opentelemetry.sdk.extension.incubator.fileconfig.DeclarativeConfiguration; | ||
| import java.io.ByteArrayInputStream; | ||
| import java.nio.charset.StandardCharsets; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class AwsXrayRemoteSamplerComponentProviderTest { | ||
| @Test | ||
| void endToEnd() { | ||
| String yaml = | ||
| "file_format: 1.0-rc.1\n" | ||
| + "tracer_provider:\n" | ||
| + " sampler:\n" | ||
| + " xray:\n" | ||
| + " endpoint: 'https://example.com'\n"; | ||
|
|
||
| OpenTelemetrySdk openTelemetrySdk = | ||
| DeclarativeConfiguration.parseAndCreate( | ||
| new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8))); | ||
|
|
||
| assertThat(openTelemetrySdk.getSdkTracerProvider().toString()) | ||
| .contains("AwsXrayRemoteSampler{endpoint=https://example.com}"); | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,2 +1,11 @@ | ||
| Comparing source compatibility of opentelemetry-aws-xray-1.51.0-SNAPSHOT.jar against opentelemetry-aws-xray-1.50.0.jar | ||
| No changes. | ||
| *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.contrib.awsxray.AwsXrayRemoteSampler (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) java.lang.String toString() | ||
| +++ NEW CLASS: PUBLIC(+) io.opentelemetry.contrib.awsxray.AwsXrayRemoteSamplerComponentProvider (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW CONSTRUCTOR: PUBLIC(+) AwsXrayRemoteSamplerComponentProvider() | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.trace.samplers.Sampler create(io.opentelemetry.api.incubator.config.DeclarativeConfigProperties) | ||
| +++ NEW METHOD: PUBLIC(+) java.lang.String getName() | ||
| +++ NEW METHOD: PUBLIC(+) java.lang.Class<io.opentelemetry.sdk.trace.samplers.Sampler> getType() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these be part of the public api?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to internal