Skip to content

Commit 8446494

Browse files
authored
Code review sweep (run 24898505367) (open-telemetry#18264)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent 85b39ac commit 8446494

10 files changed

Lines changed: 39 additions & 32 deletions

File tree

instrumentation/rxjava/rxjava-3.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava/v3_0/TracingAssembly.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ public final class TracingAssembly {
102102
@Nullable
103103
private static Function<? super Runnable, ? extends Runnable> oldScheduleHandler;
104104

105+
@GuardedBy("TracingAssembly.class")
106+
@Nullable
107+
private static RxJava3AsyncOperationEndStrategy asyncOperationEndStrategy;
108+
105109
@GuardedBy("TracingAssembly.class")
106110
private static boolean enabled;
107111

@@ -281,9 +285,6 @@ private static void enableMaybe() {
281285
}));
282286
}
283287

284-
@GuardedBy("TracingAssembly.class")
285-
private static RxJava3AsyncOperationEndStrategy asyncOperationEndStrategy;
286-
287288
@GuardedBy("TracingAssembly.class")
288289
private static void enableWithSpanStrategy(boolean captureExperimentalSpanAttributes) {
289290
asyncOperationEndStrategy =
@@ -347,15 +348,15 @@ private static void disableWithSpanStrategy() {
347348
}
348349

349350
private static <T> Function<? super T, ? extends T> compose(
350-
Function<? super T, ? extends T> before, Function<? super T, ? extends T> after) {
351+
@Nullable Function<? super T, ? extends T> before, Function<? super T, ? extends T> after) {
351352
if (before == null) {
352353
return after;
353354
}
354355
return (T v) -> after.apply(before.apply(v));
355356
}
356357

357358
private static <T, U> BiFunction<? super T, ? super U, ? extends U> biCompose(
358-
BiFunction<? super T, ? super U, ? extends U> before,
359+
@Nullable BiFunction<? super T, ? super U, ? extends U> before,
359360
BiFunction<? super T, ? super U, ? extends U> after) {
360361
if (before == null) {
361362
return after;

instrumentation/rxjava/rxjava-3.0/library/src/test/java/io/opentelemetry/instrumentation/rxjava/v3_0/RxJava3SubscriptionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
class RxJava3SubscriptionTest extends AbstractRxJava3SubscriptionTest {
1515

1616
@RegisterExtension
17-
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
17+
private static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
1818

19-
static final TracingAssembly tracingAssembly = TracingAssembly.create();
19+
private static final TracingAssembly tracingAssembly = TracingAssembly.create();
2020

2121
@Override
2222
protected InstrumentationExtension testing() {

instrumentation/rxjava/rxjava-3.0/library/src/test/java/io/opentelemetry/instrumentation/rxjava/v3_0/RxJava3Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
class RxJava3Test extends AbstractRxJava3Test {
1515
@RegisterExtension
16-
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
16+
private static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
1717

18-
static final TracingAssembly tracingAssembly = TracingAssembly.create();
18+
private static final TracingAssembly tracingAssembly = TracingAssembly.create();
1919

2020
@Override
2121
protected InstrumentationExtension testing() {

instrumentation/rxjava/rxjava-3.0/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ features:
88
- CONTEXT_PROPAGATION
99
configurations:
1010
- name: otel.instrumentation.rxjava.experimental-span-attributes
11+
declarative_name: java.rxjava.experimental_span_attributes/development
1112
description: >
1213
Enables the experimental span attribute `rxjava.canceled`.
1314
type: boolean

instrumentation/rxjava/rxjava-3.1.1/library/src/main/java/io/opentelemetry/instrumentation/rxjava/v3_1_1/TracingAssembly.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
/**
5151
* RxJava3 library instrumentation.
5252
*
53-
* <p>In order to enable RxJava3 instrumentation one has to call the {@link
54-
* TracingAssembly#enable()} method.
53+
* <p>In order to enable RxJava3 instrumentation create a {@link TracingAssembly} with {@link
54+
* #create()} or {@link #builder()} and then call {@link #enable()}.
5555
*
5656
* <p>Instrumentation uses <code>on*Assembly</code> and <code>on*Subscribe</code> RxJavaPlugin hooks
5757
* to wrap RxJava3 classes in their tracing equivalents.
5858
*
59-
* <p>Instrumentation can be disabled by calling the {@link TracingAssembly#disable()} method.
59+
* <p>Instrumentation can be disabled by calling {@link #disable()} on that instance.
6060
*/
6161
@SuppressWarnings("SuppressWarningsWithoutExplanation") // RxJavaPlugins uses raw types
6262
public final class TracingAssembly {
@@ -106,6 +106,7 @@ public final class TracingAssembly {
106106
private static boolean enabled;
107107

108108
@GuardedBy("TracingAssembly.class")
109+
@Nullable
109110
private static RxJava3AsyncOperationEndStrategy asyncOperationEndStrategy;
110111

111112
public static TracingAssembly create() {
@@ -347,15 +348,15 @@ private static void disableWithSpanStrategy() {
347348
}
348349

349350
private static <T> Function<? super T, ? extends T> compose(
350-
Function<? super T, ? extends T> before, Function<? super T, ? extends T> after) {
351+
@Nullable Function<? super T, ? extends T> before, Function<? super T, ? extends T> after) {
351352
if (before == null) {
352353
return after;
353354
}
354355
return (T v) -> after.apply(before.apply(v));
355356
}
356357

357358
private static <T, U> BiFunction<? super T, ? super U, ? extends U> biCompose(
358-
BiFunction<? super T, ? super U, ? extends U> before,
359+
@Nullable BiFunction<? super T, ? super U, ? extends U> before,
359360
BiFunction<? super T, ? super U, ? extends U> after) {
360361
if (before == null) {
361362
return after;

instrumentation/rxjava/rxjava-3.1.1/library/src/test/java/io/opentelemetry/instrumentation/rxjava/v3_1_1/RxJava3SubscriptionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
class RxJava3SubscriptionTest extends AbstractRxJava3SubscriptionTest {
1515

1616
@RegisterExtension
17-
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
17+
private static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
1818

19-
static final TracingAssembly tracingAssembly = TracingAssembly.create();
19+
private static final TracingAssembly tracingAssembly = TracingAssembly.create();
2020

2121
@Override
2222
protected InstrumentationExtension testing() {

instrumentation/rxjava/rxjava-3.1.1/library/src/test/java/io/opentelemetry/instrumentation/rxjava/v3_1_1/RxJava3Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
class RxJava3Test extends AbstractRxJava3Test {
1515
@RegisterExtension
16-
static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
16+
private static final InstrumentationExtension testing = LibraryInstrumentationExtension.create();
1717

18-
static final TracingAssembly tracingAssembly = TracingAssembly.create();
18+
private static final TracingAssembly tracingAssembly = TracingAssembly.create();
1919

2020
@Override
2121
protected InstrumentationExtension testing() {

instrumentation/rxjava/rxjava-3.1.1/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ features:
88
- CONTEXT_PROPAGATION
99
configurations:
1010
- name: otel.instrumentation.rxjava.experimental-span-attributes
11+
declarative_name: java.rxjava.experimental_span_attributes/development
1112
description: >
1213
Enables the experimental span attribute `rxjava.canceled`.
1314
type: boolean

instrumentation/rxjava/rxjava-common-3.0/testing/src/main/java/io/opentelemetry/instrumentation/rxjava/common/v3_0/ExperimentalTestHelper.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55

66
package io.opentelemetry.instrumentation.rxjava.common.v3_0;
77

8-
import javax.annotation.Nullable;
9-
10-
public class ExperimentalTestHelper {
8+
class ExperimentalTestHelper {
119
private static final boolean isEnabled =
1210
Boolean.getBoolean("otel.instrumentation.rxjava.experimental-span-attributes");
1311

14-
@Nullable
15-
public static Boolean experimentalCanceled(boolean value) {
12+
static Boolean experimentalCanceled(boolean value) {
1613
if (isEnabled) {
1714
return value;
1815
}

instrumentation/scala-fork-join-2.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/scalaexecutors/ScalaForkJoinTaskInstrumentation.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,28 @@ public static class ForkJoinTaskAdvice {
6868
public static Scope enter(@Advice.This ForkJoinTask<?> thiz) {
6969
Scope scope =
7070
TaskAdviceHelper.makePropagatedContextCurrent(FORK_JOIN_TASK_PROPAGATED_CONTEXT, thiz);
71-
Scope newScope = null;
7271
if (thiz instanceof Runnable) {
73-
newScope =
72+
Scope newScope =
7473
TaskAdviceHelper.makePropagatedContextCurrent(
7574
RUNNABLE_PROPAGATED_CONTEXT, (Runnable) thiz);
75+
if (newScope != null) {
76+
if (scope != null) {
77+
newScope.close();
78+
} else {
79+
scope = newScope;
80+
}
81+
}
7682
}
7783
if (thiz instanceof Callable) {
78-
newScope =
84+
Scope newScope =
7985
TaskAdviceHelper.makePropagatedContextCurrent(
8086
CALLABLE_PROPAGATED_CONTEXT, (Callable<?>) thiz);
81-
}
82-
if (newScope != null) {
83-
if (scope != null) {
84-
newScope.close();
85-
} else {
86-
scope = newScope;
87+
if (newScope != null) {
88+
if (scope != null) {
89+
newScope.close();
90+
} else {
91+
scope = newScope;
92+
}
8793
}
8894
}
8995
return scope;

0 commit comments

Comments
 (0)