reuse class file locator for DDAdvice
@@ -9,6 +9,7 @@ import net.bytebuddy.dynamic.ClassFileLocator;
@Slf4j
public class DDAdvice extends AgentBuilder.Transformer.ForAdvice {
private static ClassLoader AGENT_CLASSLOADER;
+ private static ClassFileLocator AGENT_CLASS_LOCATOR;
static {
try {
@@ -20,13 +21,17 @@ public class DDAdvice extends AgentBuilder.Transformer.ForAdvice {
log.error("Unable to locate agent classloader. Falling back to System Classloader");
AGENT_CLASSLOADER = ClassLoader.getSystemClassLoader();
}
+ AGENT_CLASS_LOCATOR = ClassFileLocator.ForClassLoader.of(AGENT_CLASSLOADER);
}
+ /**
+ * Create bytebuddy advice with default datadog settings.
+ *
+ * @return the bytebuddy advice
+ */
public static AgentBuilder.Transformer.ForAdvice create() {
return new DDAdvice()
- .with(
- new AgentBuilder.LocationStrategy.Simple(
- ClassFileLocator.ForClassLoader.of(AGENT_CLASSLOADER)))
+ .with(new AgentBuilder.LocationStrategy.Simple(AGENT_CLASS_LOCATOR))
.withExceptionHandler(ExceptionHandlers.defaultExceptionHandler());
}
