Skip to content

Commit

Permalink
fix instrumentation module not loading silently when duplicate helper…
Browse files Browse the repository at this point in the history
… classnames are detected.

issue open-telemetry#9752 introduced a check that prevents an instrumentation module from being loaded when duplicate helper classes are detected. Such a case may arise when a class is detected by muzzle as a helper class and at the same time it is registered in additionalHelperClasses. Before open-telemetry#9752, the module would properly load.

The proposed change will allow the instrumentation to load and log a warning. While it may be true that this is actually an issue in the instrumentation module, such cases are not obvious to find, there are modules in the field that have stopped working because this change and the fix should not lead to unintended behavior as we can expect the bytecode of the duplicates to be identical.
  • Loading branch information
FlorianBruckner committed Jan 9, 2025
1 parent c22bb59 commit f9eb7cb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import static java.util.logging.Level.FINE;
import static java.util.logging.Level.SEVERE;
import static java.util.logging.Level.WARNING;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.instrumentation.api.internal.cache.Cache;
Expand Down Expand Up @@ -183,8 +184,11 @@ public DynamicType.Builder<?> transform(
HelperClassDefinition::getClassName,
helper -> () -> helper.getBytecode().getBytecode(),
(a, b) -> {
throw new IllegalStateException(
"Duplicate classnames for helper class detected!");
logger.log(
WARNING,
"Duplicate classname for helper class in module {0} detected",
new Object[] {this.requestingName});
return a;
},
LinkedHashMap::new));

Expand Down

0 comments on commit f9eb7cb

Please sign in to comment.