Skip to content

Commit 283f589

Browse files
committed
minor code changes for consistency
1 parent 43bee25 commit 283f589

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-annotations/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v2_0/DefaultRequestContextInstrumentation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static AdviceScope enter(Class<?> filterClass, Method method) {
6767
return new AdviceScope(context, context.makeCurrent(), handlerData);
6868
}
6969

70-
public void end(Throwable throwable) {
70+
public void exit(Throwable throwable) {
7171
if (scope == null) {
7272
return;
7373
}
@@ -111,7 +111,7 @@ public static void stopSpan(
111111
@Advice.Enter @Nullable AdviceScope adviceScope) {
112112

113113
if (adviceScope != null) {
114-
adviceScope.end(throwable);
114+
adviceScope.exit(throwable);
115115
}
116116
}
117117
}

instrumentation/jaxrs/jaxrs-2.0/jaxrs-2.0-resteasy-3.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v2_0/Resteasy31RequestContextInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public AdviceScope(
5151
scope = context != null ? context.makeCurrent() : null;
5252
}
5353

54-
public void exit(Throwable throwable) {
54+
public void exit(@Nullable Throwable throwable) {
5555
if (scope == null) {
5656
return;
5757
}

instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-annotations/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v3_0/DefaultRequestContextInstrumentation.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private AdviceScope(Context context, Scope scope, Jaxrs3HandlerData handlerData)
4949
}
5050

5151
@Nullable
52-
public static AdviceScope start(
52+
public static AdviceScope enter(
5353
Class<?> filterClass, Method method, ContainerRequestContext requestContext) {
5454
Context parentContext = Java8BytecodeBridge.currentContext();
5555
Jaxrs3HandlerData handlerData = new Jaxrs3HandlerData(filterClass, method);
@@ -65,15 +65,10 @@ public static AdviceScope start(
6565
}
6666

6767
Context context = instrumenter().start(parentContext, handlerData);
68-
Scope scope = context.makeCurrent();
69-
return new AdviceScope(context, scope, handlerData);
68+
return new AdviceScope(context, context.makeCurrent(), handlerData);
7069
}
7170

7271
public void exit(@Nullable Throwable throwable) {
73-
if (scope == null) {
74-
return;
75-
}
76-
7772
scope.close();
7873
instrumenter().end(context, handlerData, null, throwable);
7974
}
@@ -103,7 +98,7 @@ public static AdviceScope createGenericSpan(
10398
return null;
10499
}
105100

106-
return AdviceScope.start(filterClass, method, requestContext);
101+
return AdviceScope.enter(filterClass, method, requestContext);
107102
}
108103

109104
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)

instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-annotations/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v3_0/JaxrsAnnotationsInstrumentation.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ public void transform(TypeTransformer transformer) {
7373
public static class JaxRsAnnotationsAdvice {
7474

7575
public static class AdviceScope {
76-
public Jaxrs3HandlerData handlerData;
77-
public final AsyncResponse asyncResponse;
78-
public final CallDepth callDepth;
79-
public final Context context;
80-
public final Scope scope;
76+
private final Jaxrs3HandlerData handlerData;
77+
private final AsyncResponse asyncResponse;
78+
private final CallDepth callDepth;
79+
private final Context context;
80+
private final Scope scope;
8181

8282
public AdviceScope(CallDepth callDepth, Class<?> type, Method method, Object[] args) {
8383
this.callDepth = callDepth;
8484
if (callDepth.getAndIncrement() > 0) {
85+
handlerData = null;
8586
asyncResponse = null;
8687
context = null;
8788
scope = null;
@@ -99,6 +100,7 @@ public AdviceScope(CallDepth callDepth, Class<?> type, Method method, Object[] a
99100
* could work around this by using a list instead, but we likely don't want the extra
100101
* span anyway.
101102
*/
103+
handlerData = null;
102104
asyncResponse = null;
103105
context = null;
104106
scope = null;

instrumentation/jaxrs/jaxrs-3.0/jaxrs-3.0-jersey-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrs/v3_0/JerseyRequestContextInstrumentation.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,17 @@ protected String abortAdviceName() {
3636
public static class ContainerRequestContextAdvice {
3737

3838
public static class AdviceScope {
39-
public Jaxrs3HandlerData handlerData;
40-
public Context context;
41-
public Scope scope;
39+
private final Jaxrs3HandlerData handlerData;
40+
private final Context context;
41+
private final Scope scope;
4242

4343
public AdviceScope(
4444
Class<?> resourceClass, Method method, ContainerRequestContext requestContext) {
4545
handlerData = new Jaxrs3HandlerData(resourceClass, method);
4646
context =
4747
Jaxrs3RequestContextHelper.createOrUpdateAbortSpan(
4848
instrumenter(), requestContext, handlerData);
49-
if (context != null) {
50-
scope = context.makeCurrent();
51-
}
49+
scope = context != null ? context.makeCurrent() : null;
5250
}
5351

5452
public void exit(@Nullable Throwable throwable) {

0 commit comments

Comments
 (0)