-
Notifications
You must be signed in to change notification settings - Fork 999
add missing declarative config resource providers #14222
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
trask
merged 29 commits into
open-telemetry:main
from
zeitlinger:declarative-config-resource-providers
Sep 11, 2025
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
cf9d250
add missing declarative config resource providers
zeitlinger 70cc64c
add missing declarative config resource providers
zeitlinger cadc237
add missing declarative config resource providers
zeitlinger a128a8f
prevent that view config file is loaded
zeitlinger 677bf18
pr review
zeitlinger b594dfb
add docs
zeitlinger 6219ad9
pr feedback
zeitlinger 9ffb655
pr review
zeitlinger acce028
fix
zeitlinger e082955
pr feedback
zeitlinger 27d6dc7
pr feedback
zeitlinger 582adac
separate resource extraction from supported interfaces
zeitlinger e242758
separate resource extraction from supported interfaces
zeitlinger 40a3106
separate resource extraction from supported interfaces
zeitlinger 7a0a61e
separate resource extraction from supported interfaces
zeitlinger 850a699
./gradlew spotlessApply
otelbot[bot] a33147f
fix
zeitlinger 550bc66
fix rebase
zeitlinger 77f3fbc
./gradlew spotlessApply
otelbot[bot] dd20147
set enabled in test
zeitlinger b2b21db
add smoke test
zeitlinger 194d2cb
add smoke test
zeitlinger 03ef3ed
pr review
zeitlinger db3a54a
pr review
zeitlinger c69a836
pr review
zeitlinger a47828c
pr review
zeitlinger 48a4105
pr review
zeitlinger b808538
pr review
zeitlinger 3a44358
pr review
zeitlinger 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
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
15 changes: 0 additions & 15 deletions
15
...es/library/src/main/java/io/opentelemetry/instrumentation/resources/ProcessArguments.java
This file was deleted.
Oops, something went wrong.
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
23 changes: 23 additions & 0 deletions
23
...ava/io/opentelemetry/instrumentation/resources/internal/JarResourceComponentProvider.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,23 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.resources.internal; | ||
|
||
import com.google.auto.service.AutoService; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
|
||
/** | ||
* Declarative config jar resource provider. | ||
* | ||
* <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 JarResourceComponentProvider extends ResourceComponentProvider { | ||
public JarResourceComponentProvider() { | ||
super("jar", p -> new JarServiceNameResourceExtractor().extract()); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
.../io/opentelemetry/instrumentation/resources/internal/JarServiceNameResourceExtractor.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,63 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.resources.internal; | ||
|
||
import static java.util.logging.Level.FINE; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.sdk.resources.Resource; | ||
import io.opentelemetry.semconv.ServiceAttributes; | ||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
import java.util.function.Supplier; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* A resource extractor that will attempt to detect the <code>service.name</code> from the main jar | ||
* file name. | ||
* | ||
* <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 JarServiceNameResourceExtractor { | ||
|
||
private static final Logger logger = | ||
Logger.getLogger(JarServiceNameResourceExtractor.class.getName()); | ||
|
||
private final Supplier<Optional<Path>> jarPathSupplier; | ||
|
||
public JarServiceNameResourceExtractor() { | ||
this(MainJarPathHolder::getJarPath); | ||
} | ||
|
||
// visible for tests | ||
JarServiceNameResourceExtractor(MainJarPathFinder jarPathFinder) { | ||
this(() -> Optional.ofNullable(jarPathFinder.detectJarPath())); | ||
} | ||
|
||
private JarServiceNameResourceExtractor(Supplier<Optional<Path>> jarPathSupplier) { | ||
this.jarPathSupplier = jarPathSupplier; | ||
} | ||
|
||
public Resource extract() { | ||
return jarPathSupplier | ||
.get() | ||
.map( | ||
jarPath -> { | ||
String serviceName = getServiceName(jarPath); | ||
logger.log( | ||
FINE, "Auto-detected service name from the jar file name: {0}", serviceName); | ||
return Resource.create(Attributes.of(ServiceAttributes.SERVICE_NAME, serviceName)); | ||
}) | ||
.orElseGet(Resource::empty); | ||
} | ||
|
||
private static String getServiceName(Path jarPath) { | ||
String jarName = jarPath.getFileName().toString(); | ||
int dotIndex = jarName.lastIndexOf("."); | ||
return dotIndex == -1 ? jarName : jarName.substring(0, dotIndex); | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
...o/opentelemetry/instrumentation/resources/internal/ManifestResourceComponentProvider.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,23 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.resources.internal; | ||
|
||
import com.google.auto.service.AutoService; | ||
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider; | ||
|
||
/** | ||
* Declarative config manifest resource provider. | ||
* | ||
* <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 ManifestResourceComponentProvider extends ResourceComponentProvider { | ||
public ManifestResourceComponentProvider() { | ||
super("manifest", p -> new ManifestResourceExtractor().extract()); | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.