Skip to content

Commit 1296f0d

Browse files
committed
Revert "Review fixes for reactor-3.1:library"
This reverts commit 8c8e72f.
1 parent 6cd9465 commit 1296f0d

2 files changed

Lines changed: 1 addition & 91 deletions

File tree

instrumentation/reactor/reactor-3.1/library/src/main/java/io/opentelemetry/instrumentation/reactor/v3_1/ContextPropagationOperator.java

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,8 @@ public final class ContextPropagationOperator {
5858
@Nullable
5959
private static final MethodHandle FLUX_CONTEXT_WRITE_METHOD = getContextWriteMethod(Flux.class);
6060

61-
private static final String SCHEDULERS_HOOK_KEY = RunnableWrapper.class.getName();
62-
6361
@Nullable private static final MethodHandle SCHEDULERS_HOOK_METHOD = getSchedulersHookMethod();
6462

65-
@Nullable
66-
private static final MethodHandle SCHEDULERS_RESET_HOOK_METHOD = getSchedulersResetHookMethod();
67-
6863
@Nullable
6964
private static MethodHandle getContextWriteMethod(Class<?> type) {
7065
MethodHandles.Lookup lookup = MethodHandles.publicLookup();
@@ -93,18 +88,6 @@ private static MethodHandle getSchedulersHookMethod() {
9388
return null;
9489
}
9590

96-
@Nullable
97-
private static MethodHandle getSchedulersResetHookMethod() {
98-
MethodHandles.Lookup lookup = MethodHandles.publicLookup();
99-
try {
100-
return lookup.findStatic(
101-
Schedulers.class, "resetOnScheduleHook", methodType(void.class, String.class));
102-
} catch (NoSuchMethodException | IllegalAccessException e) {
103-
// ignore
104-
}
105-
return null;
106-
}
107-
10891
public static ContextPropagationOperator create() {
10992
return builder().build();
11093
}
@@ -188,7 +171,7 @@ public void registerOnEachOperator() {
188171
Hooks.onEachOperator(
189172
TracingSubscriber.class.getName(), tracingLift(asyncOperationEndStrategy));
190173
AsyncOperationEndStrategies.instance().registerStrategy(asyncOperationEndStrategy);
191-
registerScheduleHook(SCHEDULERS_HOOK_KEY, RunnableWrapper::new);
174+
registerScheduleHook(RunnableWrapper.class.getName(), RunnableWrapper::new);
192175
enabled = true;
193176
}
194177
}
@@ -204,17 +187,6 @@ private static void registerScheduleHook(String key, Function<Runnable, Runnable
204187
}
205188
}
206189

207-
private static void resetScheduleHook(String key) {
208-
if (SCHEDULERS_RESET_HOOK_METHOD == null) {
209-
return;
210-
}
211-
try {
212-
SCHEDULERS_RESET_HOOK_METHOD.invoke(key);
213-
} catch (Throwable t) {
214-
logger.log(WARNING, "Failed to remove scheduler hook", t);
215-
}
216-
}
217-
218190
/** Unregisters the hook registered by {@link #registerOnEachOperator()}. */
219191
public void resetOnEachOperator() {
220192
synchronized (lock) {
@@ -223,7 +195,6 @@ public void resetOnEachOperator() {
223195
}
224196
Hooks.resetOnEachOperator(TracingSubscriber.class.getName());
225197
AsyncOperationEndStrategies.instance().unregisterStrategy(asyncOperationEndStrategy);
226-
resetScheduleHook(SCHEDULERS_HOOK_KEY);
227198
enabled = false;
228199
}
229200
}

instrumentation/reactor/reactor-3.1/library/src/test/java/io/opentelemetry/instrumentation/reactor/v3_1/HooksTest.java

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,10 @@
66
package io.opentelemetry.instrumentation.reactor.v3_1;
77

88
import static java.util.concurrent.TimeUnit.MILLISECONDS;
9-
import static java.util.concurrent.TimeUnit.SECONDS;
109
import static org.assertj.core.api.Assertions.assertThat;
1110

12-
import io.opentelemetry.api.trace.Span;
13-
import io.opentelemetry.api.trace.SpanContext;
14-
import io.opentelemetry.api.trace.TraceFlags;
15-
import io.opentelemetry.api.trace.TraceState;
16-
import io.opentelemetry.context.Context;
17-
import io.opentelemetry.context.Scope;
1811
import java.util.concurrent.Callable;
19-
import java.util.concurrent.CountDownLatch;
2012
import java.util.concurrent.atomic.AtomicReference;
21-
import java.util.function.Function;
2213
import org.junit.jupiter.api.Test;
2314
import reactor.core.CoreSubscriber;
2415
import reactor.core.Disposable;
@@ -27,14 +18,6 @@
2718

2819
class HooksTest {
2920

30-
private static final Span PARENT_SPAN =
31-
Span.wrap(
32-
SpanContext.create(
33-
"11111111111111111111111111111111",
34-
"1111111111111111",
35-
TraceFlags.getSampled(),
36-
TraceState.getDefault()));
37-
3821
@Test
3922
void canResetOurHooks() {
4023
ContextPropagationOperator operator = ContextPropagationOperator.create();
@@ -52,25 +35,6 @@ void canResetOurHooks() {
5235
assertThat(subscriber.get()).extracting("actual").isNotInstanceOf(TracingSubscriber.class);
5336
}
5437

55-
@Test
56-
void canResetSchedulerHook() throws InterruptedException {
57-
if (!schedulerHooksSupported()) {
58-
return;
59-
}
60-
61-
ContextPropagationOperator operator = ContextPropagationOperator.create();
62-
63-
assertThat(scheduledSpanIsCurrent()).isFalse();
64-
65-
operator.registerOnEachOperator();
66-
try {
67-
assertThat(scheduledSpanIsCurrent()).isTrue();
68-
} finally {
69-
operator.resetOnEachOperator();
70-
}
71-
assertThat(scheduledSpanIsCurrent()).isFalse();
72-
}
73-
7438
private static class CapturingMono extends Mono<Integer> {
7539
private final AtomicReference<CoreSubscriber<? super Integer>> subscriber;
7640

@@ -107,29 +71,4 @@ void testInvalidBlockUsage() throws InterruptedException {
10771
disposable.dispose();
10872
operator.resetOnEachOperator();
10973
}
110-
111-
private static boolean schedulerHooksSupported() {
112-
try {
113-
Schedulers.class.getMethod("onScheduleHook", String.class, Function.class);
114-
Schedulers.class.getMethod("resetOnScheduleHook", String.class);
115-
return true;
116-
} catch (NoSuchMethodException e) {
117-
return false;
118-
}
119-
}
120-
121-
private static boolean scheduledSpanIsCurrent() throws InterruptedException {
122-
CountDownLatch latch = new CountDownLatch(1);
123-
AtomicReference<Boolean> currentSpanValid = new AtomicReference<>(false);
124-
try (Scope ignored = Context.root().with(PARENT_SPAN).makeCurrent()) {
125-
Schedulers.single()
126-
.schedule(
127-
() -> {
128-
currentSpanValid.set(Span.current().getSpanContext().isValid());
129-
latch.countDown();
130-
});
131-
}
132-
assertThat(latch.await(5, SECONDS)).isTrue();
133-
return currentSpanValid.get();
134-
}
13574
}

0 commit comments

Comments
 (0)