-
Notifications
You must be signed in to change notification settings - Fork 955
Promote ComponentLoader to new opentelemetry-api-util, standardize SPI loading #7446
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
Merged
jack-berg
merged 8 commits into
open-telemetry:main
from
jack-berg:promote-component-loader
Jul 10, 2025
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
21d7756
Promote ComponentLoader to opentelemetry-context, standardize SPI loa…
jack-berg d6f7a42
Remove default implementation
jack-berg a7ce48f
Push autoconfigured component loader to ConfigProperties, Declarative…
jack-berg 2f31d3f
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 84767aa
Break out opentelemetry-api-util artifact
jack-berg d2f36c1
change from opentelemetry-api-util to opentelemetry-common
jack-berg ec9e528
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg da46069
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
jack-berg 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
28 changes: 28 additions & 0 deletions
28
context/src/main/java/io/opentelemetry/context/ComponentLoader.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,28 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.context; | ||
|
|
||
| import java.util.ServiceLoader; | ||
|
|
||
| /** A loader for components that are discovered via SPI. */ | ||
| public interface ComponentLoader { | ||
| /** | ||
| * Load implementations of an SPI. | ||
| * | ||
| * @param spiClass the SPI class | ||
| * @param <T> the SPI type | ||
| * @return iterable of SPI implementations | ||
| */ | ||
| <T> Iterable<T> load(Class<T> spiClass); | ||
|
|
||
| /** | ||
| * Create an instance for the {@code classLoader} using {@link ServiceLoader#load(Class, | ||
| * ClassLoader)}. | ||
| */ | ||
| static ComponentLoader forClassLoader(ClassLoader classLoader) { | ||
| return new ServiceLoaderComponentLoader(classLoader); | ||
| } | ||
| } |
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
27 changes: 27 additions & 0 deletions
27
context/src/main/java/io/opentelemetry/context/ServiceLoaderComponentLoader.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,27 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.context; | ||
|
|
||
| import java.util.ServiceLoader; | ||
|
|
||
| class ServiceLoaderComponentLoader implements ComponentLoader { | ||
|
|
||
| private final ClassLoader classLoader; | ||
|
|
||
| ServiceLoaderComponentLoader(ClassLoader classLoader) { | ||
| this.classLoader = classLoader; | ||
| } | ||
|
|
||
| @Override | ||
| public <T> Iterable<T> load(Class<T> spiClass) { | ||
| return ServiceLoader.load(spiClass, classLoader); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "ServiceLoaderComponentLoader{classLoader=" + classLoader + "}"; | ||
| } | ||
| } |
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,7 @@ | ||
| Comparing source compatibility of opentelemetry-context-1.52.0-SNAPSHOT.jar against opentelemetry-context-1.51.0.jar | ||
| No changes. | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.context.ComponentLoader (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.context.ComponentLoader forClassLoader(java.lang.ClassLoader) | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Iterable<T> load(java.lang.Class<T>) | ||
| GENERIC TEMPLATES: +++ T:java.lang.Object | ||
19 changes: 18 additions & 1 deletion
19
docs/apidiffs/current_vs_latest/opentelemetry-exporter-otlp.txt
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,19 @@ | ||
| Comparing source compatibility of opentelemetry-exporter-otlp-1.52.0-SNAPSHOT.jar against opentelemetry-exporter-otlp-1.51.0.jar | ||
| No changes. | ||
| *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.logs.OtlpHttpLogRecordExporterBuilder setComponentLoader(io.opentelemetry.context.ComponentLoader) | ||
| *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporterBuilder setComponentLoader(io.opentelemetry.context.ComponentLoader) | ||
| *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder setComponentLoader(io.opentelemetry.context.ComponentLoader) | ||
| *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.logs.OtlpGrpcLogRecordExporterBuilder setComponentLoader(io.opentelemetry.context.ComponentLoader) | ||
| *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.metrics.OtlpGrpcMetricExporterBuilder setComponentLoader(io.opentelemetry.context.ComponentLoader) | ||
| *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder setComponentLoader(io.opentelemetry.context.ComponentLoader) |
4 changes: 3 additions & 1 deletion
4
docs/apidiffs/current_vs_latest/opentelemetry-sdk-extension-autoconfigure-spi.txt
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,4 @@ | ||
| Comparing source compatibility of opentelemetry-sdk-extension-autoconfigure-spi-1.52.0-SNAPSHOT.jar against opentelemetry-sdk-extension-autoconfigure-spi-1.51.0.jar | ||
| No changes. | ||
| *** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.context.ComponentLoader getComponentLoader() |
4 changes: 3 additions & 1 deletion
4
docs/apidiffs/current_vs_latest/opentelemetry-sdk-extension-autoconfigure.txt
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,4 @@ | ||
| Comparing source compatibility of opentelemetry-sdk-extension-autoconfigure-1.52.0-SNAPSHOT.jar against opentelemetry-sdk-extension-autoconfigure-1.51.0.jar | ||
| No changes. | ||
| *** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder setComponentLoader(io.opentelemetry.context.ComponentLoader) |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
FYI new API surface area @jkwatson