Skip to content

Commit 8f0ce07

Browse files
authored
Merge branch 'main' into db-refactoring
2 parents 2d367bb + c0b075a commit 8f0ce07

File tree

6 files changed

+77
-43
lines changed

6 files changed

+77
-43
lines changed

.github/repository-settings.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ private admin repo.
88

99
### Repository secrets
1010

11+
- `FLAKY_TEST_REPORTER_ACCESS_KEY` - owned by [@laurit](https://github.com/laurit)
1112
- `GPG_PASSWORD` - stored in OpenTelemetry-Java 1Password
1213
- `GPG_PRIVATE_KEY` - stored in OpenTelemetry-Java 1Password
1314
- `GRADLE_PUBLISH_KEY`
@@ -17,14 +18,13 @@ private admin repo.
1718
- Key is associated with [@trask](https://github.com/trask)'s gmail address
1819
- `SONATYPE_KEY` - owned by [@trask](https://github.com/trask)
1920
- `SONATYPE_USER` - owned by [@trask](https://github.com/trask)
20-
- `FLAKY_TEST_REPORTER_ACCESS_KEY` - owned by [@laurit](https://github.com/laurit)
2121

2222
### Organization secrets
2323

24-
- `DEVELOCITY_ACCESS_KEY`
24+
- `DEVELOCITY_ACCESS_KEY` (scoped only to Java repos)
2525
- `FOSSA_API_KEY`
26+
- `OTELBOT_JAVA_INSTRUMENTATION_PRIVATE_KEY` (scoped only to this repo)
2627
- `OTELBOT_PRIVATE_KEY`
27-
- `OTELBOT_JAVA_INSTRUMENTATION_PRIVATE_KEY`
2828

2929
### Organization variables
3030

instrumentation/liberty/liberty-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/LibertyInstrumentationModule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.google.auto.service.AutoService;
1111
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
1212
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
13+
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
1314
import java.util.List;
1415

1516
/**
@@ -26,7 +27,8 @@
2627
* </ul>
2728
*/
2829
@AutoService(InstrumentationModule.class)
29-
public class LibertyInstrumentationModule extends InstrumentationModule {
30+
public class LibertyInstrumentationModule extends InstrumentationModule
31+
implements ExperimentalInstrumentationModule {
3032

3133
public LibertyInstrumentationModule() {
3234
super("liberty", "liberty-20.0");
@@ -36,4 +38,9 @@ public LibertyInstrumentationModule() {
3638
public List<TypeInstrumentation> typeInstrumentations() {
3739
return singletonList(new LibertyWebAppInstrumentation());
3840
}
41+
42+
@Override
43+
public boolean isIndyReady() {
44+
return true;
45+
}
3946
}

instrumentation/liberty/liberty-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/LibertyWebAppInstrumentation.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
1818
import io.opentelemetry.javaagent.instrumentation.servlet.ServletRequestContext;
1919
import io.opentelemetry.javaagent.instrumentation.servlet.v3_0.Servlet3Accessor;
20+
import javax.annotation.Nullable;
2021
import javax.servlet.ServletRequest;
2122
import javax.servlet.ServletResponse;
2223
import javax.servlet.http.HttpServletRequest;
@@ -51,33 +52,33 @@ public void transform(TypeTransformer transformer) {
5152
public static class HandleRequestAdvice {
5253

5354
@Advice.OnMethodEnter(suppress = Throwable.class)
54-
public static void onEnter(
55+
public static boolean onEnter(
5556
@Advice.Argument(value = 0) ServletRequest request,
56-
@Advice.Argument(value = 1) ServletResponse response,
57-
@Advice.Local("otelHandled") boolean handled) {
57+
@Advice.Argument(value = 1) ServletResponse response) {
5858

5959
// liberty has two handleRequest methods, skip processing when thread local context is already
6060
// set up
61-
handled = ThreadLocalContext.get() == null;
61+
boolean handled = ThreadLocalContext.get() == null;
6262
if (!handled
6363
|| !(request instanceof HttpServletRequest)
6464
|| !(response instanceof HttpServletResponse)) {
65-
return;
65+
return false;
6666
}
6767

6868
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
6969
// it is a bit too early to start span at this point because calling
7070
// some methods on HttpServletRequest will give a NPE
7171
// just remember the request and use it a bit later to start the span
7272
ThreadLocalContext.startRequest(httpServletRequest, (HttpServletResponse) response);
73+
return true;
7374
}
7475

7576
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
7677
public static void stopSpan(
7778
@Advice.Argument(0) ServletRequest servletRequest,
7879
@Advice.Argument(1) ServletResponse servletResponse,
79-
@Advice.Thrown Throwable throwable,
80-
@Advice.Local("otelHandled") boolean handled) {
80+
@Advice.Thrown @Nullable Throwable throwable,
81+
@Advice.Enter boolean handled) {
8182
if (!handled) {
8283
return;
8384
}

instrumentation/liberty/liberty-dispatcher-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherInstrumentationModule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
import com.google.auto.service.AutoService;
1111
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
1212
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
13+
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
1314
import java.util.List;
1415

1516
@AutoService(InstrumentationModule.class)
16-
public class LibertyDispatcherInstrumentationModule extends InstrumentationModule {
17+
public class LibertyDispatcherInstrumentationModule extends InstrumentationModule
18+
implements ExperimentalInstrumentationModule {
1719

1820
public LibertyDispatcherInstrumentationModule() {
1921
super("liberty-dispatcher", "liberty-dispatcher-20.0", "liberty");
@@ -23,4 +25,9 @@ public LibertyDispatcherInstrumentationModule() {
2325
public List<TypeInstrumentation> typeInstrumentations() {
2426
return singletonList(new LibertyDispatcherLinkInstrumentation());
2527
}
28+
29+
@Override
30+
public boolean isIndyReady() {
31+
return true;
32+
}
2633
}

instrumentation/liberty/liberty-dispatcher-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherLinkInstrumentation.java

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
import com.ibm.wsspi.http.channel.values.StatusCodes;
1515
import io.opentelemetry.context.Context;
1616
import io.opentelemetry.context.Scope;
17-
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
1817
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
1918
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
19+
import javax.annotation.Nullable;
2020
import net.bytebuddy.asm.Advice;
2121
import net.bytebuddy.description.type.TypeDescription;
2222
import net.bytebuddy.matcher.ElementMatcher;
@@ -50,45 +50,63 @@ public void transform(TypeTransformer transformer) {
5050
@SuppressWarnings("unused")
5151
public static class SendResponseAdvice {
5252

53-
@Advice.OnMethodEnter(suppress = Throwable.class)
54-
public static void onEnter(
55-
@Advice.FieldValue("isc") HttpInboundServiceContextImpl isc,
56-
@Advice.Local("otelRequest") LibertyRequest request,
57-
@Advice.Local("otelContext") Context context,
58-
@Advice.Local("otelScope") Scope scope) {
59-
Context parentContext = Java8BytecodeBridge.currentContext();
60-
request =
61-
new LibertyRequest(
62-
isc.getRequest(),
63-
isc.getLocalAddr(),
64-
isc.getLocalPort(),
65-
isc.getRemoteAddr(),
66-
isc.getRemotePort());
67-
if (!instrumenter().shouldStart(parentContext, request)) {
68-
return;
53+
public static class AdviceScope {
54+
private final LibertyRequest request;
55+
private final Context context;
56+
private final Scope scope;
57+
58+
private AdviceScope(LibertyRequest request, Context context, Scope scope) {
59+
this.request = request;
60+
this.context = context;
61+
this.scope = scope;
62+
}
63+
64+
@Nullable
65+
public static AdviceScope start(HttpInboundServiceContextImpl isc) {
66+
Context parentContext = Context.current();
67+
LibertyRequest request =
68+
new LibertyRequest(
69+
isc.getRequest(),
70+
isc.getLocalAddr(),
71+
isc.getLocalPort(),
72+
isc.getRemoteAddr(),
73+
isc.getRemotePort());
74+
if (!instrumenter().shouldStart(parentContext, request)) {
75+
return null;
76+
}
77+
Context context = instrumenter().start(parentContext, request);
78+
return new AdviceScope(request, context, context.makeCurrent());
79+
}
80+
81+
public void end(
82+
HttpDispatcherLink httpDispatcherLink,
83+
@Nullable Throwable throwable,
84+
StatusCodes statusCode,
85+
@Nullable Exception failure) {
86+
scope.close();
87+
88+
LibertyResponse response = new LibertyResponse(httpDispatcherLink, statusCode);
89+
Throwable t = failure != null ? failure : throwable;
90+
instrumenter().end(context, request, response, t);
6991
}
70-
context = instrumenter().start(parentContext, request);
71-
scope = context.makeCurrent();
92+
}
93+
94+
@Advice.OnMethodEnter(suppress = Throwable.class)
95+
public static AdviceScope onEnter(@Advice.FieldValue("isc") HttpInboundServiceContextImpl isc) {
96+
return AdviceScope.start(isc);
7297
}
7398

7499
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
75100
public static void stopSpan(
76101
@Advice.This HttpDispatcherLink httpDispatcherLink,
77-
@Advice.Thrown Throwable throwable,
102+
@Advice.Thrown @Nullable Throwable throwable,
78103
@Advice.Argument(value = 0) StatusCodes statusCode,
79104
@Advice.Argument(value = 2) Exception failure,
80-
@Advice.Local("otelRequest") LibertyRequest request,
81-
@Advice.Local("otelContext") Context context,
82-
@Advice.Local("otelScope") Scope scope) {
83-
if (scope == null) {
84-
return;
85-
}
86-
scope.close();
87-
88-
LibertyResponse response = new LibertyResponse(httpDispatcherLink, statusCode);
105+
@Advice.Enter @Nullable AdviceScope adviceScope) {
89106

90-
Throwable t = failure != null ? failure : throwable;
91-
instrumenter().end(context, request, response, t);
107+
if (adviceScope != null) {
108+
adviceScope.end(httpDispatcherLink, throwable, statusCode, failure);
109+
}
92110
}
93111
}
94112
}

instrumentation/quartz-2.0/javaagent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ muzzle {
88
module.set("quartz")
99
versions.set("[2.0.0,)")
1010
assertInverse.set(true)
11+
skip("1.7.0") // missing in maven central
1112
}
1213
}
1314

0 commit comments

Comments
 (0)