Skip to content

Commit

Permalink
rename to AsyncOperationEndSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek committed Jun 14, 2021
1 parent 825f4ba commit 4e8996a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.checkerframework.checker.nullness.qual.Nullable;

/** A global registry of {@link AsyncOperationEndStrategy} implementations. */
public final class AsyncEndStrategies {
public final class AsyncOperationEndStrategies {
private static final List<AsyncOperationEndStrategy> STRATEGIES = new CopyOnWriteArrayList<>();

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
* receives in the {@link #asyncEnd(Context, Object, Object, Throwable)} call, so it will always
* pass {@code null} as the response to the wrapped {@link Instrumenter}.
*/
public final class AsyncEndSupport<REQUEST> {
public final class AsyncOperationEndSupport<REQUEST> {

/**
* Returns a new {@link AsyncEndSupport} that wraps over passed {@code syncInstrumenter},
* Returns a new {@link AsyncOperationEndSupport} that wraps over passed {@code syncInstrumenter},
* configured for usage with asynchronous computations that are instances of {@code asyncType}.
*/
public static <REQUEST> AsyncEndSupport<REQUEST> create(
public static <REQUEST> AsyncOperationEndSupport<REQUEST> create(
Instrumenter<REQUEST, ?> syncInstrumenter, Class<?> asyncType) {
return new AsyncEndSupport<>(
syncInstrumenter, asyncType, AsyncEndStrategies.resolveStrategy(asyncType));
return new AsyncOperationEndSupport<>(
syncInstrumenter, asyncType, AsyncOperationEndStrategies.resolveStrategy(asyncType));
}

private final Instrumenter<REQUEST, ?> instrumenter;
private final Class<?> asyncType;
private final AsyncOperationEndStrategy asyncOperationEndStrategy;

private AsyncEndSupport(
private AsyncOperationEndSupport(
Instrumenter<REQUEST, ?> instrumenter,
Class<?> asyncType,
AsyncOperationEndStrategy asyncOperationEndStrategy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class AsyncEndSupportTest {
class AsyncOperationEndSupportTest {
@Mock Instrumenter<String, String> instrumenter;

@Test
void shouldEndImmediatelyWhenExceptionWasPassed() {
// given
AsyncEndSupport<String> underTest =
AsyncEndSupport.create(instrumenter, CompletableFuture.class);
AsyncOperationEndSupport<String> underTest =
AsyncOperationEndSupport.create(instrumenter, CompletableFuture.class);

Context context = Context.root();
Exception exception = new RuntimeException("boom!");
Expand All @@ -47,7 +47,8 @@ void shouldEndImmediatelyWhenExceptionWasPassed() {
@Test
void shouldEndImmediatelyWhenWrongReturnTypeWasPassed() {
// given
AsyncEndSupport<String> underTest = AsyncEndSupport.create(instrumenter, Future.class);
AsyncOperationEndSupport<String> underTest =
AsyncOperationEndSupport.create(instrumenter, Future.class);

Context context = Context.root();
CompletableFuture<String> future = new CompletableFuture<>();
Expand All @@ -64,8 +65,8 @@ void shouldEndImmediatelyWhenWrongReturnTypeWasPassed() {
@Test
void shouldEndImmediatelyWhenAsyncWrapperisOfWrongType() {
// given
AsyncEndSupport<String> underTest =
AsyncEndSupport.create(instrumenter, CompletableFuture.class);
AsyncOperationEndSupport<String> underTest =
AsyncOperationEndSupport.create(instrumenter, CompletableFuture.class);

Context context = Context.root();

Expand All @@ -81,7 +82,8 @@ void shouldEndImmediatelyWhenAsyncWrapperisOfWrongType() {
@Test
void shouldReturnedDecoratedAsyncWrapper() {
// given
AsyncEndSupport<String> underTest = AsyncEndSupport.create(instrumenter, CompletionStage.class);
AsyncOperationEndSupport<String> underTest =
AsyncOperationEndSupport.create(instrumenter, CompletionStage.class);

Context context = Context.root();
CompletableFuture<String> future = new CompletableFuture<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.instrumentation.api.asyncannotationsupport.AsyncEndSupport;
import io.opentelemetry.instrumentation.api.asyncannotationsupport.AsyncOperationEndSupport;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -76,7 +76,7 @@ public static void stopSpan(
scope.close();

returnValue =
AsyncEndSupport.create(instrumenter(), method.getReturnType())
AsyncOperationEndSupport.create(instrumenter(), method.getReturnType())
.asyncEnd(context, method, returnValue, throwable);
}
}
Expand Down

0 comments on commit 4e8996a

Please sign in to comment.