-
Couldn't load subscription status.
- Fork 1k
Add agent instrumentation for Ratpack 1.7+ #12572
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
150d23a
Add agent instrumentation for Ratpack 1.7
johnrengelman ea9c1da
(chore) update from review
johnrengelman 05a3d0d
(bug) apply exec controller classes using instrumentation
johnrengelman 8fff64a
(chore) make indy compatible
johnrengelman d72ecda
(chore) remove indy specific inlining per review
johnrengelman 65368a3
(chore) introduce factories and refactor class access for sharing
johnrengelman 14272de
(chore) class access cleanup from review
johnrengelman 948e5ba
(chore) remove extraneous test dependency
johnrengelman 6ad7e61
(chore) cleanup from review
johnrengelman f28eb5a
(chore) rename class for clarity
johnrengelman 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
33 changes: 33 additions & 0 deletions
33
instrumentation/ratpack/ratpack-1.7/javaagent/build.gradle.kts
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,33 @@ | ||
| plugins { | ||
| id("otel.javaagent-instrumentation") | ||
| } | ||
|
|
||
| muzzle { | ||
| pass { | ||
| group.set("io.ratpack") | ||
| module.set("ratpack-core") | ||
| versions.set("[1.7.0,)") | ||
| } | ||
| fail { | ||
| group.set("io.ratpack") | ||
| module.set("ratpack-core") | ||
| versions.set("[1.0,1.7)") | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| library("io.ratpack:ratpack-core:1.7.0") | ||
|
|
||
| implementation(project(":instrumentation:netty:netty-4.1:library")) | ||
| implementation(project(":instrumentation:ratpack:ratpack-1.7:library")) | ||
|
|
||
| testImplementation(project(":instrumentation:ratpack:ratpack-1.4:testing")) | ||
| testInstrumentation(project(":instrumentation:ratpack:ratpack-1.4:javaagent")) | ||
| } | ||
|
|
||
| tasks { | ||
| withType<Test>().configureEach { | ||
| systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) | ||
| jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true") | ||
| } | ||
| } | ||
93 changes: 93 additions & 0 deletions
93
...elemetry/javaagent/instrumentation/ratpack/v1_7/DefaultExecControllerInstrumentation.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,93 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.ratpack.v1_7; | ||
|
|
||
| import static net.bytebuddy.matcher.ElementMatchers.isConstructor; | ||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||
| import static net.bytebuddy.matcher.ElementMatchers.takesArgument; | ||
|
|
||
| import com.google.common.collect.ImmutableList; | ||
| import io.opentelemetry.instrumentation.ratpack.v1_7.internal.OpenTelemetryExecInitializer; | ||
| import io.opentelemetry.instrumentation.ratpack.v1_7.internal.OpenTelemetryExecInterceptor; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||
| import net.bytebuddy.asm.Advice; | ||
| import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument; | ||
| import net.bytebuddy.asm.Advice.AssignReturned.ToFields.ToField; | ||
| import net.bytebuddy.description.type.TypeDescription; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
| import ratpack.exec.ExecInitializer; | ||
| import ratpack.exec.ExecInterceptor; | ||
|
|
||
| public class DefaultExecControllerInstrumentation implements TypeInstrumentation { | ||
|
|
||
| @Override | ||
| public ElementMatcher<TypeDescription> typeMatcher() { | ||
| return named("ratpack.exec.internal.DefaultExecController"); | ||
| } | ||
|
|
||
| @Override | ||
| public void transform(TypeTransformer transformer) { | ||
| transformer.applyAdviceToMethod( | ||
| named("setInitializers") | ||
| .and(takesArgument(0, named("com.google.common.collect.ImmutableList"))), | ||
| DefaultExecControllerInstrumentation.class.getName() + "$SetInitializersAdvice"); | ||
|
|
||
| transformer.applyAdviceToMethod( | ||
| named("setInterceptors") | ||
| .and(takesArgument(0, named("com.google.common.collect.ImmutableList"))), | ||
| DefaultExecControllerInstrumentation.class.getName() + "$SetInterceptorsAdvice"); | ||
|
|
||
| transformer.applyAdviceToMethod( | ||
| isConstructor(), | ||
| DefaultExecControllerInstrumentation.class.getName() + "$ConstructorAdvice"); | ||
| } | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public static class SetInitializersAdvice { | ||
| @Advice.OnMethodEnter(suppress = Throwable.class) | ||
| @Advice.AssignReturned.ToArguments(@ToArgument(0)) | ||
| public static ImmutableList<? extends ExecInitializer> enter( | ||
| @Advice.Argument(0) ImmutableList<? extends ExecInitializer> initializers) { | ||
| return ImmutableList.<ExecInitializer>builder() | ||
| .addAll(initializers) | ||
| .add(OpenTelemetryExecInitializer.INSTANCE) | ||
| .build(); | ||
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public static class SetInterceptorsAdvice { | ||
| @Advice.OnMethodEnter(suppress = Throwable.class) | ||
| @Advice.AssignReturned.ToArguments(@ToArgument(0)) | ||
| public static ImmutableList<? extends ExecInterceptor> enter( | ||
| @Advice.Argument(0) ImmutableList<? extends ExecInterceptor> interceptors) { | ||
| return ImmutableList.<ExecInterceptor>builder() | ||
| .addAll(interceptors) | ||
| .add(OpenTelemetryExecInterceptor.INSTANCE) | ||
| .build(); | ||
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public static class ConstructorAdvice { | ||
|
|
||
| @SuppressWarnings("UnusedVariable") | ||
| @Advice.OnMethodExit(suppress = Throwable.class) | ||
| @Advice.AssignReturned.ToFields({ | ||
| @ToField(value = "initializers", index = 0), | ||
| @ToField(value = "interceptors", index = 1) | ||
| }) | ||
| public static Object[] exit( | ||
| @Advice.FieldValue("initializers") ImmutableList<? extends ExecInitializer> initializers, | ||
| @Advice.FieldValue("interceptors") ImmutableList<? extends ExecInterceptor> interceptors) { | ||
| return new Object[] { | ||
| ImmutableList.of(OpenTelemetryExecInitializer.INSTANCE), | ||
| ImmutableList.of(OpenTelemetryExecInterceptor.INSTANCE) | ||
| }; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
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.