-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename ComponentInstaller to AgentListener and add #order() method (#…
…3182) * Rename ComponentInstaller to AgentListener and add #order() method * Code review comments * Update javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/SafeServiceLoader.java Co-authored-by: Nikita Salnikov-Tarnovski <[email protected]> Co-authored-by: Nikita Salnikov-Tarnovski <[email protected]>
- Loading branch information
Showing
14 changed files
with
143 additions
and
151 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
...agent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/AgentListener.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,39 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.extension; | ||
|
||
import io.opentelemetry.instrumentation.api.config.Config; | ||
import io.opentelemetry.javaagent.instrumentation.api.InstrumentationContext; | ||
import java.lang.instrument.Instrumentation; | ||
import java.util.Map; | ||
import net.bytebuddy.agent.builder.AgentBuilder; | ||
|
||
/** | ||
* {@link AgentListener} can be used to execute code before/after Java agent installation, for | ||
* example to install any implementation providers that are used by instrumentations. For instance, | ||
* this project uses this SPI to install OpenTelemetry SDK. | ||
* | ||
* <p>This is a service provider interface that requires implementations to be registered in a | ||
* provider-configuration file stored in the {@code META-INF/services} resource directory. | ||
*/ | ||
public interface AgentListener extends Ordered { | ||
|
||
/** | ||
* Runs before the {@link AgentBuilder} construction, before any instrumentation is added. | ||
* | ||
* <p>Execute only a minimal code because any classes loaded before the agent installation will | ||
* have to be retransformed, which takes extra time, and more importantly means that fields can't | ||
* be added to those classes - which causes {@link InstrumentationContext} to fall back to the | ||
* less performant {@link Map} implementation for those classes. | ||
*/ | ||
default void beforeAgent(Config config) {} | ||
|
||
/** | ||
* Runs after instrumentations are added to {@link AgentBuilder} and after the agent is installed | ||
* on an {@link Instrumentation}. | ||
*/ | ||
default void afterAgent(Config config) {} | ||
} |
16 changes: 16 additions & 0 deletions
16
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/extension/Ordered.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,16 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.extension; | ||
|
||
public interface Ordered { | ||
/** | ||
* Returns the order of applying the SPI implementing this interface. Higher values are added | ||
* later, for example: an SPI with order=1 will run after an SPI with order=0. | ||
*/ | ||
default int order() { | ||
return 0; | ||
} | ||
} |
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
34 changes: 0 additions & 34 deletions
34
javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/spi/ComponentInstaller.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.