-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add file configuration ComponentProvider support for propagators (#6624)
- Loading branch information
Showing
10 changed files
with
233 additions
and
23 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
.../main/java/io/opentelemetry/extension/trace/propagation/internal/B3ComponentProvider.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,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.extension.trace.propagation.internal; | ||
|
||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.extension.trace.propagation.B3Propagator; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties; | ||
|
||
/** | ||
* File configuration SPI implementation for {@link B3Propagator} which allows enables the {@link | ||
* B3Propagator#injectingSingleHeader()}. | ||
* | ||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public final class B3ComponentProvider implements ComponentProvider<TextMapPropagator> { | ||
|
||
@Override | ||
public Class<TextMapPropagator> getType() { | ||
return TextMapPropagator.class; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "b3"; | ||
} | ||
|
||
@Override | ||
public TextMapPropagator create(StructuredConfigProperties config) { | ||
return B3Propagator.injectingSingleHeader(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../java/io/opentelemetry/extension/trace/propagation/internal/B3MultiComponentProvider.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,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.extension.trace.propagation.internal; | ||
|
||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.extension.trace.propagation.B3Propagator; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties; | ||
|
||
/** | ||
* File configuration SPI implementation for {@link B3Propagator} which allows enables the {@link | ||
* B3Propagator#injectingMultiHeaders()}. | ||
* | ||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public final class B3MultiComponentProvider implements ComponentProvider<TextMapPropagator> { | ||
|
||
@Override | ||
public Class<TextMapPropagator> getType() { | ||
return TextMapPropagator.class; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "b3multi"; | ||
} | ||
|
||
@Override | ||
public TextMapPropagator create(StructuredConfigProperties config) { | ||
return B3Propagator.injectingMultiHeaders(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...n/java/io/opentelemetry/extension/trace/propagation/internal/JaegerComponentProvider.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,35 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.extension.trace.propagation.internal; | ||
|
||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.extension.trace.propagation.JaegerPropagator; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties; | ||
|
||
/** | ||
* File configuration SPI implementation for {@link JaegerPropagator}. | ||
* | ||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public final class JaegerComponentProvider implements ComponentProvider<TextMapPropagator> { | ||
|
||
@Override | ||
public Class<TextMapPropagator> getType() { | ||
return TextMapPropagator.class; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "jaeger"; | ||
} | ||
|
||
@Override | ||
public TextMapPropagator create(StructuredConfigProperties config) { | ||
return JaegerPropagator.getInstance(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../java/io/opentelemetry/extension/trace/propagation/internal/OtTraceComponentProvider.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,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.extension.trace.propagation.internal; | ||
|
||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.extension.trace.propagation.B3Propagator; | ||
import io.opentelemetry.extension.trace.propagation.OtTracePropagator; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties; | ||
|
||
/** | ||
* File configuration SPI implementation for {@link B3Propagator}. | ||
* | ||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public final class OtTraceComponentProvider implements ComponentProvider<TextMapPropagator> { | ||
|
||
@Override | ||
public Class<TextMapPropagator> getType() { | ||
return TextMapPropagator.class; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "ottrace"; | ||
} | ||
|
||
@Override | ||
public TextMapPropagator create(StructuredConfigProperties config) { | ||
return OtTracePropagator.getInstance(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...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,4 @@ | ||
io.opentelemetry.extension.trace.propagation.internal.B3ComponentProvider | ||
io.opentelemetry.extension.trace.propagation.internal.B3MultiComponentProvider | ||
io.opentelemetry.extension.trace.propagation.internal.JaegerComponentProvider | ||
io.opentelemetry.extension.trace.propagation.internal.OtTraceComponentProvider |
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
55 changes: 55 additions & 0 deletions
55
...etry/sdk/extension/incubator/fileconfig/component/TextMapPropagatorComponentProvider.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,55 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.extension.incubator.fileconfig.component; | ||
|
||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.context.propagation.TextMapGetter; | ||
import io.opentelemetry.context.propagation.TextMapPropagator; | ||
import io.opentelemetry.context.propagation.TextMapSetter; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import javax.annotation.Nullable; | ||
|
||
public class TextMapPropagatorComponentProvider implements ComponentProvider<TextMapPropagator> { | ||
@Override | ||
public Class<TextMapPropagator> getType() { | ||
return TextMapPropagator.class; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "test"; | ||
} | ||
|
||
@Override | ||
public TextMapPropagator create(StructuredConfigProperties config) { | ||
return new TestTextMapPropagator(config); | ||
} | ||
|
||
public static class TestTextMapPropagator implements TextMapPropagator { | ||
|
||
public final StructuredConfigProperties config; | ||
|
||
private TestTextMapPropagator(StructuredConfigProperties config) { | ||
this.config = config; | ||
} | ||
|
||
@Override | ||
public Collection<String> fields() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public <C> void inject(Context context, @Nullable C carrier, TextMapSetter<C> setter) {} | ||
|
||
@Override | ||
public <C> Context extract(Context context, @Nullable C carrier, TextMapGetter<C> getter) { | ||
return context; | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...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