Skip to content

Commit d5a7365

Browse files
Revert "rename AsyncOperationEndXX to AsyncEndXX, rename AttributeForReturnValue to AttributeReturnValue"
This reverts commit aaf4b3a.
1 parent efbf2cd commit d5a7365

File tree

42 files changed

+390
-374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+390
-374
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
@Target(ElementType.METHOD)
3131
@Retention(RetentionPolicy.RUNTIME)
32-
public @interface AttributeReturnValue {
32+
public @interface AttributeForReturnValue {
3333

3434
/**
3535
* Attribute name for the return value.

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

Lines changed: 0 additions & 45 deletions
This file was deleted.

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

Lines changed: 0 additions & 109 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
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 AsyncEndHandler<REQUEST, RESPONSE> {
12+
public interface AsyncOperationEndHandler<REQUEST, RESPONSE> {
1313
void handle(
1414
Context context, REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error);
1515
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.api.annotation.support.async;
7+
8+
import javax.annotation.Nullable;
9+
10+
/** A global registry of {@link AsyncOperationEndStrategy} implementations. */
11+
public abstract class AsyncOperationEndStrategies {
12+
private static volatile AsyncOperationEndStrategies instance;
13+
14+
/**
15+
* Sets the actual strategies' registry implementation. The javaagent uses weak references to make
16+
* unloading strategy classes possible.
17+
*
18+
* <p>This is supposed to be only called by the javaagent. <b>Instrumentation must not call
19+
* this.</b>
20+
*/
21+
public static void internalSetStrategiesStorage(AsyncOperationEndStrategies strategies) {
22+
instance = strategies;
23+
}
24+
25+
/** Obtain instance of the async strategy registry. */
26+
public static AsyncOperationEndStrategies instance() {
27+
if (instance == null) {
28+
instance = new AsyncOperationEndStrategiesImpl();
29+
}
30+
return instance;
31+
}
32+
33+
/** Add the passed {@code strategy} to the registry. */
34+
public abstract void registerStrategy(AsyncOperationEndStrategy strategy);
35+
36+
/** Remove the passed {@code strategy} from the registry. */
37+
public abstract void unregisterStrategy(AsyncOperationEndStrategy strategy);
38+
39+
/**
40+
* Returns an {@link AsyncOperationEndStrategy} that is able to compose over {@code returnType},
41+
* or {@code null} if passed type is not supported by any of the strategies stored in this
42+
* registry.
43+
*/
44+
@Nullable
45+
public abstract AsyncOperationEndStrategy resolveStrategy(Class<?> returnType);
46+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@
1212
import javax.annotation.Nullable;
1313

1414
/** Default strategies' registry implementation that uses strong references. */
15-
final class AsyncEndStrategiesImpl extends AsyncEndStrategies {
16-
private final List<AsyncEndStrategy> strategies = new CopyOnWriteArrayList<>();
15+
final class AsyncOperationEndStrategiesImpl extends AsyncOperationEndStrategies {
16+
private final List<AsyncOperationEndStrategy> strategies = new CopyOnWriteArrayList<>();
1717

18-
AsyncEndStrategiesImpl() {
19-
registerStrategy(Jdk8AsyncEndStrategy.INSTANCE);
18+
AsyncOperationEndStrategiesImpl() {
19+
registerStrategy(Jdk8AsyncOperationEndStrategy.INSTANCE);
2020
}
2121

2222
@Override
23-
public void registerStrategy(AsyncEndStrategy strategy) {
23+
public void registerStrategy(AsyncOperationEndStrategy strategy) {
2424
strategies.add(requireNonNull(strategy));
2525
}
2626

2727
@Override
28-
public void unregisterStrategy(AsyncEndStrategy strategy) {
28+
public void unregisterStrategy(AsyncOperationEndStrategy strategy) {
2929
strategies.remove(strategy);
3030
}
3131

3232
@Nullable
3333
@Override
34-
public AsyncEndStrategy resolveStrategy(Class<?> returnType) {
35-
for (AsyncEndStrategy strategy : strategies) {
34+
public AsyncOperationEndStrategy resolveStrategy(Class<?> returnType) {
35+
for (AsyncOperationEndStrategy strategy : strategies) {
3636
if (strategy.supports(returnType)) {
3737
return strategy;
3838
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
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-
* AsyncEndHandler#handle(Context, Object, Object, Throwable)}.
15+
* AsyncOperationEndHandler#handle(Context, Object, Object, Throwable)}.
1616
*/
17-
public interface AsyncEndStrategy {
17+
public interface AsyncOperationEndStrategy {
1818

1919
/**
2020
* Returns true for every asynchronous computation type {@code asyncType} this strategy supports.
@@ -47,12 +47,12 @@ default <REQUEST, RESPONSE> Object end(
4747
}
4848

4949
/**
50-
* Composes over {@code asyncValue} and delays the {@link AsyncEndHandler#handle(Context, Object,
51-
* Object, Throwable)} call until after the asynchronous operation represented by {@code
50+
* Composes over {@code asyncValue} and delays the {@link AsyncOperationEndHandler#handle(Context,
51+
* Object, Object, Throwable)} call until after the asynchronous operation represented by {@code
5252
* asyncValue} completes.
5353
*
54-
* @param handler The {@link AsyncEndHandler} to be used to end the operation stored in the {@code
55-
* context}.
54+
* @param handler The {@link AsyncOperationEndHandler} to be used to end the operation stored in
55+
* the {@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-
AsyncEndHandler<REQUEST, RESPONSE> handler,
66+
AsyncOperationEndHandler<REQUEST, RESPONSE> handler,
6767
Context context,
6868
REQUEST request,
6969
Object asyncValue,

0 commit comments

Comments
 (0)