Skip to content

Commit

Permalink
Deprecate old extensions (#3825)
Browse files Browse the repository at this point in the history
* Introduce stable property for external extensions

* Update docs to use stable extension property.

Also log a warning if deprecated otel.javaagent.experimental.exporter.jar is used.

* Format

* Format

* Polish
  • Loading branch information
iNikem authored Aug 25, 2021
1 parent c0aad71 commit 28db0c3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/agent-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You can enable [extensions](../examples/extension/README.md) by setting the corr

| System property | Environment variable | Description |
|--------------------------------------|--------------------------------------|----------------------------------------------------------------------------------|
| `otel.javaagent.experimental.extensions` | `OTEL_JAVAAGENT_EXPERIMENTAL_EXTENSIONS` | Path to a an extension jar file or folder, containing jar files. If pointing to a folder, every jar file in that folder will be treated as separate, independent extension|
| `otel.javaagent.extensions` | `OTEL_JAVAAGENT_EXTENSIONS` | Path to a an extension jar file or folder, containing jar files. If pointing to a folder, every jar file in that folder will be treated as separate, independent extension|

## Peer service name

Expand Down
4 changes: 2 additions & 2 deletions examples/extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ To add the extension to the instrumentation agent:

```bash
java -javaagent:path/to/opentelemetry-javaagent-all.jar \
-Dotel.javaagent.experimental.extensions=build/libs/opentelemetry-java-instrumentation-extension-demo-1.0-all.jar
-Dotel.javaagent.extensions=build/libs/opentelemetry-java-instrumentation-extension-demo-1.0-all.jar
-jar myapp.jar
```
## Embed extensions in the OpenTelemetry Agent

To simplify deployment, you can embed extensions into the OpenTelemetry Java Agent to produce a single jar file. With an integrated extension, you no longer need the `-Dotel.javaagent.experimental.extensions` command line option.
To simplify deployment, you can embed extensions into the OpenTelemetry Java Agent to produce a single jar file. With an integrated extension, you no longer need the `-Dotel.javaagent.extensions` command line option.

For more information, see the `extendedAgent` task in [build.gradle](build.gradle).
## Extensions examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private GenericContainer<?> buildTargetContainer(String agentPath, String extens
//Asks instrumentation agent to include extensions from given location into its runtime
result = result.withCopyFileToContainer(
MountableFile.forHostPath(extensionPath), "/opentelemetry-extensions.jar")
.withEnv("OTEL_JAVAAGENT_EXPERIMENTAL_EXTENSIONS", extensionLocation);
.withEnv("OTEL_JAVAAGENT_EXTENSIONS", extensionLocation);
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ private static void maybeConfigureExporterJar(SdkTracerProviderBuilder sdkTracer
installExportersFromJar(exporterJar, config, sdkTracerProviderBuilder);
}

// TODO remove in 1.6
private static synchronized void installExportersFromJar(
String exporterJar, Config config, SdkTracerProviderBuilder builder) {
logger.warn(
"{} is deprecated and will be removed soon! Please use {}",
EXPORTER_JAR_CONFIG,
ExtensionClassLoader.EXTENSIONS_CONFIG);
URL url;
try {
url = new File(exporterJar).toURI().toURL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
// Used by AgentInitializer
@SuppressWarnings({"unused", "SystemOut"})
public class ExtensionClassLoader extends URLClassLoader {
public static final String EXTENSIONS_CONFIG = "otel.javaagent.extensions";

// NOTE it's important not to use slf4j in this class, because this class is used before slf4j is
// configured, and so using slf4j here would initialize slf4j-simple before we have a chance to
// configure the logging levels
Expand All @@ -47,12 +49,11 @@ public static ClassLoader getInstance(ClassLoader parent, File javaagentFile) {

includeEmbeddedExtensionsIfFound(parent, extensions, javaagentFile);

// TODO add support for old deprecated property otel.javaagent.experimental.exporter.jar
extensions.addAll(
parseLocation(
System.getProperty(
"otel.javaagent.extensions", System.getenv("OTEL_JAVAAGENT_EXTENSIONS")),
System.getProperty(EXTENSIONS_CONFIG, System.getenv("OTEL_JAVAAGENT_EXTENSIONS")),
javaagentFile));

extensions.addAll(
parseLocation(
System.getProperty(
Expand Down

0 comments on commit 28db0c3

Please sign in to comment.