-
Notifications
You must be signed in to change notification settings - Fork 987
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
Open
zeitlinger
wants to merge
19
commits into
open-telemetry:main
Choose a base branch
from
zeitlinger:declarative-config-resource-providers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ee6a060
add missing declarative config resource providers
zeitlinger f97ff6c
add missing declarative config resource providers
zeitlinger b8192f8
add missing declarative config resource providers
zeitlinger fb8b36b
prevent that view config file is loaded
zeitlinger 3025ed2
pr review
zeitlinger 0a7c386
add docs
zeitlinger 5d394da
pr feedback
zeitlinger cdf6bf0
pr review
zeitlinger 26301e3
fix
zeitlinger a3c1b1e
pr feedback
zeitlinger d872805
pr feedback
zeitlinger 5a0de64
separate resource extraction from supported interfaces
zeitlinger 29d7938
separate resource extraction from supported interfaces
zeitlinger 1ed3b6b
separate resource extraction from supported interfaces
zeitlinger 74bce68
separate resource extraction from supported interfaces
zeitlinger 53de0ea
./gradlew spotlessApply
otelbot[bot] 1879f99
fix
zeitlinger 27bcee2
fix rebase
zeitlinger 6833b99
./gradlew spotlessApply
otelbot[bot] 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.