Skip to content

Commit c5a1976

Browse files
committed
fix: pr review changes
1 parent 4b54b37 commit c5a1976

8 files changed

Lines changed: 24 additions & 16 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
id("otel.java-conventions")
3+
}

instrumentation/finagle-http-23.11/javaagent/src/main/java/com/twitter/util/Promise.java renamed to instrumentation/finagle-http-23.11/compile-stub/src/main/java/com/twitter/util/Promise.java

File renamed without changes.

instrumentation/finagle-http-23.11/javaagent/build.gradle.kts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,16 @@ dependencies {
3434

3535
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))
3636

37-
implementation(project(":instrumentation:netty:netty-4.1:javaagent"))
38-
implementation(project(":instrumentation:netty:netty-4.1:library"))
39-
implementation(project(":instrumentation:netty:netty-common-4.0:javaagent"))
40-
implementation(project(":instrumentation:netty:netty-common-4.0:library"))
41-
}
42-
43-
tasks.withType<Jar>().configureEach {
4437
// Exclude the Promise stub and its nested classes;
4538
// this allows us to compile against these types in the instrumentation
4639
// despite them being private in their original inner class;
4740
// this is required for VirtualField to have a concrete type to find/get/set on.
48-
exclude("com/twitter/util/Promise.class")
49-
exclude("com/twitter/util/Promise$*.class")
41+
compileOnly(project(":instrumentation:finagle-http-23.11:compile-stub"))
42+
43+
implementation(project(":instrumentation:netty:netty-4.1:javaagent"))
44+
implementation(project(":instrumentation:netty:netty-4.1:library"))
45+
implementation(project(":instrumentation:netty:netty-common-4.0:javaagent"))
46+
implementation(project(":instrumentation:netty:netty-common-4.0:library"))
5047
}
5148

5249
tasks {

instrumentation/finagle-http-23.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11/PromiseKInstrumentation.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public void transform(TypeTransformer transformer) {
4747
public static class TrapContextAdvice {
4848

4949
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
50-
public static void onExit(@Advice.This Promise.K thiz) {
50+
public static void onExit(
51+
@Advice.This
52+
@SuppressWarnings("rawtypes") // type is from compile-stub and masks private type
53+
Promise.K thiz) {
5154
Context current = Context.current();
5255
TwitterUtilCoreHelpers.PROMISE_K_CONTEXT_FIELD.set(thiz, current);
5356
}
@@ -57,7 +60,10 @@ public static void onExit(@Advice.This Promise.K thiz) {
5760
public static class ApplyAdvice {
5861
@Advice.OnMethodEnter(suppress = Throwable.class, inline = false)
5962
@Nullable
60-
public static Scope onApplyEnter(@Advice.This Promise.K thiz) {
63+
public static Scope onApplyEnter(
64+
@Advice.This
65+
@SuppressWarnings("rawtypes") // type is from compile-stub and masks private type
66+
Promise.K thiz) {
6167
// if this is null, there's a bug in the instrumentation
6268
Context savedContext = TwitterUtilCoreHelpers.PROMISE_K_CONTEXT_FIELD.get(thiz);
6369
return savedContext != null ? savedContext.makeCurrent() : null;

instrumentation/finagle-http-23.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11/TwitterUtilCoreHelpers.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import scala.runtime.BoxedUnit;
1717

1818
public class TwitterUtilCoreHelpers {
19+
@SuppressWarnings("rawtypes") // type is from compile-stub and masks private type
1920
public static final VirtualField<Promise.K, Context> PROMISE_K_CONTEXT_FIELD =
2021
VirtualField.find(Promise.K.class, Context.class);
2122

@@ -35,7 +36,7 @@ public InterruptibleWithContext(
3536
@Override
3637
public boolean isDefinedAt(Throwable x) {
3738
try (Scope ignored = context.makeCurrent()) {
38-
// Return true only for inputs this function handles`
39+
// Return true only for inputs this function handles
3940
return delegate.isDefinedAt(x);
4041
}
4142
}
@@ -49,7 +50,7 @@ public BoxedUnit apply(Throwable x) {
4950
}
5051

5152
public static <T, O> Function1<T, O> wrap(Context context, Function1<T, O> fn) {
52-
return (t) -> {
53+
return t -> {
5354
// always set it: you never know what might be polluting the thread local context at the time
5455
try (Scope ignored = context.makeCurrent()) {
5556
return fn.apply(t);

instrumentation/finagle-http-23.11/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11/FinagleClientExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
/**
3131
* Class-scoped JUnit extension that owns a Finagle {@link Http.Client} per {@link ClientType} and
32-
* the underlying {@link EventLoopGroup} for the duration of the test class. Modeled on {@code
33-
* Netty41ClientExtension}: build once in {@code beforeAll}, tear down once in {@code afterAll}.
32+
* the underlying {@link EventLoopGroup} for the duration of the test class. Clients and services
33+
* are created lazily on first use and torn down once in {@code afterAll}.
3434
*/
3535
public class FinagleClientExtension implements AfterAllCallback {
3636

instrumentation/finagle-http-23.11/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/finaglehttp/v23_11/TwitterUtilCoreInstrumentationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void futurePoolSingleApplyPropagatesContext() throws Exception {
112112
return 1;
113113
})));
114114

115-
assertThat((int) Await.result(f, AWAIT)).isEqualTo(1);
115+
assertThat(Await.result(f, AWAIT)).isEqualTo(1);
116116
assertParentAndChild("parent", "pool-child");
117117
}
118118

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ include(":instrumentation:external-annotations:javaagent")
289289
include(":instrumentation:external-annotations:javaagent-unit-tests")
290290
include(":instrumentation:failsafe-3.0:library")
291291
include(":instrumentation:finagle-http-23.11:javaagent")
292+
include(":instrumentation:finagle-http-23.11:compile-stub")
292293
include(":instrumentation:finatra-2.9:javaagent")
293294
include(":instrumentation:geode-1.4:javaagent")
294295
include(":instrumentation:google-http-client-1.19:javaagent")

0 commit comments

Comments
 (0)