-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Describe the bug
I'm developing a custom OpenTelemetry agent extension that provides a SpanExporter that bridges OpenTelemetry with our proprietary telemetry solution. Implementation-wise, the encoded Collection<SpanData> must be sent over HTTP. I've tried using the built-in java.net.http.HttpClient for this purpose and, quite surprisingly, got a ClassNotFoundException from the extension class loader.
As far as I understand, it's caused by the class name filtering here:
Lines 486 to 495 in 3100f0b
| @Override | |
| protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { | |
| // prometheus exporter uses jdk http server, load it from the platform class loader | |
| // some custom extensions use java.sql classes, make these available to agent and extensions | |
| if (name != null | |
| && (name.startsWith("com.sun.net.httpserver.") || name.startsWith("java.sql."))) { | |
| return platformClassLoader.loadClass(name); | |
| } | |
| return Class.forName(name, false, null); | |
| } |
Is there a particular reason why the filter does not allow all java. classes to reach the platform class loader?
Steps to reproduce
This dummy exporter provider implementation always throws the exception for me:
public final class CustomExporterProvider implements ConfigurableSpanExporterProvider {
@Override
public SpanExporter createExporter(ConfigProperties properties) {
java.net.http.HttpClient.newBuilder().build();
return null;
}
@Override
public String getName() {
return "custom-exporter";
}
}Expected behavior
I believe that java.net.http.HttpClient should be usable as it's a platform-provided class.
Actual behavior
The java.net.http.HttpClient class can't be loaded.
Javaagent or library instrumentation version
v2.9.0
Environment
JDK: Zulu21.38+21-CA (build 21.0.5+11-LTS)
OS: macOS Sonoma 14.6.1
Additional context
No response