Skip to content

Commit 6822a7f

Browse files
committed
fix distribution example
1 parent 74d6b87 commit 6822a7f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

examples/distro/instrumentation/servlet-3/src/main/java/com/example/javaagent/instrumentation/DemoServlet3HelperClass.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
package com.example.javaagent.instrumentation;
77

88
import com.example.javaagent.bootstrap.AgentApi;
9+
import io.opentelemetry.instrumentation.api.util.VirtualField;
10+
import java.util.concurrent.atomic.AtomicInteger;
11+
import javax.servlet.ServletResponse;
912

1013
public final class DemoServlet3HelperClass {
1114

12-
public final VirtualField<ServletResponse, AtomicInteger> VIRTUAL_FIELD =
15+
public static final VirtualField<ServletResponse, AtomicInteger> VIRTUAL_FIELD =
1316
VirtualField.find(ServletResponse.class, AtomicInteger.class);
1417

1518
public static void doSomething(int number) {

examples/distro/instrumentation/servlet-3/src/main/java/com/example/javaagent/instrumentation/DemoServlet3Instrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void onEnter(@Advice.Argument(value = 1) ServletResponse response)
4747
AtomicInteger counter = DemoServlet3HelperClass.VIRTUAL_FIELD.get(response);
4848
if (counter == null) {
4949
counter = new AtomicInteger();
50-
virtualField.set(response, counter);
50+
DemoServlet3HelperClass.VIRTUAL_FIELD.set(response, counter);
5151
}
5252
DemoServlet3HelperClass.doSomething(counter.incrementAndGet());
5353

0 commit comments

Comments
 (0)