-
Notifications
You must be signed in to change notification settings - Fork 853
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to opentelemetry-configuration v0.1.0 (#5899)
- Loading branch information
Showing
8 changed files
with
148 additions
and
45 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
37 changes: 37 additions & 0 deletions
37
.../src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactory.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,37 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.extension.incubator.fileconfig; | ||
|
||
import io.opentelemetry.context.propagation.ContextPropagators; | ||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; | ||
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Propagator; | ||
import java.io.Closeable; | ||
import java.util.List; | ||
import javax.annotation.Nullable; | ||
|
||
final class PropagatorFactory implements Factory<Propagator, ContextPropagators> { | ||
|
||
private static final PropagatorFactory INSTANCE = new PropagatorFactory(); | ||
|
||
private PropagatorFactory() {} | ||
|
||
static PropagatorFactory getInstance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public ContextPropagators create( | ||
@Nullable Propagator model, SpiHelper spiHelper, List<Closeable> closeables) { | ||
List<String> compositeModel = null; | ||
if (model != null) { | ||
compositeModel = model.getComposite(); | ||
} | ||
TextMapPropagator textMapPropagator = | ||
TextMapPropagatorFactory.getInstance().create(compositeModel, spiHelper, closeables); | ||
return ContextPropagators.create(textMapPropagator); | ||
} | ||
} |
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
60 changes: 60 additions & 0 deletions
60
.../test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactoryTest.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,60 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.extension.incubator.fileconfig; | ||
|
||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; | ||
|
||
import io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator; | ||
import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; | ||
import io.opentelemetry.context.propagation.ContextPropagators; | ||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.extension.trace.propagation.B3Propagator; | ||
import io.opentelemetry.extension.trace.propagation.JaegerPropagator; | ||
import io.opentelemetry.extension.trace.propagation.OtTracePropagator; | ||
import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; | ||
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Propagator; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.stream.Stream; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
class PropagatorFactoryTest { | ||
|
||
private final SpiHelper spiHelper = | ||
SpiHelper.create(PropagatorFactoryTest.class.getClassLoader()); | ||
|
||
@ParameterizedTest | ||
@MethodSource("createArguments") | ||
void create(Propagator model, ContextPropagators expectedPropagators) { | ||
ContextPropagators propagators = | ||
PropagatorFactory.getInstance().create(model, spiHelper, Collections.emptyList()); | ||
|
||
assertThat(propagators.toString()).isEqualTo(expectedPropagators.toString()); | ||
} | ||
|
||
private static Stream<Arguments> createArguments() { | ||
return Stream.of( | ||
Arguments.of( | ||
null, | ||
ContextPropagators.create( | ||
TextMapPropagator.composite( | ||
W3CTraceContextPropagator.getInstance(), W3CBaggagePropagator.getInstance()))), | ||
Arguments.of( | ||
new Propagator() | ||
.withComposite( | ||
Arrays.asList("tracecontext", "baggage", "ottrace", "b3multi", "b3", "jaeger")), | ||
ContextPropagators.create( | ||
TextMapPropagator.composite( | ||
W3CTraceContextPropagator.getInstance(), | ||
W3CBaggagePropagator.getInstance(), | ||
OtTracePropagator.getInstance(), | ||
B3Propagator.injectingMultiHeaders(), | ||
B3Propagator.injectingSingleHeader(), | ||
JaegerPropagator.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