-
Notifications
You must be signed in to change notification settings - Fork 1k
indy instrumentation - leftovers migration #13074
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
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c911faa
lambda
SylvainJuge 26e79f9
inject proxies for indy
SylvainJuge 7f3ae3b
kotlinx + integration tests
SylvainJuge 9183992
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-i…
SylvainJuge 29c99dd
inject missing classes for indy
SylvainJuge 45ead47
do not inject proxies for lambda
SylvainJuge ba30ba8
move back comment in the expected location
SylvainJuge eb945b8
remove duplication
SylvainJuge eba7e20
add jpms compatible class file transformer
SylvainJuge 7a1cbc7
remove lambda java9 module
SylvainJuge 590f86e
fix pebkc
SylvainJuge a8cbb24
fix lambda instrumentation, must not redefine them
SylvainJuge 403caaa
fix javadoc
SylvainJuge 506cc62
fix things again
SylvainJuge da1c13d
fix it again
SylvainJuge c4350d0
make the comments a bit better
SylvainJuge 1d54a14
fix typo
SylvainJuge 03aa810
avoid injecting classes for kotlinxcoroutines
SylvainJuge 2ed4e96
remove commented code
SylvainJuge 77a4f00
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-i…
SylvainJuge d9cd13f
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-i…
SylvainJuge 5e2ef89
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-i…
SylvainJuge 20856e3
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-i…
SylvainJuge a38763f
revert commented code that was there for a reason
SylvainJuge b77428c
add LambdaTransformer interface + rename things
SylvainJuge bc785b9
fix typos and comments
SylvainJuge 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
38 changes: 0 additions & 38 deletions
38
...tstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/ClassFileTransformerHolder.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...agent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/LambdaTransformer.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,24 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.bootstrap; | ||
|
||
import java.lang.instrument.IllegalClassFormatException; | ||
|
||
/** Transformer for lambda bytecode */ | ||
public interface LambdaTransformer { | ||
|
||
/** | ||
* Transforms lambda bytecode for instrumentation | ||
* | ||
* @param className class name in JVM format with slashes | ||
* @param targetClass target class, must not be {@literal null} | ||
* @param classfileBuffer target class bytecode | ||
* @return instrumented lambda bytecode | ||
* @throws IllegalClassFormatException if bytecode is invalid | ||
*/ | ||
byte[] transform(String className, Class<?> targetClass, byte[] classfileBuffer) | ||
throws IllegalClassFormatException; | ||
} |
36 changes: 36 additions & 0 deletions
36
...bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/LambdaTransformerHolder.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,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.bootstrap; | ||
|
||
/** | ||
* Holder for {@link LambdaTransformer} used by the instrumentation. Calling transform on this | ||
* transformer processes given bytes the same way as they would be processed during loading of the | ||
* class. | ||
*/ | ||
public final class LambdaTransformerHolder { | ||
|
||
private static volatile LambdaTransformer lambdaTransformer; | ||
|
||
/** | ||
* get lambda transformer | ||
* | ||
* @return class transformer for defining lambdas | ||
*/ | ||
public static LambdaTransformer setLambdaTransformer() { | ||
return lambdaTransformer; | ||
} | ||
|
||
/** | ||
* set lambda transformer | ||
* | ||
* @param transformer transformer | ||
*/ | ||
public static void setLambdaTransformer(LambdaTransformer transformer) { | ||
lambdaTransformer = transformer; | ||
} | ||
|
||
private LambdaTransformerHolder() {} | ||
} |
42 changes: 0 additions & 42 deletions
42
...va9/src/main/java/io/opentelemetry/javaagent/tooling/Java9LambdaClassFileTransformer.java
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...ooling-java9/src/main/java/io/opentelemetry/javaagent/tooling/Java9LambdaTransformer.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,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.tooling; | ||
|
||
import io.opentelemetry.javaagent.bootstrap.LambdaTransformer; | ||
import java.lang.instrument.ClassFileTransformer; | ||
import java.lang.instrument.IllegalClassFormatException; | ||
|
||
/** lambda transformer with java9 jpms module compatibility */ | ||
public class Java9LambdaTransformer implements LambdaTransformer { | ||
|
||
private final ClassFileTransformer delegate; | ||
|
||
public Java9LambdaTransformer(ClassFileTransformer delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public byte[] transform(String className, Class<?> targetClass, byte[] classfileBuffer) | ||
throws IllegalClassFormatException { | ||
|
||
// lambda instrumentation happens only when the lambda is defined, thus the classBeingRedefined | ||
SylvainJuge marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// must be null otherwise we get a partial instrumentation, for example virtual fields are not | ||
// properly applied | ||
return delegate.transform( | ||
targetClass.getModule(), | ||
targetClass.getClassLoader(), | ||
className, | ||
null, | ||
null, | ||
classfileBuffer); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -21,9 +21,10 @@ | |
import io.opentelemetry.instrumentation.api.internal.EmbeddedInstrumentationProperties; | ||
import io.opentelemetry.javaagent.bootstrap.AgentClassLoader; | ||
import io.opentelemetry.javaagent.bootstrap.BootstrapPackagePrefixesHolder; | ||
import io.opentelemetry.javaagent.bootstrap.ClassFileTransformerHolder; | ||
import io.opentelemetry.javaagent.bootstrap.DefineClassHelper; | ||
import io.opentelemetry.javaagent.bootstrap.InstrumentedTaskClasses; | ||
import io.opentelemetry.javaagent.bootstrap.LambdaTransformer; | ||
import io.opentelemetry.javaagent.bootstrap.LambdaTransformerHolder; | ||
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseCustomizer; | ||
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseCustomizerHolder; | ||
import io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseMutator; | ||
|
@@ -200,14 +201,15 @@ private static void installBytebuddyAgent( | |
|
||
agentBuilder = AgentBuilderUtil.optimize(agentBuilder); | ||
ClassFileTransformer transformer = agentBuilder.installOn(inst); | ||
LambdaTransformer lambdaTransformer; | ||
if (JavaModule.isSupported()) { | ||
// wrapping in a JPMS compliant implementation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [for reviewer] wrapping at registration time helps to make the consumer transparently use it with java 8 API. |
||
transformer = new Java9LambdaClassFileTransformer(transformer); | ||
lambdaTransformer = new Java9LambdaTransformer(transformer); | ||
} else { | ||
// wrapping in a java 8 compliant transformer | ||
transformer = new LambdaClassFileTransformer(transformer); | ||
lambdaTransformer = new Java8LambdaTransformer(transformer); | ||
} | ||
ClassFileTransformerHolder.setLambdaClassFileTransformer(transformer); | ||
LambdaTransformerHolder.setLambdaTransformer(lambdaTransformer); | ||
|
||
instrumentationInstalled = true; | ||
|
||
|
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
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.