forked from open-telemetry/opentelemetry-java-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add declarative config support for aws xray propagators (open-telemet…
- Loading branch information
Showing
10 changed files
with
109 additions
and
3 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
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
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
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
28 changes: 28 additions & 0 deletions
28
...n/java/io/opentelemetry/contrib/awsxray/propagator/internal/AwsXrayComponentProvider.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,28 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.contrib.awsxray.propagator.internal; | ||
|
||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayPropagator; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties; | ||
|
||
public class AwsXrayComponentProvider implements ComponentProvider<TextMapPropagator> { | ||
@Override | ||
public Class<TextMapPropagator> getType() { | ||
return TextMapPropagator.class; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "xray"; | ||
} | ||
|
||
@Override | ||
public TextMapPropagator create(StructuredConfigProperties config) { | ||
return AwsXrayPropagator.getInstance(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.../io/opentelemetry/contrib/awsxray/propagator/internal/AwsXrayLambdaComponentProvider.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,28 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.contrib.awsxray.propagator.internal; | ||
|
||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayLambdaPropagator; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties; | ||
|
||
public class AwsXrayLambdaComponentProvider implements ComponentProvider<TextMapPropagator> { | ||
@Override | ||
public Class<TextMapPropagator> getType() { | ||
return TextMapPropagator.class; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "xray-lambda"; | ||
} | ||
|
||
@Override | ||
public TextMapPropagator create(StructuredConfigProperties config) { | ||
return AwsXrayLambdaPropagator.getInstance(); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...s/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ConfigurablePropagatorProvider
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 |
---|---|---|
@@ -1 +1 @@ | ||
io.opentelemetry.contrib.awsxray.propagator.AwsConfigurablePropagator | ||
io.opentelemetry.contrib.awsxray.propagator.internal.AwsConfigurablePropagator |
2 changes: 2 additions & 0 deletions
2
...urces/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider
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,2 @@ | ||
io.opentelemetry.contrib.awsxray.propagator.internal.AwsXrayComponentProvider | ||
io.opentelemetry.contrib.awsxray.propagator.internal.AwsXrayLambdaComponentProvider |
34 changes: 34 additions & 0 deletions
34
...t/java/io/opentelemetry/contrib/awsxray/propagator/internal/AwsComponentProviderTest.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,34 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.contrib.awsxray.propagator.internal; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayLambdaPropagator; | ||
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayPropagator; | ||
import io.opentelemetry.sdk.OpenTelemetrySdk; | ||
import io.opentelemetry.sdk.extension.incubator.fileconfig.FileConfiguration; | ||
import java.io.ByteArrayInputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class AwsComponentProviderTest { | ||
|
||
@Test | ||
void endToEnd() { | ||
String yaml = "file_format: 0.1\n" + "propagator:\n" + " composite: [xray, xray-lambda]\n"; | ||
|
||
OpenTelemetrySdk openTelemetrySdk = | ||
FileConfiguration.parseAndCreate( | ||
new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8))); | ||
TextMapPropagator expectedPropagator = | ||
TextMapPropagator.composite( | ||
AwsXrayPropagator.getInstance(), AwsXrayLambdaPropagator.getInstance()); | ||
assertThat(openTelemetrySdk.getPropagators().getTextMapPropagator().toString()) | ||
.isEqualTo(expectedPropagator.toString()); | ||
} | ||
} |