Skip to content

Commit 874ad04

Browse files
rename AsyncOperationEndHandler#handle to AsyncOperationCallback#onEnd
1 parent 771fe71 commit 874ad04

File tree

10 files changed

+41
-41
lines changed

10 files changed

+41
-41
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import javax.annotation.Nullable;
1010

1111
/** Callback that is called when async computation completes. */
12-
public interface AsyncOperationEndHandler<REQUEST, RESPONSE> {
13-
void handle(
12+
public interface AsyncOperationCallback<REQUEST, RESPONSE> {
13+
void onEnd(
1414
Context context, REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error);
1515
}

instrumentation-annotations-support/src/main/java/io/opentelemetry/instrumentation/api/annotation/support/async/AsyncOperationEndStrategy.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Implementations of this interface describe how to compose over {@linkplain #supports(Class)
1313
* supported} asynchronous computation types and delay marking the operation as ended by calling
1414
* {@link Instrumenter#end(Context, Object, Object, Throwable)} or {@link
15-
* AsyncOperationEndHandler#handle(Context, Object, Object, Throwable)}.
15+
* AsyncOperationCallback#onEnd(Context, Object, Object, Throwable)}.
1616
*/
1717
public interface AsyncOperationEndStrategy {
1818

@@ -47,12 +47,12 @@ default <REQUEST, RESPONSE> Object end(
4747
}
4848

4949
/**
50-
* Composes over {@code asyncValue} and delays the {@link AsyncOperationEndHandler#handle(Context,
50+
* Composes over {@code asyncValue} and delays the {@link AsyncOperationCallback#onEnd(Context,
5151
* Object, Object, Throwable)} call until after the asynchronous operation represented by {@code
5252
* asyncValue} completes.
5353
*
54-
* @param handler The {@link AsyncOperationEndHandler} to be used to end the operation stored in
55-
* the {@code context}.
54+
* @param handler The {@link AsyncOperationCallback} to be used to end the operation stored in the
55+
* {@code context}.
5656
* @param asyncValue Return value from the instrumented method. Must be an instance of a {@code
5757
* asyncType} for which {@link #supports(Class)} returned true (in particular it must not be
5858
* {@code null}).
@@ -63,7 +63,7 @@ default <REQUEST, RESPONSE> Object end(
6363
* of completion.
6464
*/
6565
<REQUEST, RESPONSE> Object end(
66-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
66+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
6767
Context context,
6868
REQUEST request,
6969
Object asyncValue,

instrumentation-annotations-support/src/main/java/io/opentelemetry/instrumentation/api/annotation/support/async/AsyncOperationEndSupport.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import javax.annotation.Nullable;
1111

1212
/**
13-
* A wrapper over {@link AsyncOperationEndHandler} that is able to defer {@link
14-
* AsyncOperationEndHandler#handle(Context, Object, Object, Throwable)} until asynchronous
15-
* computation finishes.
13+
* A wrapper over {@link AsyncOperationCallback} that is able to defer {@link
14+
* AsyncOperationCallback#onEnd(Context, Object, Object, Throwable)} until asynchronous computation
15+
* finishes.
1616
*/
1717
public final class AsyncOperationEndSupport<REQUEST, RESPONSE> {
1818

@@ -42,7 +42,7 @@ public static <REQUEST, RESPONSE> AsyncOperationEndSupport<REQUEST, RESPONSE> cr
4242
* used as the response.
4343
*/
4444
public static <REQUEST, RESPONSE> AsyncOperationEndSupport<REQUEST, RESPONSE> create(
45-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
45+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
4646
Class<RESPONSE> responseType,
4747
Class<?> asyncType) {
4848
return new AsyncOperationEndSupport<>(
@@ -52,13 +52,13 @@ public static <REQUEST, RESPONSE> AsyncOperationEndSupport<REQUEST, RESPONSE> cr
5252
AsyncOperationEndStrategies.instance().resolveStrategy(asyncType));
5353
}
5454

55-
private final AsyncOperationEndHandler<REQUEST, RESPONSE> handler;
55+
private final AsyncOperationCallback<REQUEST, RESPONSE> handler;
5656
private final Class<RESPONSE> responseType;
5757
private final Class<?> asyncType;
5858
@Nullable private final AsyncOperationEndStrategy asyncOperationEndStrategy;
5959

6060
private AsyncOperationEndSupport(
61-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
61+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
6262
Class<RESPONSE> responseType,
6363
Class<?> asyncType,
6464
@Nullable AsyncOperationEndStrategy asyncOperationEndStrategy) {
@@ -87,7 +87,7 @@ public <ASYNC> ASYNC asyncEnd(
8787
Context context, REQUEST request, @Nullable ASYNC asyncValue, @Nullable Throwable throwable) {
8888
// we can end early if an exception was thrown
8989
if (throwable != null) {
90-
handler.handle(context, request, null, throwable);
90+
handler.onEnd(context, request, null, throwable);
9191
return asyncValue;
9292
}
9393

@@ -98,7 +98,7 @@ public <ASYNC> ASYNC asyncEnd(
9898
}
9999

100100
// fall back to sync end() if asyncValue type doesn't match
101-
handler.handle(context, request, tryToGetResponse(responseType, asyncValue), null);
101+
handler.onEnd(context, request, tryToGetResponse(responseType, asyncValue), null);
102102
return asyncValue;
103103
}
104104

instrumentation-annotations-support/src/main/java/io/opentelemetry/instrumentation/api/annotation/support/async/Jdk8AsyncOperationEndStrategy.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public boolean supports(Class<?> asyncType) {
2121

2222
@Override
2323
public <REQUEST, RESPONSE> Object end(
24-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
24+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
2525
Context context,
2626
REQUEST request,
2727
Object asyncValue,
@@ -43,7 +43,7 @@ public <REQUEST, RESPONSE> Object end(
4343
* notification of completion.
4444
*/
4545
private static <REQUEST, RESPONSE> boolean tryToEndSynchronously(
46-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
46+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
4747
Context context,
4848
REQUEST request,
4949
CompletableFuture<?> future,
@@ -55,9 +55,9 @@ private static <REQUEST, RESPONSE> boolean tryToEndSynchronously(
5555

5656
try {
5757
Object potentialResponse = future.join();
58-
handler.handle(context, request, tryToGetResponse(responseType, potentialResponse), null);
58+
handler.onEnd(context, request, tryToGetResponse(responseType, potentialResponse), null);
5959
} catch (Throwable t) {
60-
handler.handle(context, request, null, t);
60+
handler.onEnd(context, request, null, t);
6161
}
6262
return true;
6363
}
@@ -67,13 +67,13 @@ private static <REQUEST, RESPONSE> boolean tryToEndSynchronously(
6767
* span will be ended.
6868
*/
6969
private static <REQUEST, RESPONSE> CompletionStage<?> endWhenComplete(
70-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
70+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
7171
Context context,
7272
REQUEST request,
7373
CompletionStage<?> stage,
7474
Class<RESPONSE> responseType) {
7575
return stage.whenComplete(
7676
(result, exception) ->
77-
handler.handle(context, request, tryToGetResponse(responseType, result), exception));
77+
handler.onEnd(context, request, tryToGetResponse(responseType, result), exception));
7878
}
7979
}

instrumentation/guava-10.0/library/src/main/java/io/opentelemetry/instrumentation/guava/v10_0/GuavaAsyncOperationEndStrategy.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import io.opentelemetry.api.common.AttributeKey;
1313
import io.opentelemetry.api.trace.Span;
1414
import io.opentelemetry.context.Context;
15-
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndHandler;
15+
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationCallback;
1616
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategy;
1717

1818
public final class GuavaAsyncOperationEndStrategy implements AsyncOperationEndStrategy {
@@ -41,7 +41,7 @@ public boolean supports(Class<?> returnType) {
4141

4242
@Override
4343
public <REQUEST, RESPONSE> Object end(
44-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
44+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
4545
Context context,
4646
REQUEST request,
4747
Object asyncValue,
@@ -53,7 +53,7 @@ public <REQUEST, RESPONSE> Object end(
5353
}
5454

5555
private <REQUEST, RESPONSE> void end(
56-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
56+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
5757
Context context,
5858
REQUEST request,
5959
ListenableFuture<?> future,
@@ -63,13 +63,13 @@ private <REQUEST, RESPONSE> void end(
6363
if (captureExperimentalSpanAttributes) {
6464
Span.fromContext(context).setAttribute(CANCELED_ATTRIBUTE_KEY, true);
6565
}
66-
handler.handle(context, request, null, null);
66+
handler.onEnd(context, request, null, null);
6767
} else {
6868
try {
6969
Object response = Uninterruptibles.getUninterruptibly(future);
70-
handler.handle(context, request, tryToGetResponse(responseType, response), null);
70+
handler.onEnd(context, request, tryToGetResponse(responseType, response), null);
7171
} catch (Throwable exception) {
72-
handler.handle(context, request, null, exception);
72+
handler.onEnd(context, request, null, exception);
7373
}
7474
}
7575
} else {

instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent-kotlin/src/main/kotlin/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowUtil.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
package io.opentelemetry.javaagent.instrumentation.kotlinxcoroutines.flow
77

88
import io.opentelemetry.context.Context
9-
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndHandler
9+
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationCallback
1010
import kotlinx.coroutines.flow.Flow
1111
import kotlinx.coroutines.flow.onCompletion
1212

13-
fun <REQUEST, RESPONSE> onComplete(flow: Flow<*>, handler: AsyncOperationEndHandler<REQUEST, RESPONSE>, context: Context, request: REQUEST & Any): Flow<*> = flow.onCompletion { cause: Throwable? ->
14-
handler.handle(context, request, null, cause)
13+
fun <REQUEST, RESPONSE> onComplete(flow: Flow<*>, handler: AsyncOperationCallback<REQUEST, RESPONSE>, context: Context, request: REQUEST & Any): Flow<*> = flow.onCompletion { cause: Throwable? ->
14+
handler.onEnd(context, request, null, cause)
1515
}

instrumentation/kotlinx-coroutines/kotlinx-coroutines-flow-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/flow/FlowInstrumentationHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package io.opentelemetry.javaagent.instrumentation.kotlinxcoroutines.flow;
77

88
import io.opentelemetry.context.Context;
9-
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndHandler;
9+
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationCallback;
1010
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategies;
1111
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategy;
1212
import kotlinx.coroutines.flow.Flow;
@@ -32,7 +32,7 @@ public boolean supports(Class<?> returnType) {
3232

3333
@Override
3434
public <REQUEST, RESPONSE> Object end(
35-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
35+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
3636
Context context,
3737
REQUEST request,
3838
Object asyncValue,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import io.opentelemetry.api.common.AttributeKey;
1111
import io.opentelemetry.api.trace.Span;
1212
import io.opentelemetry.context.Context;
13-
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndHandler;
13+
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationCallback;
1414
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategy;
1515
import java.util.concurrent.atomic.AtomicBoolean;
1616
import java.util.function.Consumer;
@@ -44,7 +44,7 @@ public boolean supports(Class<?> returnType) {
4444

4545
@Override
4646
public <REQUEST, RESPONSE> Object end(
47-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
47+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
4848
Context context,
4949
REQUEST request,
5050
Object asyncValue,
@@ -54,7 +54,7 @@ public <REQUEST, RESPONSE> Object end(
5454
new EndOnFirstNotificationConsumer(context) {
5555
@Override
5656
protected void end(Object result, Throwable error) {
57-
handler.handle(context, request, tryToGetResponse(responseType, result), error);
57+
handler.onEnd(context, request, tryToGetResponse(responseType, result), error);
5858
}
5959
};
6060

instrumentation/rxjava/rxjava-2.0/library/src/main/java/io/opentelemetry/instrumentation/rxjava/v2_0/RxJava2AsyncOperationEndStrategy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import io.opentelemetry.api.common.AttributeKey;
1111
import io.opentelemetry.api.trace.Span;
1212
import io.opentelemetry.context.Context;
13-
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndHandler;
13+
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationCallback;
1414
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategy;
1515
import io.reactivex.Completable;
1616
import io.reactivex.Flowable;
@@ -55,7 +55,7 @@ public boolean supports(Class<?> returnType) {
5555

5656
@Override
5757
public <REQUEST, RESPONSE> Object end(
58-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
58+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
5959
Context context,
6060
REQUEST request,
6161
Object asyncValue,
@@ -65,7 +65,7 @@ public <REQUEST, RESPONSE> Object end(
6565
new EndOnFirstNotificationConsumer<Object>(context) {
6666
@Override
6767
protected void end(Object response, Throwable error) {
68-
handler.handle(context, request, tryToGetResponse(responseType, response), error);
68+
handler.onEnd(context, request, tryToGetResponse(responseType, response), error);
6969
}
7070
};
7171

instrumentation/rxjava/rxjava-3-common/library/src/main/java/io/opentelemetry/instrumentation/rxjava/v3/common/RxJava3AsyncOperationEndStrategy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import io.opentelemetry.api.common.AttributeKey;
1111
import io.opentelemetry.api.trace.Span;
1212
import io.opentelemetry.context.Context;
13-
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndHandler;
13+
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationCallback;
1414
import io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndStrategy;
1515
import io.reactivex.rxjava3.core.Completable;
1616
import io.reactivex.rxjava3.core.Flowable;
@@ -55,7 +55,7 @@ public boolean supports(Class<?> returnType) {
5555

5656
@Override
5757
public <REQUEST, RESPONSE> Object end(
58-
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
58+
AsyncOperationCallback<REQUEST, RESPONSE> handler,
5959
Context context,
6060
REQUEST request,
6161
Object asyncValue,
@@ -65,7 +65,7 @@ public <REQUEST, RESPONSE> Object end(
6565
new EndOnFirstNotificationConsumer<Object>(context) {
6666
@Override
6767
protected void end(Object response, Throwable error) {
68-
handler.handle(context, request, tryToGetResponse(responseType, response), error);
68+
handler.onEnd(context, request, tryToGetResponse(responseType, response), error);
6969
}
7070
};
7171

0 commit comments

Comments
 (0)