When trying to add open telemetry to my Selenium 4 tests
like this
System.setProperty("otel.traces.exporter", "jaeger");
System.setProperty("otel.exporter.jaeger.endpoint", "http://localhost:14250");
System.setProperty("JAEGER_SERVICE_NAME", "client");
System.setProperty("otel.resource.attributes", "service.name=selenium-java-try");
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-jaeger</artifactId>
<version>1.23.1</version>
</dependency>
I get this error:
java.lang.NoClassDefFoundError: io/opentelemetry/sdk/logs/SdkLogEmitterProviderBuilder
at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.<init>(AutoConfiguredOpenTelemetrySdkBuilder.java:69)
So I added the these as well:
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<version>1.23.1</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-logs</artifactId>
<version>1.23.1-alpha</version>
</dependency>
But still no success..
Who to set-up the dependencies/configuration so that I can start using jaeger-over-otel?
I was able to work around this by setting enableTracing to false when creating the RemoteWebDriver
:
webDriver = new RemoteWebDriver(remoteAddress, capabilities, false);
Although I'm using opentelemetry-sdk:1.22.0
, selenium-remote-driver
(4.1.4) is pulling in an earlier version (1.13.x) of opentelemetry-sdk-extension-autoconfigure
.
AutoConfiguredOpenTelemetrySdkBuilder
(in opentelemetry-sdk-extension-autoconfigure
) references SdkLogEmitterProviderBuilder
but that class was renamed in OpenTelemetry 1.19.0 so it is not found.
There is an issue against Selenium describing the problem, which suggests selenium-remote-driver
is incorrectly depending on the sdk instead of just the api. However, the issue has been closed and the most recent version (currently 4.9.0) still depends on the sdk.
Picking a recent enough version of selenium-remote-driver
to align its version of opentelemetry-sdk
with the one in your project might be good enough but feels a bit brittle.