Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: "java.lang.IllegalStateException: Context has not been changed" error is thrown by Selenium server running in a hub mode during attempt to add node when using OpenTelemetry instrumentation agent #15552

Open
AndriyShykin opened this issue Apr 2, 2025 · 4 comments
Labels
B-grid Everything grid and server related I-defect Something is not working as intended

Comments

@AndriyShykin
Copy link

What happened?

I am encountering an error when trying to run Selenium grid in a hub-node mode with added OpenTelemetry instrumentation (https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar, version 2.14.0).

"java.lang.IllegalStateException: Context has not been changed" exception is thrown by Selenium server running in a hub mode, and the node is not added.

java --version output:
java 21.0.3 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 21.0.3+7-LTS-152)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.3+7-LTS-152, mixed mode, sharing)

java -jar opentelemetry-javaagent.jar --version output:
2.14.0

How can we reproduce the issue?

Selenium hub is started by command:
java -javaagent:opentelemetry-javaagent.jar -jar selenium-server-4.30.0.jar hub --log-level fine

Selenium node is started by command:
java -jar selenium-server-4.30.0.jar node

Relevant log output

07:42:02.332 DEBUG [LocalDistributor.add] - Exception while adding Node http://***.***.**.**:5555
java.lang.IllegalStateException: Context has not been changed
	at org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryContext.createSpan(OpenTelemetryContext.java:59)
	at org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryContext.createSpan(OpenTelemetryContext.java:30)
	at org.openqa.selenium.remote.tracing.HttpTracing.newSpanAsChildOf(HttpTracing.java:48)
	at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:50)
	at org.openqa.selenium.grid.node.remote.RemoteNode.getStatus(RemoteNode.java:254)
	at org.openqa.selenium.grid.distributor.local.LocalDistributor.add(LocalDistributor.java:350)
	at org.openqa.selenium.grid.distributor.local.LocalDistributor.register(LocalDistributor.java:335)
	at org.openqa.selenium.events.EventListener.accept(EventListener.java:42)
	at org.openqa.selenium.events.EventListener.accept(EventListener.java:24)
	at org.openqa.selenium.events.zeromq.UnboundZmqEventBus$PollingRunnable.lambda$notifyListeners$2(UnboundZmqEventBus.java:325)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Operating System

macOS 15.4

Selenium version

Java 4.30.0

What are the browser(s) and version(s) where you see this issue?

What are the browser driver(s) and version(s) where you see this issue?

Are you using Selenium Grid?

4.30.0

@AndriyShykin AndriyShykin added the I-defect Something is not working as intended label Apr 2, 2025
@diemol
Copy link
Member

diemol commented Apr 2, 2025

@pujagani @VietND96 do you know what the issue is?

@diemol diemol added the B-grid Everything grid and server related label Apr 2, 2025
@VietND96
Copy link
Member

VietND96 commented Apr 2, 2025

Looks like after this change 892babe

@joerg1985
Copy link
Member

joerg1985 commented Apr 3, 2025

This happens for 4.29.0 too, so this is not related to 892babe in my mind.

@AndriyShykin why are you using the agent based instrumentation, selenium does implement tracing. So there should be no need to add this, but i never used it, so i might be wrong.

@AndriyShykin
Copy link
Author

@joerg1985 Selenium needs external dependencies for telemetry on the classpath. I have used OpenTelemetry instrumentation agent before and the assumption was it should work here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-grid Everything grid and server related I-defect Something is not working as intended
Projects
None yet
Development

No branches or pull requests

4 participants