-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ComponentInstaller SPI and use it for OpenTelemetry SDK (#1848)
* Add component installer SPI Signed-off-by: Pavol Loffay <[email protected]> * Move more code to agent installer Signed-off-by: Pavol Loffay <[email protected]>
- Loading branch information
1 parent
785cb91
commit f69217e
Showing
8 changed files
with
294 additions
and
218 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
32 changes: 32 additions & 0 deletions
32
javaagent-spi/src/main/java/io/opentelemetry/javaagent/spi/ComponentInstaller.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,32 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.spi; | ||
|
||
/** | ||
* {@link ComponentInstaller} can be used to install any implementation providers that are used by | ||
* instrumentations. For instance Java agent uses this to install OpenTelemetry SDK. The | ||
* instrumentation uses shaded OpenTelemetry API that lives in the bootstrap classlaoder and the | ||
* implementation (SDK) is installed via service loader from agent's classloader. This way the | ||
* application does not have a direct access to the OpenTelemetry SDK classes. The same approach can | ||
* be done for other APIs used by custom instrumentations. | ||
* | ||
* <p>This is a service provider interface that requires implementations to be registered in {@code | ||
* META-INF/services} folder. | ||
*/ | ||
public interface ComponentInstaller { | ||
|
||
/** | ||
* Runs before instrumentations are installed to ByteBuddy. Execute only a minimal code because | ||
* any classes loaded before the instrumentations are installed will have to be retransformed, | ||
* which takes extra time, and more importantly means that fields can't be added to those classes | ||
* and InstrumentationContext falls back to the less performant Map implementation for those | ||
* classes. | ||
*/ | ||
void beforeByteBuddyAgent(); | ||
|
||
/** Runs after instrumentations are added to ByteBuddy. */ | ||
void afterByteBuddyAgent(); | ||
} |
Oops, something went wrong.