Skip to content

Commit 8d3ed5a

Browse files
committed
Limit ExceptionLogger to ByteBuddy suppression
1 parent d7be861 commit 8d3ed5a

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

.github/agents/knowledge/general-rules.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,12 @@ Only flag substantive problems, not stylistic preference.
6060
## [Javaagent] Best-Effort Suppressed Failures
6161

6262
When javaagent runtime code intentionally suppresses a `Throwable` to avoid breaking the
63-
application, do not silently swallow it.
64-
65-
- Prefer `ExceptionLogger.logSuppressedError(...)` for suppressed failures in javaagent code.
66-
It logs at `FINE` and matches the agent's default ByteBuddy advice suppression path in
67-
`ExceptionHandlers.defaultExceptionHandler()`.
68-
- Use this for best-effort hooks such as response customizers, bootstrap fallbacks, or other
69-
optional extension points where failure must not change application behavior.
70-
- Do not introduce ad-hoc local loggers for one-off suppressed javaagent failures when
71-
`ExceptionLogger` is available from bootstrap.
63+
application, do not silently swallow it unless the failure is an expected optional probe.
64+
65+
- In ordinary instrumentation implementation code, local JUL `logger.log(FINE, ...)` is an
66+
established pattern and preserves module / class logger identity.
67+
- Silent suppression is acceptable for expected optional-probe paths, such as classpath or
68+
version-detection lookups where failure is routine and logging would be noisy.
7269
- Keep the message action-oriented and specific (for example, "Failed to customize Netty 4.1
7370
HTTP server response").
7471

instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonRequest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
import static java.util.Collections.emptyList;
99
import static java.util.Collections.singletonList;
10+
import static java.util.logging.Level.FINE;
1011

1112
import com.google.auto.value.AutoValue;
1213
import io.netty.buffer.ByteBuf;
1314
import io.opentelemetry.api.GlobalOpenTelemetry;
1415
import io.opentelemetry.instrumentation.api.incubator.config.internal.DbConfig;
1516
import io.opentelemetry.instrumentation.api.incubator.semconv.db.RedisCommandSanitizer;
16-
import io.opentelemetry.javaagent.bootstrap.ExceptionLogger;
1717
import java.lang.invoke.MethodHandle;
1818
import java.lang.invoke.MethodHandles;
1919
import java.lang.invoke.MethodType;
@@ -22,13 +22,16 @@
2222
import java.util.List;
2323
import java.util.concurrent.CompletableFuture;
2424
import java.util.concurrent.CompletionStage;
25+
import java.util.logging.Logger;
2526
import javax.annotation.Nullable;
2627
import org.redisson.client.protocol.CommandData;
2728
import org.redisson.client.protocol.CommandsData;
2829

2930
@AutoValue
3031
public abstract class RedissonRequest {
3132

33+
private static final Logger logger = Logger.getLogger(RedissonRequest.class.getName());
34+
3235
private static final RedisCommandSanitizer sanitizer =
3336
RedisCommandSanitizer.create(
3437
DbConfig.isQuerySanitizationEnabled(GlobalOpenTelemetry.get(), "redisson"));
@@ -126,14 +129,14 @@ private CompletionStage<?> getPromise() {
126129
try {
127130
return (CompletionStage<?>) COMMAND_DATA_GET_PROMISE.invoke(command);
128131
} catch (Throwable t) {
129-
ExceptionLogger.logSuppressedError("Failed to get Redisson command promise", t);
132+
logger.log(FINE, "Failed to get Redisson command promise", t);
130133
return null;
131134
}
132135
} else if (command instanceof CommandsData && COMMANDS_DATA_GET_PROMISE != null) {
133136
try {
134137
return (CompletionStage<?>) COMMANDS_DATA_GET_PROMISE.invoke(command);
135138
} catch (Throwable t) {
136-
ExceptionLogger.logSuppressedError("Failed to get Redisson commands promise", t);
139+
logger.log(FINE, "Failed to get Redisson commands promise", t);
137140
return null;
138141
}
139142
}

javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/IndyBootstrapDispatcher.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55

66
package io.opentelemetry.javaagent.bootstrap;
77

8+
import static java.util.logging.Level.FINE;
9+
810
import io.opentelemetry.instrumentation.api.internal.Initializer;
911
import java.lang.invoke.CallSite;
1012
import java.lang.invoke.ConstantCallSite;
1113
import java.lang.invoke.MethodHandle;
1214
import java.lang.invoke.MethodHandles;
1315
import java.lang.invoke.MethodType;
1416
import java.lang.reflect.Array;
17+
import java.util.logging.Logger;
1518
import javax.annotation.Nullable;
1619

1720
/**
@@ -20,6 +23,8 @@
2023
*/
2124
public class IndyBootstrapDispatcher {
2225

26+
private static final Logger logger = Logger.getLogger(IndyBootstrapDispatcher.class.getName());
27+
2328
private static volatile MethodHandle bootstrap;
2429

2530
private IndyBootstrapDispatcher() {}
@@ -45,7 +50,7 @@ public static CallSite bootstrap(
4550
try {
4651
callSite = (CallSite) bootstrap.invoke(lookup, adviceMethodName, adviceMethodType, args);
4752
} catch (Throwable e) {
48-
ExceptionLogger.logSuppressedError("Error bootstrapping indy instruction", e);
53+
logger.log(FINE, "Error bootstrapping indy instruction", e);
4954
}
5055
}
5156
if (callSite == null) {

javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/AgentInstaller.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import io.opentelemetry.javaagent.bootstrap.AgentClassLoader;
2323
import io.opentelemetry.javaagent.bootstrap.BootstrapPackagePrefixesHolder;
2424
import io.opentelemetry.javaagent.bootstrap.DefineClassHelper;
25-
import io.opentelemetry.javaagent.bootstrap.ExceptionLogger;
2625
import io.opentelemetry.javaagent.bootstrap.InstrumentedTaskClasses;
2726
import io.opentelemetry.javaagent.bootstrap.LambdaTransformer;
2827
import io.opentelemetry.javaagent.bootstrap.LambdaTransformerHolder;
@@ -317,7 +316,8 @@ public <T> void customize(
317316
try {
318317
modifier.customize(serverContext, response, responseMutator);
319318
} catch (Throwable t) {
320-
ExceptionLogger.logSuppressedError(
319+
logger.log(
320+
FINE,
321321
"Failed to customize HTTP server response with "
322322
+ modifier.getClass().getName(),
323323
t);

0 commit comments

Comments
 (0)